O level Python

- Python was developed by
A. Dennis Ritchie
B. James Gosling
C. Bjarne Stroustrup
D. Guido van Rossum
- In which year was the Python language developed?
A. 1972
B. 1982
C. 1989
D. 1995
- How many keywords are there in python 3.7?
A. 30
B. 31
C. 32
D. 33
- Which one of the following is the correct extension of the Python file?
A. .p
B. .py
C. .python
D. None of these
- Which of the following is not in Python Character Set.
A. Vector
B. Digits : 0 – 9
C. Letters : A-Z or a – z
D. Whitespaces : blank space, tab etc
- Which of the following is not the mode of interacting with python?
A. Script Mode
B. Hybrid Mode
C. Interactive Mode
D. None of the above
- Is Python case sensitive when dealing with identifiers?
A. Yes
B. No
C. machine dependent
D. None of the mentioned
- What is the maximum possible length of an identifier?
A. 31 characters
B. 63 characters
C. 73 characters
D. Any length
- In which language is Python written?
A. C
B. English
C. PHP
D. All of the above
o level python mcq questions pdf
- What do we use to define a block of code in Python language?
A. Key
B. Brackets
C. Indentation
D. None of these
- Python is said to be easily
A. writable language
B. bug-able language
C. readable language
D. script-able language
- Extensible programming language that can be extended through classes and programming interfaces is
A. Python
B. Perl
C. Ada
D. PHP
- Which one of the following is not a Python keyword?
A. except
B. finally
C. return
D. calender
- Which character is used in Python to make a single line comment?
A. /
B. //
C. #
D. !
- Python is Object Oriented Programming Language.
A. True
B. False
C. Neither true nor false
D. None of the above
- Python 3.0 is released in which year?
A. 2000
B. 2008
C. 2011
D. 2016
- What is output for – min(”hello world”)
A. w
B. e
C. hello world
D. a blank space character
- How to output the string “May the odds favor you” in Python?
A. printf(“May the odds favor you”)
B. print(“May the odds favor you”)
C. echo(“May the odds favor you”)
D. System.out(“May the odds favor you”)
- Python is often described as a:
A. Gear included language
B. Gear excluded language
C. Batteries excluded language
D. Batteries included language
- Python supports dynamic typing.
A. True
B. False
- Which of the following statements is true?
A. Python is an interpreted language.
B. Python is an object-oriented language
C. Python is a high level programming language.
D. All of the above
- Mathematical operations can be performed on a string in
Python? State whether true or false:
A. True
B. False
- Which one of the following is not a python’s predefined data type?
A. Class
B. List
C. Tuple
D. Dictionary
- Which of the following is true for variable names in Python?
A. unlimited length
B. all private members must have leading and trailing underscores
C. underscore and ampersand are the only two special characters allowed
D. none of the mentioned
- Which of the following is not a keyword in Python language?
A. val
B. try
C. raise
D. with
- Which one of the following is the correct statement regarding comments in Python?
A. Python comments will affect the print statement present in program at some extent.
B. To apply comment we have to use ‘#’ keyword at starting while writing a comment in our program.
C. Python provides us a way through which can do both single line and multiple lines in our program.
D. To apply comment we have to use ‘#’ keyword both at starting
and ending while writing a comment in our program.
- What is a python file with .py extension called?
A. module
B. package
C. directory
D. None of the above
- What is the return value of trunc()?
A. int
B. float
C. bool
D. none
- Which of the following has more precedence?
A. +
B. ()
C. –
D. /
o level m3r5 mcqs for jan 2025 exam
- Do we need to compile a program before execution in Python?
A. Yes
B. No
- Which of the following statements is correct regarding the object-oriented programming concept in Python?
A. Classes are real-world entities while objects are not real
B. Objects are real-world entities while classes are not real
C. Both objects and classes are real-world entities
D. All of the above
- How to convert the uppercase letters in the string to lowercase in Python?
A. lower()
B. lowercase()
C. capilaize()
D. toLower()
- How to capitalize only the first letter of a sentence in Python?
A. upper() method
B. capitalize() method
C. uppercase() method
D. None of the above
- How to convert the lowercase letters in the string to uppercase in Python?
A. upper()
B. uppercase()
C. toUpper()
D. capitalize()
- How to check whether all the characters in a string is printable?
A. echo() method
B. print() method
C. printable() method
D. isprintable() method
- How to swap case in Python i.e. lowercase to uppercase and vice versa?
A. case() method
B. convert() method
C. casefold() method
D. swapcase() method
- What will be the data type of the following variable? A = ‘101’
A. Integer
B. String
C. Float
D. None of the above
- Write the output of the following:
print(range(0,8,2))
A. 0,2,4,6
B. Error
C. range(0, 8, 2)
D. None of the above
- Which of the following is not correct about python?
A. Python is based on ABC language.
B. Python is an open source language.
C. Python is developed by Guido Van Rossum
D. None of the above
- Which of the following cannot be a variable?
A. init
B. in
C. it
D. on
- What error occurs when you execute the following Python code snippet? apple = mango
A. Type Error
B. Value Error
C. Name Error
D. Syntax Error
- Smallest element of of python coding is called __
A. Token
B. Keywords
C. Identifiers
D. Delimiters
- Writing comments is mandatory in python programs(T/F)
A. True
B. False
- Which keyword is used to define a function in python?
A. new
B. def
C. define
D. None of the above
- Which statement will display square of number (n)
A. print(n * n)
B. print(math.pow(n,2)) # math module is already imported
C. Only First
D. All of the above
- What is the output of this expression, 31*3?
A. 1
B. 3
C. 9
D. 27
- Identify the invalid identifier.
A. and
B. token
C. Keyword
D. operator
- Which keyboard key is used to run python programs?
A. f5
B. f6
C. F + n
D. Ctrl + r
- Which of the following operation cannot be performed on a Python string?
A. Deletion of Python String
B. Splitting of Python String
C. Reassigning of Python String
D. Adding elements in a Python String
51.What is the output of print(2 ** 3)?
A. 6
B. 8
C. 9
D. 5
52.Which of the following is a valid Python variable name?
A. 2variable
B. variable-name
C. variable_2
D. variable name
53.What is the data type of 5.0 in Python?
A. int
B. double
C. float
D. long
54.Which of these is used to define a function in Python?
A. define
B. function
C. def
D. fun
55.What is the correct way to write a comment in Python?
A. /* comment */
B. // comment
C. ** comment
D. # comment
56.What does the len() function do in Python?
A. Returns the number of variables
B. Returns the length of a string/list
C. Converts to integer
D. Joins strings
57.Which keyword is used to start a loop in Python?
A. repeat
B. loop
C. for
D. iterate
58.What will be the output of print(3 == 3.0)?
A. False
B. Error
C. True
D. None
59.How to insert an element at the end of a list?
A. list.add()
B. list.append()
C. list.insert()
D. list.push()
60.What is the result of int(’10’) + float(‘5.5’)?
A. 105.5
B. 15.5
C. Error
D. 10.5
61.Which operator is used for floor division in Python?
A. /
B. //
C. %
D. **
62.What is the output of ‘Python'[1]?
A. P
B. y
C. t
D. h
63.Which function converts a string to an integer?
A. str()
B. int()
C. float()
D. eval()
64.What does range(1, 5) return?
A. [1, 2, 3, 4]
B. [1, 2, 3, 4, 5]
C. [1, 5]
D. [2, 3, 4, 5]
65.What is the output of type([])?
A. list
B. tuple
C. dictionary
D. array
66.What is the result of bool(0)?
Answer: False
67.Which of the following is immutable?
A. list
B. set
C. tuple
D. dictionary
68.What does break do in a loop?
Answer: Exits the loop
69.is operator is used to compare…?
Answer: Object identity
70.Which function is used to read input from the user in Python 3?
Answer: input()
71.Which keyword is used for an infinite loop?
Answer: while(True)
72.Which of the following is a logical operator?
A. and
B. not
C. or
D. All of the above
73.What is the correct way to write an if statement in Python?
Answer: if x > 5:
74.What is the output of print(10 % 3)?
Answer: 1
75.How many times will this loop run? for i in range(0, 3):
Answer: 3 times
76.What does str.upper() do?
Answer: Converts all characters to uppercase
77.How to get the last item in a list a?
Answer: a[-1]
78.list.pop() removes…?
Answer: Last element
79.What is the default return type of a function without return?
Answer: None
80.Which function returns number of elements in list?
Answer: len()
81.Which mode opens a file for reading?
Answer: ‘r’
82.What is the output of open(‘file.txt’, ‘w’)?
Answer: Opens file for writing (creates if not exists)
83.What is used to catch exceptions in Python?
Answer: try-except
84.What does finally block do?
Answer: Executes no matter what
85.Which keyword is used to raise an exception?
Answer: raise
86.Dictionary in Python stores data in…?
Answer: key-value pairs
87.What is the output of {‘a’:1, ‘b’:2}[‘b’]?
Answer: 2
88.Which method removes all items from a list?
Answer: list.clear()
89.How to add a key-value pair in a dictionary?
Answer: dict[‘key’] = value
90.What does set() do?
Answer: Removes duplicates and stores unordered unique items
91.What is indentation used for in Python?
Answer: To define code blocks
92.Python is a…?
A. Compiled language
B. Interpreted language
C. Assembly language
D. High-level + compiled
93.Python files have extension…?
Answer: .py
94.What does continue do in a loop?
Answer: Skips to next iteration
95.Which keyword is used to define a class?
Answer: class
96.What is the use of pass in Python?
Answer: It does nothing; a placeholder
97.What is the output of bool(‘False’)?
Answer: True
98.What will list(range(0,10,2)) return?
Answer: [0, 2, 4, 6, 8]
99.How to remove a specific item by value from a list?
Answer: list.remove(item)
100.What is the correct syntax for importing a module?
Answer: import module_name
101.Which data type is used for True/False?
Answer: bool
102.What is a lambda function?
Answer: An anonymous function
103.Which built-in function returns the largest item?
Answer: max()
104.How to comment multiple lines in Python?
Answer: Use multiple # or triple quotes (”’)
105.What is the output of 3 != 5?
Answer: True




