2. Write a program that changes some number in a list to something different. Make sure...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. Write a program that changes some number in a list to something different. Make sure your output is as shown below, note the blank line in between the two lists. a. Create a list of 10 positive random integers between 1 and 100 (including 1 and 100) using the Python random module. Print the list. Define a function called tik_tok that takes a list as input and returns a new list. The function creates a new list from the input list with the following rules and returns the new list: those divisible by 2 and 3 with the string 'TikTok'; those only divisible by 2 with the string 'Tik' those only divisible by 3 with the string 'Tok' • rest of the numbers stay the same i.e. are unchanged. b. c. d. Print the new list. Below is an image of what the program output should look like. Original List: [42, 3, 53, 6, 77, 51, 43, 44, 58, 80] TikTok List: ['TikTok', 'Tok', 53, 'TikTok' 77, 'Tok', 43, 'Tik', 'Tik', 'Tik'] 2. Write a program that changes some number in a list to something different. Make sure your output is as shown below, note the blank line in between the two lists. a. Create a list of 10 positive random integers between 1 and 100 (including 1 and 100) using the Python random module. Print the list. Define a function called tik_tok that takes a list as input and returns a new list. The function creates a new list from the input list with the following rules and returns the new list: those divisible by 2 and 3 with the string 'TikTok'; those only divisible by 2 with the string 'Tik' those only divisible by 3 with the string 'Tok' • rest of the numbers stay the same i.e. are unchanged. b. c. d. Print the new list. Below is an image of what the program output should look like. Original List: [42, 3, 53, 6, 77, 51, 43, 44, 58, 80] TikTok List: ['TikTok', 'Tok', 53, 'TikTok' 77, 'Tok', 43, 'Tik', 'Tik', 'Tik']
Expert Answer:
Answer rating: 100% (QA)
Python import random def tiktoklist1 Function to change some numbers in a list to TikTok Tok or Tik depending on their divisibility by 2 and 3 Args li... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
Use the test of your choice to determine whether the following series converge. + + +
-
What is the speed of an electron just before it hits a television screen after accelerated rest by the 25,000V of the picture tube?
-
Crabapple Catering has just received its April bank statement from Example Bank. You gather the following information to prepare the April 30, 2015, bank reconciliation. APRIL BANK STATEMENT: CASH...
-
Daphne Brown-Wright worked as a teacher for East St. Louis School District 189 from 1975 until 1998 and then returned as an administrator from 2002 until 2012, thus serving the District for 33...
-
Crop-Quick Inc. replenishes its three distribution centers in Boston, Denver and Houston from its Las Vegas central supply warehouse. The distribution schedule for one of its products for the next...
-
What is the output of this code? x=3 num = 17 print(num %x)
-
Amherst Networking Systems adjusts and closes its books and then prepares financial statements monthly. Amherst uses the perpetual inventory system and all sales on credit have terms of n/30. The...
-
A Carnot cycle operating between 600 C and 25 C absorbs 1000 kJ of heat from the high temperature reservoir. The work produced is used to power another Carnot cycle which transfers 1000 kJ of heat...
-
MTT Custom Classics uses a job costing system. Overhead is applied on the basis of direct material cost. The overhead rate used is 200% of direct labor cost. The following is an incomplete Cost of...
-
John works for a toy company, over the past 3 years the company's ABC tablet has been increasing in profits annually. What type of BCG Business portfolio would the tablet be considered ?
-
Based on the following code, what is the value of y if x = 5? int x, y; if (x < 4) y = 2; else if (x 4) { if (x > 7) y = 4; else } else y = 6; y = 8;
-
An instrument with maturity period of 15 years was held by Mr. Taylor (a non-resident citizen) for 3 years and transferred to Mr. Edward (a resident alien). Mr. Edward held It for 2 years before...
-
Please answer each question in detail and in bullet point 1. When Juan Gomez purchased an insurance policy on his life, he named his wife Lois as the beneficiary. Juan and Lois divorced several years...
-
The test statistics: Z-3.49 Decision: Reject the null hypothesis -2 n 2 Make sure you level the CV and don't forget to shade the area of the region! Conclusion about the claim: At 3 N significant...
-
How has the globalization of firms affected the diversity of their employees? Why has increased diversity put an additional burden on accounting systems?
-
In 2012, Lou has a salary of $54,000 from her job. She also has interest income of $1,700. Lou is single and has no dependents. During the year, Lou sold silver coins held as an investment for a...
-
Emily Jackson (Social Security number 765-12-4326) and James Stewart (Social Security number 466-74-9932) are partners in a partnership that owns and operates a barber shop. The partnership's first...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1 and 2. On September 1, Irene opened a retail store that specializes in sports car...
-
Show that the group \(D_{3}\) has two 1D irreps in addition to the 2D irrep found in Problem 5.6 , and construct the character table. Derive the two-dimensional matrix representation Data from...
-
Show that the groups \(C_{3 v}\) and \(D_{3}\) have equivalent characters, but the basis functions corresponding to their irreps are different.
-
The matrix representation of \(\mathrm{C}_{3 \mathrm{v}}\) given in Eq. (5.14) was constructed with respect to the particular coordinate system defined by the unit vectors \(\boldsymbol{e}_{1}\) and...
Study smarter with the SolutionInn App