2. Write a function that takes two strings as arguments. The function should return the number...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. Write a function that takes two strings as arguments. The function should return the number of times the second argument appears in the first. 3. Write a function that takes a list and an integer argument. The function should return a new list with each of the values of the argument list multiplied by the value of the integer argument. 4. Write a program that uses a dictionary to keep track of the grades associated with students. The keys of the dictionary should be student IDs and the values should be a list of grades. The user should be able to repeatedly specify a student number and the grade to add. When the user enters "quit" for the student number, print out the average grade for each student that had at least 1 grade entered. 5. Write a function that takes two string arguments. The function should return a new string value that is equivalent to the first argument with all of the occurrences of the second argument removed. For example, if the inputs are "My catdog's breath smells like catdog food" and "dog", the returned value should be "My cat's breath smells like cat food". 2. Write a function that takes two strings as arguments. The function should return the number of times the second argument appears in the first. 3. Write a function that takes a list and an integer argument. The function should return a new list with each of the values of the argument list multiplied by the value of the integer argument. 4. Write a program that uses a dictionary to keep track of the grades associated with students. The keys of the dictionary should be student IDs and the values should be a list of grades. The user should be able to repeatedly specify a student number and the grade to add. When the user enters "quit" for the student number, print out the average grade for each student that had at least 1 grade entered. 5. Write a function that takes two string arguments. The function should return a new string value that is equivalent to the first argument with all of the occurrences of the second argument removed. For example, if the inputs are "My catdog's breath smells like catdog food" and "dog", the returned value should be "My cat's breath smells like cat food".
Expert Answer:
Answer rating: 100% (QA)
Here are the solutions to the provided tasks 1 Function to count occurrences of the second string in ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
/** * WEB222 - Assignment 02 * * I declare that this assignment is my own work in accordance with * Seneca Academic Policy. No part of this assignment has been * copied manually or electronically...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
What (if anything) is wrong with each of the following statements? a. if (a > b) then c = 0; b. if a > b { c = 0; } c. if (a > b) c = 0; d. if (a > b) c = 0 else b = 0;
-
As an employee, would you prefer being given a $2400 raise each year for 5 years or a $400 raise each quarter for 5 years?
-
How does an asset gain or loss develop in pension accounting? How does a liability gain or loss develop in pension accounting?
-
Does structural modeling represent classes or objects?
-
Suppose Ramirez Ltd. Just issued a dividend of $1.89 per share on its common stock. The company paid dividends of $1.47, $1.62, $1.67, and $1.78 per share in the last four years. If the stock...
-
dy 1. 2. For each differential equation, find the particular solution that passes through the given point. 3 sin(2x); (,-1) (0.3) 3. = +1 and y'(5)=-1 and y(5)=-
-
ABC Company provided the following information for the year ended December 31, 2021: ABC Company Statement of Financial Position As of December 31, 2021 and 2020 Assets Current assets Cash and cash...
-
INFT124 -Excel Assessment 19 22 15 24 21 18 5. In cell A8, type the word "Total" (in Times New Roman 12-point font, bold). 6. To add the total amount in the Numbers column, highlight from B2 to B8,...
-
Do any of the reports you receive in the course of your work use common sizing? Why do you think so?
-
Cost varies as volume changes because of what type of cost?
-
In what ways can conflict be beneficial to a society? Can conflict actually support consensus?
-
If so, did you receive the information in a formal seminar or in an informal manner, oneon-one with another individual? Do you think this was the best way? Why?
-
Give one or two examples of how changing values and/or technology have led to changes in the law.
-
Financial Statement Analysis. Projected Statement of Cash Flows for Kohl's Corporation. Predict Three years of projected statements starting with the most recent year after the companys last issued...
-
On 1 July 2021, Croydon Ltd leased ten excavators for five years from Machines4U Ltd. The excavators are expected to have an economic life of 6 years, after which time they will have an expected...
-
Enhance the String class declaration (that is, upgrade string1.h to string2.h) by doing the following: a. Overload the + operator to allow you to join two strings into one. b. Provide a stringlow()...
-
Do Programming Exercise 1 from Chapter 9 but replace the code shown there with an appropriate golf class declaration. Replace setgolf(golf &, const char*, int) with a constructor with the appropriate...
-
The following are some desired effects. Indicate whether each can be accomplished with default arguments, function overloading, both, or neither. Provide appropriate prototypes. a. mass(density,...
-
Laura says she doesnt believe that humans were at one time chimpanzees or gorillas. Jeff says he doesnt believe it either. Explain why biologists also dont believe that humans are descended from...
-
Write a letter to Grandma telling her about drug resistance in living organisms. Explain to her why drug resistance is such a common phenomenonincluding why insects become more resistant to...
-
During a drought, the supply of seeds available to a finch population decreases. The smaller, softer seeds, which are easier to crack, are quickly eaten up. Finches with larger, stronger beaks are...
Study smarter with the SolutionInn App