WRITE A FUNCTION FOR EACH OF THE FOLLOWING TASKS (100 Pts) (a) (10 Pts) [Task-1] Define...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
WRITE A FUNCTION FOR EACH OF THE FOLLOWING TASKS (100 Pts) (a) (10 Pts) [Task-1] Define a function called repeat letters that takes a string and a number n as two parameters and prints the string with every letter repeated n times. Sample input/Output: print(repeat letters ("medipol", 3)) "mmmeeedddizipppooolll" (b) (10 Pts) [Task-2] Define a function called find_index which takes as argument a word and a letter. It will return the index of the second occurrence of the letter in the given word. Sample input/Output: print(find index("welcomehome", "e")) 6 (c) (10 Pts) [Task-3] Define a function called list_unique that takes a string str as an input, checks all letters of the string, and constructs a list that contains the list of character that appear in str. This list should not contain any duplicates. Sample input/Output: print(list_unique("ankara")) ['a', 'n', 'k', 'r'] (d) (10 Pts) [Task-4] Write a function called ngrams list that takes a string and a number n and return the n-grams of the this string as a list Sample input/Output: print(ngrams_list("computer", 2)) ["co","om","mp", "pu", "ut", "te", "er"] 2 ☆ WRITE A FUNCTION FOR EACH OF THE FOLLOWING TASKS (100 Pts) (a) (10 Pts) [Task-1] Define a function called repeat letters that takes a string and a number n as two parameters and prints the string with every letter repeated n times. Sample input/Output: print(repeat letters ("medipol", 3)) "mmmeeedddizipppooolll" (b) (10 Pts) [Task-2] Define a function called find_index which takes as argument a word and a letter. It will return the index of the second occurrence of the letter in the given word. Sample input/Output: print(find index("welcomehome", "e")) 6 (c) (10 Pts) [Task-3] Define a function called list_unique that takes a string str as an input, checks all letters of the string, and constructs a list that contains the list of character that appear in str. This list should not contain any duplicates. Sample input/Output: print(list_unique("ankara")) ['a', 'n', 'k', 'r'] (d) (10 Pts) [Task-4] Write a function called ngrams list that takes a string and a number n and return the n-grams of the this string as a list Sample input/Output: print(ngrams_list("computer", 2)) ["co","om","mp", "pu", "ut", "te", "er"] 2 ☆
Expert Answer:
Answer rating: 100% (QA)
The image shows a programming assignment with four tasks each requiring the definition of a specific ... View the full answer
Related Book For
Business Analytics Data Analysis and Decision Making
ISBN: 978-1305947542
6th edition
Authors: S. Christian Albright, Wayne L. Winston
Posted Date:
Students also viewed these programming questions
-
Wonder Woman was paying a visit to Batman so she flew her invisible jet over to the Bat Cave and parked it outside. As she approached the Bat Cave the camouflage covering began to open. Wonder Woman...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
"I'm not sure we should lay out $300,000 for that automated welding machine," said Jim Alder, president of the Superior Equipment Company. "That's a lot of money, and it would cost us $84,000 for...
-
The Wall Street Journal reported interest rates of 6 percent, 6.35 percent, 6.65 percent, and 6.75 percent for three-year, four-year, five-year, and six-year Treasury notes, respectively. According...
-
Sparky's Mountain Bikes Ltd. markets mountain-bike tours to clients vacationing in various locations in the mountains of British Columbia. On March 1, 2015, the company had a balance of $30,000 in...
-
On July 1, 2022, Crowe NV pays 15,000 to Zubin Insurance for a 3-year insurance policy. Both companies have fiscal years ending December 31. For Crowe NV journalize the entry on July 1 and the...
-
Determining the limitations of the constitutional doctrine of due process has been a difficult issue to resolve. Use the Internet to research specific California cases in which a court considered...
-
Assume that both portfolios a and b are well diversified? that E(rA)=12% and E(rB)=9%. If the economy has only one factor and beta=1.2 whereas beta=.8, what must be the risk-free rate?
-
Monica Gellar owns a famous restaurant called Famous Kitchen. During a busy night at the restaurant, a spark went off in the kitchen and caused a fire. The restaurant had to immediately shut down....
-
At age 25, someone sets up an IRA (individual retirement account) with an APR of 5%. At the end of each month he deposits $60 in the account. How much will the IRA contain when he retires at age 65?...
-
Given a warehouse that serves only the five products described below, calculate the cubic feet required for a warehouse. Round up to the nearest 5,000. Assume: 30-day inventory 15 percent buffer for...
-
1. Identify and define the model of interpersonalcommunication. 2. What are the characteristics of interpersonal communication? Identify and define. 3. Identify, and define, the following skills:...
-
A hiker walks 29 km from her base camp at 38 south of west. The next day, he walks 40 km in a direction of 68 east of north and discovers a ranger's house. Find the magnitude and direction of his...
-
Explain the development of slavery in North America. When did slavery become widely used in the British colonies? How did the institution of slavery vary across the colonies and how did it differ...
-
Compare California's government to the U . S . government in two of the following aspects: executive branch, legislative branch, judicial branch, constitutional amendment process.
-
A coworker is preparing a presentation for an organization's various stakeholders and asks for your advice. Use a company of your own choice. Answer the following questions in detailed. Question 1:...
-
If the current as shown in the waveform below, is passed through 2 resistor, the average power absorbed (over one cycle) by the resistor is ? a) 0 W b) 12.5 W c) 16.3 W d) 50 W e) 133.3 W i(1)...
-
What is taxable income, and what is the formula for determining taxable income?
-
Consider an event that will either occur or not. For example, the event might be that California will experience a major earthquake in the next five years. You let p be the probability that the event...
-
What is the relationship between transportation models and more general logistics models? Explain how these two types of linear optimization models are similar and how they are different.
-
In the RedBrand example, suppose the plants cannot ship to each other and the customers cannot ship to each other. Modify the model appropriately, and rerun Solver. How much does the total cost...
-
What are the main components of corporate directional strategies?
-
Define concept growth. What does this mean to entrepreneurial firms?
-
Discuss the significance of discounting in business decision making.
Study smarter with the SolutionInn App