Font size
WorksheetsCSE 102 Exam 2 Practice
Total questions: 15
Worksheet time: 10mins
Which of the following methods is used to add an element to the end of a list in Python? (And only to the end of the list)
list.insert()
`list.append()`
`list.add()`
`list.extend()`
What will be the output of the code snippet?
Hello
World
World!
, Worl
How many times will i be printed?
4 times
5 times
6 times
0 times
Which option below converts the while loop to a for loop?
Which of the following is true about nested loops?
Only for loops can be nested.
Only while loops can be nested.
Both for and while loops can be nested.
Nested loops are not allowed in Python.
What is the output of the code?
0:1
0:2
0:3
1:1
1:2
1:3
1:0
1:1
2:0
2:1
1:0
1:1
1:2
2:0
2:1
2:2
3:0
3:1
3:2
0:1
1:1
0:2
1:2
Which loop is more suitable for iterating over a list when the number of iterations is known?
for loop
while loop
do-while loop
foreach loop
Which loop is better situated for an unknown number of iterations?
While
For
What will be the output of the code?
[2,4,6,8,10]
[1,1,2,2,3,3,4,4,5,5]
[1,2,3,4,5]
[1,2,3,4,5,1,2,3,4,5]
Which of the following is a valid way to create a list in Python? Select all that apply.
myList = list()
list = {}
myList = []
myList = <>
What will be the output of the code?
PYTHON
python
Python
pYTHON
Which of the following is not a valid string operation in Python?
Concatenation
Slicing
Multiplication
Division
What is the first line of output if the user types "PyThon" after the initial input prompt?
Welcome
Try again!
Error
Enter your password
Given the list of lists, how would you access the number 3?
myList = [[1, 2], [3, 4], [5, 6]]
myList[[2]]
myList[1,0]
myList[1][0]
myList[2][1]
What is the output from the code?
230.4480 is a floating point value.
230.448 is a floating point value.
230.450 is a floating point value
0230.448 is a floating point value.
