The document contains 30 multiple choice questions about Python programming concepts like data types, variables, operators, control flow, lists, tuples, dictionaries, functions and more. The questions test fundamental Python knowledge like the difference between lists and tuples (tuples are immutable while lists are mutable), valid variable names (my_variable), operators (> for comparison), control flow statements (break, continue, pass), indexing and slicing lists, functions and more.
The document contains 30 multiple choice questions about Python programming concepts like data types, variables, operators, control flow, lists, tuples, dictionaries, functions and more. The questions test fundamental Python knowledge like the difference between lists and tuples (tuples are immutable while lists are mutable), valid variable names (my_variable), operators (> for comparison), control flow statements (break, continue, pass), indexing and slicing lists, functions and more.
The document contains 30 multiple choice questions about Python programming concepts like data types, variables, operators, control flow, lists, tuples, dictionaries, functions and more. The questions test fundamental Python knowledge like the difference between lists and tuples (tuples are immutable while lists are mutable), valid variable names (my_variable), operators (> for comparison), control flow statements (break, continue, pass), indexing and slicing lists, functions and more.
B. A low-level programming language C. A scripting language D. Both A and C
2]What is the output of the following code?
print(5 + "hello") A. 5hello B. TypeError C. SyntaxError D. None of the above
3]Which of the following is a valid Python variable name?
A. my variable B. my_variable C. my-variable D. myvariable
4]What is the value of x after the following code is executed?
x = 3 x += 5 A. 8 B. 3 C. 5 D. 15
5]What is the output of the following code?
print(2 ** 3 ** 2) A. 64 B. 512 C. SyntaxError D. None of the above
6]Which of the following is not a Python data type?
A. List B. Tuple C. Dictionary D. Record
7]What is the output of the following code?
print("hello"[-2]) A. h B. l C. o D. e
8]What is the difference between a list and a tuple in Python?
A. A tuple is immutable while a list is mutable. B. A list is immutable while a tuple is mutable. C. Both are mutable. D. Both are immutable.
9]What is the output of the following code?
x = "hello" y = x.upper() print(y) A. Hello B. HELLO C. hello D. None of the above
10]What is the output of the following code?
x = ["a", "b", "c"] print(x[1:]) A. ["a"] B. ["b", "c"] C. ["a", "b"] D. ["c"]
11]What is the output of the following code?
x = [1, 2, 3] y = [4, 5, 6] z = x + y print(z) A. [1, 2, 3, 4, 5, 6] B. [[1, 2, 3], [4, 5, 6]] C. [5, 7, 9] D. None of the above
12]What is the output of the following code?
x = [1, 2, 3] y = x y[0] = 4 print(x) A. [1, 2, 3] B. [4, 2, 3] C. [4, 1, 2, 3] D. None of the above
13]What is the output of the following code?
for i in range(5): if i == 2: break print(i) A. 0 1 2 B. 0 1 C. 0 1 2 3 4 D. 2 3 4
14]What is the output of the following code?
for i in range(5): if i == 2: continue print(i) A. 0 1 2 B. 0 1 C. 0 1 3 4 D. 2 3 4
15]What is the output of the following code?
for i in range(1, 4): for j in range(1, 4): print(i * j) A. 1 2 3 4 5 6 7 8 9 B. 1 2 3 2 4 6 3 6 9 C. 2 4 6 3 6 9 D. None of the above
16]What is the output of the following code?
i = 1 while i < 5: print(i) i += 1 A. 1 2 3 4 B. 1 2 3 C. 2 3 4 D. None of the above
17]What is the output of the following code?
i = 1 while True: if i == 5: break print(i) i += 1 A. 1 2 3 4 B. 1 2 3 C. 2 3 4 D. None of the above
18]What is the output of the following code?
x = 5 if x > 10: print("x is greater than 10") elif x < 5: print("x is less than 5") else: print("x is between 5 and 10") A. x is greater than 10 B. x is less than 5 C. x is between 5 and 10 D. None of the above
19]What is the output of the following code?
x = 5 if x > 10: print("x is greater than 10") if x < 5: print("x is less than 5") else: print("x is between 5 and 10") A. x is greater than 10 B. x is less than 5 C. x is between 5 and 10 D. None of the above
20]Which of the following is a comparison operator in Python?
A. + B. - C. * D. >
21]Which of the following is the correct way to declare and initialize a variable in Python? A. int x = 5 B. x = 5 C. x := 5 D. Both B and C
22]What is the output of the following code?
x = 10 y = 3 print(x // y) A. 3.3333 B. 3.0 C. 3 D. None of the above
23]What is the output of the following code?
x = 2 y = 3 if x == 2 and y == 3: print("True") else: print("False") A. True B. False C. SyntaxError D. None of the above
24]What is the output of the following code?
x = 2 y = 3 if x == 2 or y == 4: print("True") else: print("False") A. True B. False C. SyntaxError D. None of the above
25]What is the output of the following code?
x = 1 y = 2 if not x == 1: print("True") elif y == 2: print("False") else: print("None") A. True B. False C. None D. SyntaxError
26]What is the output of the following code?
x = [1, 2, 3] for i in x: print(i) A. 1 2 3 B. [1, 2, 3] C. [1], [2], [3] D. None of the above
27]What is the output of the following code?
x = [1, 2, 3] for i in range(len(x)): print(x[i]) A. 1 2 3 B. [1, 2, 3] C. [1], [2], [3] D. None of the above
28]What is the output of the following code?
x = [1, 2, 3] print(x[1]) A. 1 B. 2 C. 3 D. None of the above
29]What is the output of the following code?
x = [1, 2, 3] print(x[-1]) A. 1 B. 2 C. 3 D. None of the above
30]What is the output of the following code?
x = [1, 2, 3] x.append(4) print(x) A. [1, 2, 3, 4] B. [4, 3, 2, 1] C. [1, 2, 3] D. None of the above