Python
1. An algorithm is defined as:
A. A computer program
B. A step-by-step procedure to solve a problem
C. A flow chart
D. A programming language
2. Which of the following is a building block of an algorithm?
A. Statements
B. State
C. Control Flow
D. All of the above
3. Pseudocode is:
A. Written in Python
B. A graphical representation
C. A structured English description of an algorithm
D. Machine code
4. A flowchart uses which shape for decision-making?
A. Rectangle
B. Parallelogram
C. Diamond
D. Circle
5. Iteration means:
A. Repeating a set of instructions
B. Making a decision
C. Calling a function
D. None of the above
6. Recursion is:
A. A loop inside a loop
B. A function calling itself
C. Using multiple functions
D. A type of variable
7. The "state" of a program refers to:
A. Current line number
B. Values of all variables at a given time
C. Memory capacity
D. Operating system
8. Which of the following is NOT a characteristic of a good algorithm?
A. Input
B. Output
C. Infinite steps
D. Definiteness
9. Flowcharts represent algorithms using:
A. Text
B. Symbols and arrows
C. Code
D. Variables
10. In pseudocode, BEGIN and END indicate:
A. Values
B. Program boundaries
C. Control flow
D. Comments
11. Python is:
A. Compiled
B. Interpreted
C. Machine language
D. Both compiled and interpreted
12. In Python, the output of type(10.5) is:
A. int
B. float
C. double
D. long
13. A Boolean type in Python has how many values?
A. 1
B. 2
C. 3
D. 4
14. Which of the following is a valid variable name?
A. 1value
B. value_1
C. value-1
D. value 1
15. Which operator has the highest precedence?
A. +
B. *
C. ()
D. =
16. What is a tuple assignment?
A. Assigning values to multiple variables at once
B. Creating a list
C. Creating a dictionary
D. Calling a function
17. Which of the following is NOT a data type?
A. int
B. float
C. char
D. list
18. Comments in Python begin with:
A. //
B. #
C. /* */
D. $$
19. A module in Python is:
A. A variable
B. A function
C. A file containing Python definitions
D. A loop
20. The function to read user input is:
A. read()
B. input()
C. scan()
D. get()
21. A Boolean operator in Python is:
A. plus
B. minus
C. and
D. equal
22. if-else is an example of:
A. Iteration
B. Recursion
C. Conditional
D. Assignment
23. A chained conditional uses:
A. if
B. if-else
C. if-elif-else
D. switch
24. Which loop repeats until a condition becomes false?
A. for
B. while
C. do-while
D. repeat-until
25. continue statement does what?
A. Stops the loop
B. Skips to next iteration
C. Terminates program
D. Returns a value
26. break statement:
A. Ends the loop
B. Restarts loop
C. Ends program
D. Continues loop
27. A fruitful function is one that:
A. Does not return value
B. Returns a value
C. Has no parameters
D. Uses local variables only
28. Local variables are created:
A. Inside a function
B. Outside a function
C. In loops
D. In dictionaries
29. A global variable is declared using:
A. universal keyword
B. public keyword
C. global keyword
D. def keyword
30. String slicing uses:
A. ()
B. {}
C. []
D. <>
31. Strings in Python are:
A. Mutable
B. Immutable
C. Sometimes mutable
D. Based on list
32. Which method returns string length?
A. length()
B. size()
C. len()
D. str_len()
33. The string module provides:
A. Arithmetic operations
B. Utility functions
C. Looping
D. File handling
34. Lists in Python act like:
A. Arrays
B. Operators
C. Loops
D. Modules
35. Which operator is used for string concatenation?
A. *
B. +
C. -
D. /
36. Lists are:
A. Immutable
B. Mutable
C. Immutable sometimes
D. Static only
37. A list slice looks like:
A. list{1:3}
B. list(1,3)
C. list[1:3]
D. list<1,3>
38. [Link](x) does what?
A. Deletes x
B. Adds x to end
C. Inserts x at beginning
D. Removes x
39. Which is a list method?
A. push()
B. add()
C. insert()
D. append_all()
40. Aliasing means:
A. Making a copy
B. Two variables refer to same list
C. Creating a tuple
D. Converting list to string
41. Cloning a list uses:
A. clone()
B. [Link]()
C. [Link]()
D. recreate()
42. Tuples are:
A. Mutable
B. Immutable
C. Changeable
D. Dynamic
43. Tuple assignment is used for:
A. Multi-variable assignment
B. Sorting
C. Loops
D. File writing
44. A dictionary stores data as:
A. Values only
B. Keys only
C. Key-value pairs
D. Lists
45. [Link]() returns:
A. Values
B. Keys
C. Both
D. Items
46. [Link]() returns:
A. Keys only
B. Values only
C. Key-value pairs
D. Indexes
47. List comprehension is used for:
A. File handling
B. Creating lists using expressions
C. Sorting lists
D. Slicing lists
48. Which of these creates a tuple?
A. (1,2,3)
B. [1,2,3]
C. {1,2,3}
D. <1,2,3>
49. Which dictionary method deletes an item?
A. pop()
B. delete()
C. remove()
D. discard()
50. What is the result of len({1: “a”, 2: “b”})?
A. 1
B. 2
C. 3
D. Error
51. A text file stores data in:
A. Binary format
B. Human-readable format
C. Hexadecimal format
D. Encrypted format
52. Which mode is used to read a file?
A. “a”
B. “r”
C. “w”
D. “x”
53. Which method reads entire file?
A. readall()
B. read()
C. readline()
D. readfile()
54. write() is used for:
A. Reading
B. Writing
C. Deleting
D. Appending only
55. An exception is:
A. A loop
B. A runtime error
C. A function
D. A module
56. try statement is used for:
A. Looping
B. Handling exceptions
C. Declaring variables
D. Importing modules
57. finally block executes:
A. Only with error
B. Only without error
C. Always
D. Never
58. Command line arguments are handled using:
A. sys module
B. os module
C. random module
D. math module
59. A Python package is:
A. A folder with [Link]
B. A text file
C. A loop
D. An operator
60. Importing a module uses:
A. include
B. using
C. import
D. module
61. Algorithms must always have:
A. Infinite steps
B. Finite steps
C. No inputs
D. No outputs
62. The symbol for input in a flowchart is:
A. Diamond
B. Rectangle
C. Parallelogram
D. Circle
63. print(type(True)) gives:
A. int
B. bool
C. str
D. boolean
64. Which is mutable?
A. Tuple
B. String
C. List
D. Boolean
65. Which operator checks equality?
A. =
B. ==
C. ===
D. :=
66. What is the output of 3 * "ab"?
A. Error
B. ab
C. ababab
D. 3ab
67. range(5) generates:
A. 1 2 3 4 5
B. 0 1 2 3 4
C. 5 values starting at 1
D. Error
68. Which loop definitely runs for a fixed number of times?
A. while
B. for
C. do-while
D. recursion
69. pass statement is used to:
A. Stop a program
B. Do nothing
C. Raise error
D. Continue
70. Function parameters are written inside:
A. ()
B. {}
C. []
D. <>
71. [Link]() returns:
A. Lowercase
B. Uppercase
C. Title case
D. Error
72. Which operator is used for membership?
A. in
B. is
C. ==
D. <=
73. [Link]() removes:
A. First element
B. Last element
C. Specific index
D. All items
74. Tuples are faster than lists because:
A. They are bigger
B. They are immutable
C. They use more memory
D. They use loops
75. Dictionary keys must be:
A. Mutable
B. Immutable
C. Lists
D. None
76. f=open("[Link]","w") does what?
A. Reads file
B. Writes and overwrites
C. Appends
D. Deletes
77. readlines() returns:
A. String
B. List of lines
C. Dictionary
D. Set
78. os module is used for:
A. String operations
B. System operations
C. Math
D. Random
79. [Link](16) returns:
A. 2
B. 4
C. 8
D. Error
80. Which mode creates a file?
A. r
B. w
C. x
D. a
81. A package contains:
A. Functions only
B. Submodules
C. Classes only
D. Lists
82. isinstance(5,int) returns:
A. False
B. True
C. Error
D. None
83. Which operator is logical OR?
A. ||
B. or
C. OR
D. |
84. sum([1,2,3]) gives:
A. 1
B. 6
C. 3
D. Error
85. A recursive function must have:
A. No parameters
B. Base case
C. Loops
D. Global variables
86. What is the output of len("Python")?
A. 5
B. 6
C. 7
D. Error
87. Negative indexing starts from:
A. -2
B. -1
C. 0
D. 1
88. [Link](key) returns:
A. Value
B. Key
C. Index
D. Tuple
89. Which function converts string to integer?
A. str()
B. int()
C. float()
D. bool()
90. open("file","a") means:
A. Read
B. Append
C. Overwrite
D. Delete
91. An exception is caught using:
A. catch
B. try-except
C. handle
D. error()
92. [Link] stores:
A. Variables
B. Command line arguments
C. Exceptions
D. Modules
93. Which module generates random numbers?
A. math
B. random
C. os
D. sys
94. pow(2,3) returns:
A. 5
B. 6
C. 8
D. 9
95. A docstring is written using:
A. ‘
B. ‘’
C. “””
D. #
96. A package must contain:
A. [Link]
B. [Link]
C. [Link]
D. [Link]
97. To close a file you use:
A. end()
B. close()
C. stop()
D. finish()
98. Which converts list to tuple?
A. list()
B. tuple()
C. set()
D. convert()
99. isinstance("hi",str) returns:
A. True
B. False
C. Error
D. None
100. abs(-5) gives:
A. -5
B. 0
C. 5
D. None