Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2. Write a program that changes some number in a list to something different. Make sure your output is as shown below, note the
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']
Step by Step Solution
★★★★★
3.40 Rating (144 Votes )
There are 3 Steps involved in it
Step: 1
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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started