Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python question a [2] creates a list (refer to by variable a) with one element, a number 2 in this case. b= [None] creates a
Python question
a [2] creates a list (refer to by variable a) with one element, a number 2 in this case. b= [None] creates a list with one element. That element is an object of type None. That is sometimes useful when we are not ready yet to assign a value to an element of a list. c-[] creates an empty list, i.e. a list of length zero Recall further that multiplying a list by an integer n, creates a new list that repeats the given list n times. Or that applying '+' operator to two lists creates a new lists that concatenates the given two lists. For example: [1,2]+[10,20,0] creates a list [1,2,10,20, 0] [7,2]*3 creates a list [7,2,7,2,7, Finally, recall the slicing. For example, if a-12,3,4,1], a: returns a new list that is a copy of list a. Open the file called creating_various_lists.py. The first line is given to you. It asks the user to enter a positive even integer n. For each green programing exercise below, try to find at least two solutions (e.g. one by using a loop with accumulator pattern and another by using int*list). 1.Create a list a (i.e a list referred to by variable a) of length n filled with zeros 2.Create a list b of length n filled with random integers between 1 and 100 3.Create a variable c that is an alias of b 4.Set first half of the elements of c to zero, and then print both b and c 5Copy list b into a list d 6.Create a new list e that has every 2nd element of bStep by Step Solution
There are 3 Steps involved in it
Step: 1
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