1–20: BASICS OF PYTHON
1. What type of language is Python?
a) Low-level
b) Machine
c) High-level
d) Assembly
2. Who developed Python?
a) Dennis Ritchie
b) James Gosling
c) Guido van Rossum
d) Bjarne Stroustrup
3. Python was first released in:
a) 1989
b) 1991
c) 2000
d) 2010
4. Which symbol is used for comments?
a) //
b) /* */
c) #
d) –
5. Which of the following is a valid variable name?
a) 1name
b) name1
c) name-1
d) @name
6. Python is:
a) Compiled only
b) Interpreted
c) Assembly
d) None
7. File extension of Python file:
a) .java
b) .cpp
c) .py
d) .exe
8. Which function prints output?
a) input()
b) print()
c) display()
d) write()
9. Which function takes input?
a) print()
b) input()
c) read()
d) get()
10. Python is case:
a) Not sensitive
b) Case-sensitive
c) Both
d) None
11. Which keyword defines a function?
a) func
b) define
c) def
d) function
12. Which operator is used for addition?
a) *
b) –
c) +
d) /
13. Which is used to end a statement?
a) ;
b) :
c) .
d) (none required)
14. Which of these is not a keyword?
a) if
b) else
c) then
d) while
15. Python supports:
a) OOP
b) Functional programming
c) Procedural
d) All of the above
16. Which bracket is used for list?
a) ( )
b) { }
c) [ ]
d) < >
17. Which bracket is used for tuple?
a) [ ]
b) { }
c) ( )
d) < >
18. Which bracket is used for dictionary?
a) [ ]
b) ( )
c) { }
d) < >
19. Python is:
a) Paid
b) Free and open-source
c) Licensed only
d) None
20. Which is correct print syntax?
a) print “Hello”
b) print(“Hello”)
c) echo(“Hello”)
d) display(“Hello”)
________________________________________
21–40: DATA TYPES & VARIABLES
21. Which is an integer?
a) 3.14
b) 10
c) “10”
d) True
22. Which is a float?
a) 3.5
b) 5
c) “3.5”
d) None
23. Which is a string?
a) 10
b) “Hello”
c) 3.5
d) True
24. Boolean values are:
a) 0,1
b) Yes, No
c) True, False
d) On, Off
25. Type of “5”:
a) int
b) float
c) str
d) bool
26. Type of 5.0:
a) int
b) float
c) str
d) bool
27. Which converts to integer?
a) str ()
b) int( )
c) float( )
d) bool( )
28. Which converts to string?
a) int( )
b) str( )
c) float( )
d) bool( )
29. Which converts to float?
a) int( )
b) str( )
c) float( )
d) bool( )
30. Which is mutable?
a) tuple
b) string
c) list
d) int
31. Which is immutable?
a) list
b) tuple
c) dictionary
d) set
32. Which symbol assigns value?
a) ==
b) =
c) :=
d) !=
33. Which checks equality?
a) =
b) ==
c) !=
d) <=
34. Which operator means “not equal”?
a) ==
b) !=
c) =
d) <>
35. Which is logical AND?
a) or
b) not
c) and
d) xor
36. Which is logical OR?
a) and
b) not
c) or
d) xor
37. Which is logical NOT?
a) and
b) not
c) or
d) xor
38. Which is a valid boolean?
a) true
b) false
c) True
d) yes
39. What is type(10)?
a) str
b) float
c) int
d) bool
40. What is type(“abc”)?
a) int
b) str
c) float
d) bool
________________________________________
41–60: CONTROL STRUCTURES
41. Which is a decision statement?
a) for
b) while
c) if
d) def
42. Syntax of if statement ends with:
a) ;
b) :
c) .
d) ,
43. Which is loop?
a) if
b) else
c) for
d) def
44. Which loop runs while condition is true?
a) for
b) while
c) if
d) else
45. Which keyword handles false condition?
a) if
b) else
c) for
d) while
46. Which allows multiple conditions?
a) if
b) else
c) elif
d) for
47. Which breaks loop?
a) continue
b) pass
c) break
d) stop
48. Which skips iteration?
a) break
b) stop
c) continue
d) exit
49. Which does nothing?
a) break
b) continue
c) pass
d) stop
50. Range function is used in:
a) if
b) while
c) for
d) def
51. range(5) gives:
a) 1–5
b) 0–4
c) 0–5
d) 1–4
52. Infinite loop example:
a) for i in range(5)
b) while True
c) if True
d) def loop
53. Nested loop means:
a) multiple loops
b) loop inside loop
c) single loop
d) no loop
54. Indentation is:
a) optional
b) required
c) ignored
d) error
55. Python uses indentation for:
a) decoration
b) block of code
c) printing
d) comments
56. Which is correct?
a) if x=5
b) if x==5:
c) if(x=5)
d) if x==5
57. else is used with:
a) loop
b) if
c) function
d) variable
58. elif means:
a) ease if
b) else if
c) end if
d) none
59. Loop variable changes automatically in:
a) while
b) for
c) if
d) def
60. Condition must return:
a) number
b) string
c) boolean
d) list
________________________________________
61–80: FUNCTIONS & LISTS
61. Function is defined using:
a) function
b) define
c) def
d) fun
62. Function returns value using:
a) print
b) return
c) output
d) break
63. Parameter is:
a) output
b) input to function
c) variable
d) loop
64. Argument is:
a) definition
b) value passed
c) function
d) loop
65. len( ) gives:
a) type
b) length
c) value
d) index
66. list.append( ) does:
a) delete
b) add element
c) sort
d) reverse
67. list.remove( ) does:
a) add
b) sort
c) remove element
d) copy
68. list.sort() does:
a) reverse
b) sort list
c) delete
d) append
69. Index starts from:
a) 1
b) 0
c) -1
d) 2
70. Last index is:
a) 0
b) -1
c) 1
d) n
71. List is:
a) immutable
b) mutable
c) fixed
d) none
72. Tuple is:
a) mutable
b) immutable
c) changeable
d) list
73. Dictionary stores:
a) values only
b) keys only
c) key-value pairs
d) numbers
74. Access dictionary value using:
a) ( )
b) { }
c) [ ]
d) < >
75. Example of list:
a) (1,2)
b) {1,2}
c) [1,2]
d) <1,2>
76. Example of tuple:
a) [1,2]
b) (1,2)
c) {1,2}
d) <1,2>
77. Example of dictionary:
a) [1,2]
b) (1,2)
c) {“a”:1}
d) <1,2>
78. Which is built-in function?
a) user
b) custom
c) predefined
d) none
79. Recursive function means:
a) loop
b) function calling itself
c) error
d) condition
80. Lambda is:
a) loop
b) anonymous function
c) variable
d) list
________________________________________
81–100: MISCELLANEOUS
81. Python supports OOP?
a) No
b) Yes
c) Partial
d) None
82. Class is:
a) function
b) variable
c) blueprint
d) loop
83. Object is:
a) class
b) instance of class
c) loop
d) variable
84. init is:
a) destructor
b) constructor
c) loop
d) function
85. Inheritance means:
a) copying
b) reusing class
c) deleting
d) none
86. File open mode “r” means:
a) write
b) append
c) read
d) create
87. File open mode “w” means:
a) read
b) write
c) append
d) close
88. File open mode “a” means:
a) read
b) write
c) append
d) close
89. close( ) does:
a) open file
b) read file
c) close file
d) delete
90. read( ) does:
a) write
b) append
c) read file
d) close
91. write( ) does:
a) read
b) write file
c) append
d) close
92. Exception handling uses:
a) if
b) loop
c) try
d) def
93. Catch block uses:
a) try
b) except
c) finally
d) error
94. finally block:
a) skip
b) error
c) always executes
d) none
95. Syntax error is:
a) runtime
b) compile-time
c) logical
d) none
96. Runtime error occurs:
a) before run
b) during execution
c) after run
d) none
97. Logical error is:
a) syntax
b) runtime
c) wrong logic
d) none
98. Python keyword list is available via:
a) help( )
b) keyword module
c) list( )
d) dir( )
99. IDLE stands for:
a) Integrated Device
b) Integrated Development Environment
c) Input Device
d) None
100. Python is popular because:
a) difficult
b) slow
c) easy to learn
d) none