Introductory Python Assignment: List Operations and Output

Verified

Added on  2022/09/05

|36
|5744
|27
Homework Assignment
AI Summary
This assignment is a comprehensive exercise in Python list manipulation. It presents a series of code blocks involving the `list()` function, list creation, and various list operations such as accessing elements, slicing, appending, extending, inserting, and removing elements. For each code block, the student is required to select the appropriate output from a multiple-choice selection and describe the action being executed by the code. The assignment covers a wide range of list operations, including converting strings, tuples, and other data structures to lists, determining the length of lists, and modifying lists through various methods. The student is also expected to understand the effects of different list slicing techniques and element access. Finally, the student is required to upload the completed python script file.
Document Page
Walk through the exercises in the attached pdf, select the appropriate answer, describe
the action and upload the completed python script file
Select the appropriate output after running the following code block:
list ("abc")
Group of answer choices
abc
"abc"
['a', 'b', 'c']
a,b,c
Question 21 pts
Describe the action being executed by the former code block:
list() will take each character of “abc” and make a list.
Question 31 pts
Select the appropriate output after running the following code block:
list ((1,2,3))
Group of answer choices
1, 2, 3
(1,2,3)
123
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
[1, 2, 3]
Question 41 pts
Describe the action being executed by the former code block:
list() take each element and make a list
Question 51 pts
Select the appropriate output after running the following code block:
list([1,3,5,7,9])
Group of answer choices
1, 3, 5, 7, 9
[1, 3, 5, 7, 9]
13579
(1, 3, 5, 7, 9)
Question 61 pts
Describe the action being executed by the former code block:
list() take each element and make a list.
Flag this Question
Question 71 pts
Select the appropriate output after running the following code block:
empty_list = []
print(len(empty_list))
Group of answer choices
0
15
Document Page
empty_list
len(empty_list)
Question 81 pts
Describe the action being executed by the former code block:
Because the list is empty, size is 0
Question 91 pts
Select the appropriate output after running the following code block:
another_empty_list=list ()
print(len(another_empty_list))
Group of answer choices
24
len(another_empty_list)
0
another_empty_list
Question 101 pts
Describe the action being executed by the former code block:
Because the list doesn’t contain any element
Question 111 pts
Select the appropriate output after running the following code block:
list("house")
Group of answer choices
house
h,o,u,s,e
['h', 'o', 'u', 's', 'e']
Document Page
'h', 'o', 'u', 's', 'e'
Question 121 pts
Describe the action being executed by the former code block:
list() function will take each character of “house” and make a list.
Question 131 pts
Select the appropriate output after running the following code block:
list("This word")
Group of answer choices
This word
'T', 'h', 'i', 's', ' ', 'w', 'o', 'r', 'd'
['T', 'h', 'i', 's', ' ', 'w', 'o', 'r', 'd']
T,h,i,s , W,o,r,d
Question 141 pts
Describe the action being executed by the former code block:
list() will take each character of “this word” and make a list including space.
Question 151 pts
Select the appropriate output after running the following code block:
aTuple =('ready','fire','aim')
list(aTuple)
Group of answer choices
[ready, fire, aim]
'ready', 'fire', 'aim'
('ready', 'fire', 'aim')
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
['ready', 'fire', 'aim']
Question 161 pts
Describe the action being executed by the former code block:
list() converted the tuple into list.
Question 171 pts
Select the appropriate output after running the following code block:
aStringOf= "This is a string of "
aList=aStringOf.split(' ')
print(aList)
Group of answer choices
[This, is, a, string, of, ]
This is a string of
['This', 'is', 'a', 'string', 'of', '']
('This', 'is', 'a', 'string', 'of', '')
Question 181 pts
Describe the action being executed by the former code block:
split() function splits the list where space occurred and converts to list.
Question 191 pts
Select the appropriate output after running the following code block:
aDayString="5/1/2017"
aList=aDayString.split('/')
print(aList)
Group of answer choices
'5', '1', '2017'
Document Page
['5', '1', '2017']
('5', '1', '2017')
"5/1/2017"
Question 201 pts
Describe the action being executed by the former code block:
split() function splits the list where ‘/’ occurred and converts to list.
Question 211 pts
Select the appropriate output after running the following code block:
l_lists=[[1,2,3],[2,3,4],[3,4,5]]
new_llists=[element[1:] for element in l_lists]
i=0
for element in new_llists:
print(element)
i=i+1
if i==3:
break
Group of answer choices
2, 3, 3, 4, 4, 5
(2, 3) (3, 4) (4, 5)
2, 3 3, 4 4, 5
[2, 3] [3, 4] [4, 5]
Question 221 pts
Describe the action being executed by the former code block:
element[1:] means element[1] to element[2]
Document Page
Question 231 pts
Select the appropriate output after running the following code block:
my_list=['p','r','o','b','e']
print(my_list[0])
Group of answer choices
r
b
p
e
Flag this Question
Question 241 pts
Describe the action being executed by the former code block:
HTML EditorKeyboard Shortcuts
p is at 0th location.
Question 251 pts
Select the appropriate output after running the following code block:
my_list=['p','r','o','b','e']
print(my_list[2])
Group of answer choices
o
p
0
e
Question 261 pts
Describe the action being executed by the former code block:
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
o is at my_list[2]
Question 271 pts
Select the appropriate output after running the following code block:
n_list=["Happy",[2,0,1,5]]
print(n_list[0][1])
Group of answer choices
p
a
2
0
Flag this Question
Question 281 pts
Describe the action being executed by the former code block:
HTML EditorKeyboard Shortcuts
Happy” is at 0th location and ‘a’ is at 1st loc.
Flag this Question
Question 291 pts
Select the appropriate output after running the following code block:
n_list=["Happy",[2,0,1,5]]
print(n_list[1][3])
Group of answer choices
y
p
5
Document Page
0
Flag this Question
Question 301 pts
Describe the action being executed by the former code block:
HTML EditorKeyboard Shortcuts
2,0,1,5” is at 1st loc and 5 is at 3rd loc
Flag this Question
Question 311 pts
Select the appropriate output after running the following code block:
aTuple=('ready','fire','aim')
aList=list(aTuple)
print("Length of the list:",len(aList))
Group of answer choices
Length of the list: 20
Length of the list: 12
Length of the list: 3
Length of the list: 0
Flag this Question
Question 321 pts
Describe the action being executed by the former code block:
HTML EditorKeyboard Shortcuts
The list contains 3 elements only.
Flag this Question
Document Page
Question 331 pts
Select the appropriate output after running the following code block:
aTuple=('ready','fire','aim')
aList=list(aTuple)
list_element1=aList[0]
print(list_element1)
Group of answer choices
None of these
ready
fire
aim
Flag this Question
Question 341 pts
Describe the action being executed by the former code block:
HTML EditorKeyboard Shortcuts
The 0th element is ready
Flag this Question
Question 351 pts
Select the appropriate output after running the following code block:
aTuple=('ready','fire','aim')
aList=list(aTuple)
list_element3=aList[2]
print(list_element3)
Group of answer choices
fire
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
None of these
ready
aim
Flag this Question
Question 361 pts
Describe the action being executed by the former code block:
HTML EditorKeyboard Shortcuts
The list[2] = ‘aim’
Flag this Question
Question 371 pts
Select the appropriate output after running the following code block:
languages=["Python","C","C++","Java","Perl"]
print(languages[0]+" and "+languages[1]+" are quite different !")
Group of answer choices
Java and C are quite different !
C++ and C are quite different !
Python and C are quite different !
C and Python are quite different !
Flag this Question
Question 381 pts
Describe the action being executed by the former code block:
HTML EditorKeyboard Shortcuts
0th and 1th location are “python” and “c”
Document Page
Flag this Question
Question 391 pts
Select the appropriate output after running the following code block:
my_list=['p','r','o','g','r','a','m','i','z']
print(my_list[2:5])
Group of answer choices
['r', 'o', 'g', 'r']
[ 'r', 'o', 'g']
['o', 'g', 'r']
['p', 'r', 'o', 'g']
Flag this Question
Question 401 pts
Describe the action being executed by the former code block:
HTML EditorKeyboard Shortcuts
my_list[2:5] means my_list[2] to my_list[4]
Flag this Question
Question 411 pts
Select the appropriate output after running the following code block:
my_list=['p','r','o','g','r','a','m','i','z']
print(my_list[:-5])
Group of answer choices
['r', 'a', 'm', 'i', 'z']
['p', 'r', 'o', 'g', 'r']
chevron_up_icon
1 out of 36
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]