You are on page 1of 4

AI with Python MCQ’s

Q1. Which of the following is the use of id() function in python?


Every object doesn’t have a unique id
Id returns the identity of the object
All of the mentioned
None of the mentioned

Q2. Is Python case sensitive when dealing with identifiers?


yes
no

Q3. All keywords in Python are in


UPPER CASE
lower case
Capitalized
None of the mentioned

Q4. Mathematical operations can be performed on a string. State whether true or false -
False
A. True
Q5. Which one of the following has the highest precedence in the expression?
Addition
Multiplication
Exponential
Parentheses

Q6. What is the return type of function id?


float
bool
dict
int

Q7. What is the output of the following? print("Hello {0!r} and {0!s}".format('foo', 'bin'))
Hello ‘foo’ and foo
Hello foo and foo
Hello foo and ‘bin’
Error

Q8. Which of the following data types is not supported in python ?


String
Numbers
Slice
List
Q9. Which Of The Following Keywords Mark The Beginning Of The Class Definition?
return
class
def
All of the above

Q10. Select the reserved keyword in python-


else
raise
import
All of the above

Q11. Are nested if-else are allowed in Python?


Yes
no

Q12. Python allows string slicing. What is the output of below code: s='cppbuzz chicago' print(s[3:5])
buzzc
pbuzz
bu
None of these

Q13. class test: def init (self): print "Hello World" def init (self): print "Bye
World" obj=test()
Bye World
Hello World
Compilation Error
Ambiguity

Q14. The format function, when applied on a string returns :


list
bool
int
str

Q15. Which statement is correct. ............... ??


List is mutable & Tuple is immutable
List is immutable & Tuple is mutable
Both are Mutable.
Both are Immutable

Q16. What is the maximum possible length of an identifier?


32 characters
63 characters
79 characters
31 Characters
Q17. Which one of the following is not a python's predefined data type?
List
Dictionary
Tuple
Class

Q18. What will be the output of 7^10 in python?


13
15
2
None of these

Q19. 19 % 2 in python
2
17
None of these

Q20. Which of the following has more precedance?


/
+
()
-
Q21. Is Tuple mutable?
yes
no

Q 22. Among the given options, which search algorithm requires less memory?
• Optimal Search
• Depth First Search
• Breadth-First Search
• Linear Search

Q 23.Which one of the following is the correct extension of the Python file?
• .py
• .python
• .p
• None of these

Q 24. Which of the following statements is correct for variable names in Python language?
• All variable names must begin with an underscore.
• Unlimited length
• The variable name length is a maximum of 2.
• All of the above

Q 25.Which of the following operators is the correct option for power(ab)?


• a^b
• a**b
• a^^b
• a^*b
Q 26.What is Time Complexity of Breadth First search algorithm?
• b
• b^d
• b^2
• b^b

Q 27.Depth-First Search is implemented in recursion with _______ data structure.


• LIFO
• LILO
• FIFO
• FILO

Q 28.What is Space Complexity of Depth First search algorithm?


• b
• b^2
• b^b
• b^m

Q 29.Which of the following search algorithm searches forward from initial state and backward from goal
state till both meet to identify a common state?
• Uniform Cost Search
• Iterative Deepening Depth-First Search
• Bidirectional Search
• None of the Above

Q 30.Which of the following declarations is incorrect in python language?


• xyzp = 5,000,000
• x y z p = 5000 6000 7000 8000
• x,y,z,p = 5000, 6000, 7000, 8000
• x_y_z_p = 5,000,000

You might also like