Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 4 7 pts Assume a list object called myList has been created that contains the following elements ['cherry', 'apple, cherry', orange']. Match Python expressions
Question 4 7 pts Assume a list object called myList has been created that contains the following elements ['cherry', 'apple, cherry', orange']. Match Python expressions with the resulting values - consider each statement in relation to the original contents of myList, namely ['cherry' apple,'cherry', 'orange'] myList.append('cherry') [ Choose ] myList.index'cherry) [ Choose ] myList.remove'cherry') [ Choose ] myList.insert1, 'orangeChoose] myList.sort( Choose ] Choose ] Choose ] myList.reverse del myList[2] Question 5 4 pts Which of the following statements about Program 7-9 (average_list.py) S TRUE? (check all that apply) for value in scores: is a loop that iterates over all list elements During the third repetition of the for loop, value becomes 6.5 total is an example of an accumulator variable that accumulates the sum of all the values in scores During the second repetition of the for loop, total becomes 7.3 During the first repetition of the for loop, value becomes 7.3 During the third repetition of the for loop, total becomes 16.3 Question3 4 pts Given the programming fragment below, which of the following statements are TRUE? (Check all that apply) for variable in [4, Alice, -2.34]: print variable, variable, variable) Overall, the loop repeats three times. We say that the loop iterates over the elements in a list containing 4 Alice-2.34 Second time through the loop, variable contains a copy of a letter 'A The program will print: 4 Alice -2.34 4 Alice -2.34 4 Alice -2.34 variable is a name of a variable that on each loop iteration holds a copy of a different element contained in [4, Alice, -2.34] The first time the loop executes, variable contains a copy of number 4 Question 1 4 pts Which of the following statements about lists are TRUE? Check all that apply List elements could be of different types. In a maer similar to strings, Python supports list repetition, concatenation, and slicing. Unlike strings, lists are mutable and their elements can be added and removed during the program execution. Unlike strings, list elements cannot be accessed using their position/ index. List elements appear within curly braces and are delimited with a comma, e.g. [1,2, 3 A list may contain mutliple data items. Question 2 6 pts Match corresponding statements, given the following Python cdeiiritieo: numbers [1, 2, 3,4, 5] print(numbers[1]) displays index of the last element is numbers(O]-5 results in[Chs numbers list containing I Choose ] len(numbers) I Choose ] s-51 4 results in nums [Choose ] ist containing printl numbersl 4:]) displays Choose ]
Step 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