Complete the following function according to its docstring. Use a for loop. The lists we test...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Complete the following function according to its docstring. Use a for loop. The lists we test will not all be shown; instead, some will be described in English. If you fail any test cases, you will need to read the description and make your own test. 1 def first_even (items: list[int]) -> int: 2 """Return the first even number from items. Return -1 if items contains no even numbers. 4 5 6 8 >>> first_even ([5, 8, 3, 2]) 8 >>> first_even([7, 1]) -1 11 Complete the following function according to its docstring. Note: this function should return None. Its job is to modify the list passed as its argument. 1 def swap_name(name_list: list[str]) -> None: 2 3 4 5 6 7 8 9 10 11 12 13 """name_list contains a single person's name. Modify name_list so that the first name and last name are swapped. >>> name= ['John', 'Smith'] >>> swap_name (name) >>> name ['smith', 'John'] >>> name = ['John', 'Andrew', 'Gleeson', 'Smith'] >>> swap_name (name) >>> name ['Smith', 'Andrew', 'Gleeson', 'John'] ****** Complete the following function according to its docstring. Use a for loop. The lists we test will not all be shown; instead, some will be described in English. If you fail any test cases, you will need to read the description and make your own test. 1 def first_even (items: list[int]) -> int: 2 """Return the first even number from items. Return -1 if items contains no even numbers. 4 5 6 8 >>> first_even ([5, 8, 3, 2]) 8 >>> first_even([7, 1]) -1 11 Complete the following function according to its docstring. Note: this function should return None. Its job is to modify the list passed as its argument. 1 def swap_name(name_list: list[str]) -> None: 2 3 4 5 6 7 8 9 10 11 12 13 """name_list contains a single person's name. Modify name_list so that the first name and last name are swapped. >>> name= ['John', 'Smith'] >>> swap_name (name) >>> name ['smith', 'John'] >>> name = ['John', 'Andrew', 'Gleeson', 'Smith'] >>> swap_name (name) >>> name ['Smith', 'Andrew', 'Gleeson', 'John'] ******
Expert Answer:
Answer rating: 100% (QA)
1 firsteven function Python def firstevenitems listint int Return th... View the full answer
Related Book For
Smith and Roberson Business Law
ISBN: 978-0538473637
15th Edition
Authors: Richard A. Mann, Barry S. Roberts
Posted Date:
Students also viewed these programming questions
-
Factorize the following expressions: a. 25ab-10ab+1 b. +2-120 c. 120-66x+3x
-
Find x from the following equations. a. 9 (x-1)-5(3x+4)-1=0 b. x 1(2x+3)=7x 23 3 (2+3) =7_145
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
Our thoughts return to Ambrose and his nuts and berries. Ambroses utility function is U(x1, x2) = 4x1 + x2, where x1 is his consumption of nuts and x2 is his consumption of berries. (a) Let us find...
-
Phil and Linda are 25-year-old newlyweds and file a joint tax return. Linda is covered by a retirement plan at work, but Phil is not. a. Assuming Phil's wages were $27,000 and Linda's wages were...
-
Use the graph to answer the following questions. a. If the government takes no policy actions, what will be the values of real GDP and the price level in 2019? b. What actions can the government take...
-
After an intense period of negotiation, Global Enterprises Corporation TA 2, 3 agreed to purchase all of the outstanding common shares of The Carlton Corporation. The agreed-upon price was \($294\)...
-
NET Suppose you wanted to test the effect of three different e-mail requests inviting people to participate in a survey posted on the Internet. One simply contained a hyperlink with no explanation,...
-
How to write the Data Analysis of my research project topic " EXPLORING THE ECONOMIC IMPACT OF SUPPLY CHAIN DISRUPTIONS IN AUTOMOTIVE INDUSTRIES IN THE UK" : using ONLY secondary data, so with data...
-
For each item listed in the table below, input the balance for the date range 10/1/20XX to 12/1/20XX. For the Journal, input the balance for the date range 11/13/20XX to 12/1/20XX. Note: Enter your...
-
Let us consider again the university admission process for international students described in Exercise 1.1 (page 5). The owner of this process is the Head of the Admissions Office, who reports to...
-
Do you think that Keynes ideas still have some relevance today? Explain.
-
What are time-series data? Give three examples of key macroeconomic variables that are examples of time-series data.
-
Assume that a period of deflation leads to a rise in the supply of real money balances. Explain the effect of this change on the economy using the ISLM model and then what effect it would have on AD...
-
Distinguish between planned expenditure and actual expenditure.
-
What does the IS curve show? What does the LM curve show?
-
1. Under traditional common law, in accepting an offer, may an offeree requestadditional terms? 2. What differences does the UCC make to the common law "mirror image" rule?
-
(a) Given a mean free path = 0.4 nm and a mean speed vav = 1.17 105 m/s for the current flow in copper at a temperature of 300 K, calculate the classical value for the resistivity of copper. (b)...
-
In payment of the purchase price of a used motorboat that had been fraudulently misrepresented, Young signed and delivered to Armstrong his negotiable note in the amount of $2,000 due October 1, with...
-
Howard Harrison, a longtime customer of Western Bank, operates a small department store, Harrisons Store. Because his store has few experienced employees, Harrison frequently travels throughout the...
-
Testator gives property to Tim in trust for Barneys benefit, providing that Barney cannot anticipate the income by assignment or pledge. Barney borrows money from Linda, assigning his future income...
-
What are two inherent limitations of financial statement data?
-
Quick Ratio Calculate the company's quick ratio for 2019 and compare the result to the industry average. Use the following financial data for Brenner Instruments Sales revenue.. Cost of goods sold...
-
Accounts Receivable Turnover Calculate the company's accounts receivable turnover for 2019 and compare the result to the industry average. Use the following financial data for Brenner Instruments...
Study smarter with the SolutionInn App