GATE 2025 Python Programming MCQs
1. What is the output of the following code snippet?
x = 10
y = 5
print(x % y)
a) 2
b) 0
c) 1
d) 5
Answer: b) 0
2. Which of the following statements is true regarding Python?
a) Python is a compiled language
b) Python is a functional programming language
c) Python is dynamically typed
d) Python code cannot be executed on Windows
Answer: c) Python is dynamically typed
3. What will be the output of the following code snippet?
my_list = [1, 2, 3, 4, 5]
print(my_list[2:4])
a) [1, 2]
b) [2, 3]
c) [3, 4]
d) [4, 5]
Answer: c) [3, 4]
4. Which of the following is not a valid data type in Python?
a) List
b) Tuple
c) Array
d) Dictionary
Answer: c) Array
5. What is the output of the following code snippet?
print("Hello" + 2)
a) Hello2
b) TypeError: can only concatenate str (not "int") to str
c) Hello
d) 2
Answer: b) TypeError: can only concatenate str (not "int") to str
6. What does the len() function do in Python?
a) Returns the length of a string
b) Returns the length of a list
c) Returns the length of a dictionary
d) All of the above
Answer: d) All of the above
7. Which of the following operators is used for exponentiation in Python?
a) **
b) ^
c) //
d) %
Answer: a) **
8. What is the output of the following code snippet?
x = "Hello"
print(x[::-1])
a) Hello
b) olleH
c) ello
d) Syntax Error
Answer: b) olleH
9. In Python, what does the != operator signify?
a) Less than or equal to
b) Not equal to
c) Assignment
d) Less than
Answer: b) Not equal to
10. What will be the output of the following code snippet?
x = [1, 2, 3]
y = x
y.append(4)
print(x)
a) [1, 2, 3]
b) [1, 2, 3, 4]
c) [1, 2, 3, 4, 5]
d) [1, 2, 3, 4, 5, 6]
Answer: b) [1, 2, 3, 4]
11. Which keyword is used to define a function in Python?
a) def
b) function
c) define
d) func
Answer: a) def
12. What is the output of the following code snippet?
print(type(type(int)))
a) int
b) type
c) class 'int'
d) class 'type'
Answer: d) class 'type'
13. Which of the following is not a valid way to comment out multiple lines in Python?
a) Using triple quotes
b) Using the # symbol at the beginning of each line
c) Using /* */
d) Using ''' '''
Answer: c) Using /* */
14. What is the output of the following code snippet?
x = 5
y = 2
print(x // y)
a) 2.5
b) 2
c) 2.0
d) 3
Answer: b) 2
15. In Python, what is the purpose of the continue statement?
a) To exit the loop completely
b) To skip the remaining code inside the loop and jump to the next iteration
c) To pause the execution of the loop
d) To restart the loop
Answer: b) To skip the remaining code inside the loop and jump to the next iteration
16. What does the init function do in Python?
a) Initializes a new Python object
b) Initializes a database connection
c) Initializes a loop
d) Initializes a variable
Answer: a) Initializes a new Python object
17. Which of the following is used to create an empty set in Python?
a) {}
b) ()
c) []
d) None of the above
Answer: d) None of the above
18. What will be the output of the following code snippet?
x = 10
if x > 5:
print("x is greater than 5")
elif x < 5:
print("x is less than 5")
else:
print("x is equal to 5")
a) x is greater than 5
b) x is less than 5
c) x is equal to 5
d) No output
Answer: a) x is greater than 5
19. What is the output of the following code snippet?
x = "hello"
print(x.upper())
a) hello
b) HELLO
c) Hello
d) hElLo
Answer: b) HELLO
20. Which of the following statements is true regarding Python's list?
a) Lists are immutable
b) Lists are ordered collections of items
c) Lists can only store integers
d) Lists cannot be nested
Answer: b) Lists are ordered collections of items
21. What is the output of the following code snippet?
print(2 3 * 3 * 4)
a) 216
b) 72
c) 24
d) 144
Answer: a) 216
22. In Python, what does the is keyword do?
a) Checks if two variables have the same value
b) Checks if two variables refer to the same object in memory
c) Checks if a variable is defined
d) Checks if a variable is empty
Answer: b) Checks if two variables refer to the same object in memory
23. What will be the output of the following code snippet?
x = 5
print(type(x))
a) str
b) int
c) float
d) bool
Answer: b) int
24. What is the output of the following code snippet?
x = [1, 2, 3]
x.remove(2)
print(x)
a) [1, 2]
b) [2, 3]
c) [1, 3]
d) [1, 2, 3]
Answer: c) [1, 3]
25. Which function is used to read a line from standard input in Python?
a) read()
b) readline()
c) input()
d) stdin()
Answer: b) readline()
26. What is the output of the following code snippet?
x = "python"
print(x[1:4])
a) pyt
b) yth
c) pyt
d) thon
Answer: b) yth
27. Which of the following is not a valid method of a list object in Python?
a) append()
b) insert()
c) add()
d) remove()
Answer: c) add()
28. What will be the output of the following code snippet?
x = 2.5
print(int(x))
a) 2.5
b) 2
c) 3
d) 2.0
Answer: b) 2
29. In Python, what is the purpose of the pass statement?
a) To end the execution of a loop
b) To skip a block of code without raising an error
c) To execute a block of code repeatedly
d) To print a message to the console
Answer: b) To skip a block of code without raising an error
30. What is the output of the following code snippet?
x = [1, 2, 3]
y = x
y[0] = 5
print(x)
a) [1, 2, 3]
b) [5, 2, 3]
c) [1, 2, 5]
d) [5, 2, 5]
Answer: b) [5, 2, 3]