Home Videos Exercises MCQ Q&A Quiz E-Store Services Blog Sign in Appointment Payment

Python MCQ

Soopro Pathshala provides Python MCQ(Multiple Choice Questions)


1. Is Python case sensitive when dealing with identifiers?

a) no

b) yes

c) machine dependent

d) none of the mentioned

View Answer

Answer: (b) yes



2. Which keyword is uesd for function in Python language?

a) Function

b) def

c) Fun

d) Define

View Answer

Answer: (b) def



3. Which of the following character is used to give single-line comments in Python?

a) //

b) #

c) !

d) /*

View Answer

Answer: (b) #



4. What does pip stand for python?

a) Pip Installs Python

b) Pip Installs Packages

c) Preferred Installer Program

d) All of the mentioned

View Answer

Answer: (c) Preferred Installer Program



5. Which of the following functions is a built-in function in python?

a) factorial()

b) print()

c) seed()

d) sqrt()

View Answer

Answer: (b) print()



6. Which of the following is not a core data type in Python programming?

a) Tuples

b) Lists

c) Class

d) Dictionary

View Answer

Answer: (c) Class



7. How to create a variable in Python with a value 22.6?

a) int a=22.6

b) a=22.6

c) Integer a =22.6

d) None of the above

View Answer

Answer: (b) a=22.6



8. How to convert the uppercase letters in the string to lowercase in Python?

a) lowercase()

b) capitalize()

c) lower()

d) toLower()

View Answer

Answer: (c) lower()



9. How to fetch characters from a given range in Python?

a) [:]

b) in operator

c) []

d) none of the above

View Answer

Answer: (a) [:]



10. What is the correct way to get the maximum value from Tuple in Python?

a) print (max(mytuple));

b) print (maximum(mytuple));

c) print (mytuple.max());

d) print (mytuple.maximum);

View Answer

Answer: (a) print (max(mytuple));



11. How to fetch and display only the keys of a Dictionary in Python?

a) print(mystock.keys())

b) print(mystock.key())

c) print(keys(mystock))

d) print(key(mystock))

View Answer

Answer: (a) print(mystock.keys())



12. How to align a string centrally in Python?

a) align() method

b) center() method

c) fill() method

d) none of the above

View Answer

Answer: (b) center() method



13. Are Python Tuples faster than Lists?

a) TRUE

b) FALSE

c) cant say

d) none of these

View Answer

Answer: (a) TRUE



14. How to specify range of index in Python Tuples? Let’s say our tuple name is “mytuple”

a) print(mytuple[1:4])

b) print(mytuple[1 to 4])

c) print(mytuple[1-4])

d) print(mytuple[].slice[1:4])

View Answer

Answer: (a) print(mytuple[1:4])



15. How to correctly create a function in Python?

a) demoFunction()

b) def demoFunction()

c) function demoFunction()

d) void demoFunction()

View Answer

Answer: (b) def demoFunction()



16. How to get the total length of a Tuple in Python?

a) count() method

b) length() method

c) len() method

d) None of the above

View Answer

Answer: (c) len() method



17. How to access a value in Tuple?

a) mytuple(1)

b) mytuple{1}

c) mytuple[1]

d) none of the above

View Answer

Answer: (c) mytuple[1]



18. Is using a return statement optional in a Python Function?

a) Yes

b) No

c) cant say

d) none of these

View Answer

Answer: (a) Yes



19. What is the correct way to get minimum value from Tuple?

a) print(min(mytuple));

b) print(minimum(mytuple));

c) print(mytuple.min());

d) print(mytuple.minimum);

View Answer

Answer: (a) print(min(mytuple));



20. ____________ represents key-value pair in Python?

a) Tuples

b) Lists

c) Dictionary

d) all of the above

View Answer

Answer: (c) Dictionary



21. How to create an empty Tuple in Python?

a) mytuple=()

b) mytuple=(0)

c) mytuple=0

d) mytuple=

View Answer

Answer: (a) mytuple=()



22. Which of the following types of loops are not supported in Python?

a) for

b) while

c) do-while

d) none of the above

View Answer

Answer: (c) do-while



23. Which of the following functions converts date to corresponding time in Python?

a) strptime()

b) strftime()

c) both a and b

d) none of the above

View Answer

Answer: (a) strptime



24. What keyword is used in python to raise exceptions?

a) raise

b) try

c) goto

d) except

View Answer

Answer: (a) raise



25. Which of the following are valid escape sequence in Python?

a) \n

b) \t

c) \\

d) All of the above

View Answer

Answer: (d) all of the above



26. Which of the following are valid string manipulation functions in Python?

a) count()

b) upper()

c) strip()

d) all of the above

View Answer

Answer: (d) all of the above



27. In which language is python written?

a) c++

b) c

c) java

d) none of these

View Answer

Answer: (b) c



28. Which of the following concepts is not a part of Python?

a) pointers

b) loops

c) dynamic typing

d) all of the above

View Answer

Answer: (a) pointers