Quiz 01
Quiz 01
A) 55 B) 10
C) Error D) ”55”
2. How do you append an element to a list in Python?
A) list.add(item) B) list.append(item)
C) list.insert(item) D) list.push(item)
3. What is the correct syntax for an if-else statement in Python?
A) if x == 5 then: print("Yes") else: print("No") B) if (x == 5) { print("Yes");
C) if x == 5: print("Yes") else: print("No") D) if x == 5: print("Yes") \\
4. What will the following code output?
numbers = [ 1 , 2 , 3 , 4 ]
numbers . pop ( )
print ( numbers )
A) [1, 2, 3] B) [1, 2, 3, 4]
C) [1, 2, 4] D) Error
5. How many times will the following loop run?
f o r i in range ( 2 , 1 0 , 2 ) :
print ( i )
A) 3 B) 4
C) 5 D) 8