Hướng dẫn sanfoundry python programs
Show
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn. Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses. Here are 1000 MCQs on Python (Chapterwise). 1. Who developed Python Programming Language? Answer: c 2. Which type of Programming does Python support? Answer: d 3. Is Python case sensitive when dealing with identifiers? Answer: a 4. Which of the following is the correct extension of the Python file? Answer: c 5. Is Python code compiled or interpreted? Answer: b 6. All keywords in Python are in _________ Answer: d 7. What will be the value of the following Python expression? a) 7 Answer: a 8. Which of the following is used to define a block of code in Python language? Answer:
a 9. Which keyword is used for function in Python language? Answer: b 10. Which of the following character is used to give single-line comments in Python? Answer: b 11. What will be the output of the following Python code? i = 1 while True: if i%3 == 0: break print(i) i + = 1 a) 1 2 3 Answer: b 12. Which of the following functions can help us to find the version of python that we are currently working on? Answer: a 13. Python supports the creation of anonymous functions at runtime, using a construct called __________ Answer: c 14. What is the order of precedence in python? Answer: d 15. What will be the output of the following Python code snippet if x=1? a) 4 Answer: a 16. What does pip stand for python? Answer: c 17. Which of the following is true for variable names in Python? Answer: b 18. What are the values of the following Python expressions? 2**(3**2) (2**3)**2 2**3**2 a) 512, 64, 512 Answer: a 19. Which of the following is the truncation division operator in Python? Answer: b 20. What will be the output of the following Python code? l=[1, 0, 2, 0, 'hello', '', []] list(filter(bool, l)) a) [1, 0, 2, ‘hello’, ”, []] Answer: c 21. Which of the following functions is a built-in function in python? Answer: b 22. Which of
the following is the use of id() function in python? Answer: b 23. The following python program can work with ____ parameters. def f(x): def f1(*args, **kwargs): print("Sanfoundry") return x(*args, **kwargs) return f1 a) any
number of Answer: a 24. What will be the output of the following Python function? min(max(False,-3,-4), 2,7) a) -4 Answer: d 25. Which of the following is not a core data type in Python programming? Answer: c 26. What will be the output of the following Python expression if x=56.236? a) 56.236 Answer: d 27. Which of these is the definition for packages in Python? Answer: b 28. What will be the output of the following Python function? a) Error Answer: c 29. What will be the output of the following Python code? x = 'abcd' for i in x: print(i.upper()) a) a B C D Answer: d 30. What is the order of namespaces in which Python looks for an identifier? Answer: c 31. What will be the output of the following Python code snippet? for i in [1, 2, 3, 4][::-1]: print (i) a) 4 3 2 1 Answer: a 32. What will be the output of the following Python statement?
a) bc Answer: b 33. Which function is called when the following Python program is executed? a) str() Answer: c 34. Which one of the following is not a keyword in Python language? Answer: b 35. What will be the output of the following Python code?
a) 12 Answer: a 36. What will be the output of the following Python program? def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q)) a) Error Answer: d 37. Which module in the python standard library parses options received from the command line? Answer: b 38. What will be the output of the following Python program? z=set('abc') z.add('san') z.update(set(['p', 'q'])) z a) {‘a’, ‘c’, ‘c’, ‘p’, ‘q’, ‘s’, ‘a’, ‘n’} Answer: c 39. What arithmetic operators cannot be used with strings in Python? Answer: b 40. What will be the output of the following Python code? print("abc. DEF".capitalize()) a) Abc. def Answer: a 41. Which of the following statements is used to create an empty set in
Python? Answer: d 42. What will be the value of ‘result’ in following Python program? list1 = [1,2,3,4] list2 = [2,4,5,6] list3 = [2,6,7,8] result = list() result.extend(i for i in list1 if i not in (list2+list3) and i not in result) result.extend(i for i in list2 if i not in (list1+list3) and i not in result) result.extend(i for i in list3 if i not in (list1+list2) and i not in result) a) [1, 3, 5, 7, 8] Answer: a 43. To add a new element to a list we use which Python command? Answer: c 44. What will be the output of the following Python code? print('*', "abcde".center(6), '*', sep='') a) * abcde * Answer: b 45. What will be the output of the following Python code?
a) [1, 4] Answer: c 46. Which one of the following is the use of function in python? Answer: c 47. Which of the following Python statements will result in the output: 6? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] a) A[2][1] Answer: b 48. What is the maximum possible length of an identifier in Python? Answer: d 49. What will be the output of the following Python program? i = 0 while i < 5: print(i) i += 1 if i == 3: break else: print(0) a) error Answer: c 50. What will be the output of the following Python code? x = 'abcd' for i in range(len(x)): print(i) a) error Answer: d 51. What are the two main types of functions in Python? Answer: c 52. What will be the output of the following Python program?
a) 5 Answer: a 53. Which of the following is a Python tuple? Answer: d 54. What will be the output of the following Python code snippet? a) Error Answer: b 55. What will be the output of the following Python expression? a) 4 Answer: c 56. Which of the following is a feature of Python DocString? Answer: d 57. What will be the output of the following Python code? print("Hello {0[0]} and {0[1]}".format(('foo', 'bin'))) a) Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’) Answer: c 58. What is output of print(math.pow(3, 2))? Answer: a 59. Which of the following is the use of id() function in python? Answer: b 60. What will be the output of the following Python code? x = [[0], [1]] print((' '.join(list(map(str, x))),)) a) 01 Answer: d 61. The process of pickling in Python includes ____________ Answer: a 62. What will be the output of the following Python code? def foo(): try: return 1 finally: return 2 k = foo() print(k) a) error, there is more than one return statement in a single try-finally block Answer: c Chapterwise Multiple Choice Questions on PythonOur 1000+ MCQs focus on all topics of the Python Programming subject, covering 100+ topics. This will help you to prepare for exams, contests, online tests, quizzes, viva-voce, interviews, and certifications. You can also download the PDF of Python MCQs by applying below.
1. Python MCQ on Variable Names & OperatorsThe section contains multiple choice questions and answers on python variables and basic operators. 2. Python MCQ on Data Types & Numeric TypesThe section contains questions and answers on python core data types and numeric types. 3. MCQ on Precedence and Associativity in PythonThe section contains Python MCQ on precedence and associativity. 4. Python MCQ on Bitwise & BooleanThe section contains multiple choice questions and answers on python bitwise and boolean. 5. Multiple Choice Questions on Formatting & Decorators in PythonThe section contains questions and answers on python formatting, advanced formatting and decorators. 6. Python MCQ on While and For LoopsThe section contains Python MCQ on different types of loops (while and for loops). 7. Python MCQ on StringsThe section contains multiple choice questions and answers on different types of python strings. The section contains questions and answers on different types of lists. 9. Python MCQ on List ComprehensionThe section contains MCQ on different types of list comprehension. 10. MCQ on Python TuplesThe section contains multiple choice questions and answers on various types of tuples. 11. MCQ on Python SetsThe section contains questions and answers on various types of python sets. 12. Multiple Choice Questions on Python DictionaryThe section contains multiple choice questions and answers on python dictionary. 13. Python MCQ on Built-in FunctionsThe section contains multiple choice questions and answers on different types of python built in functions. 14. Multiple Choice Questions on Python FunctionsThe section contains questions and answers on different types of python functions. 15. Python MCQ on Argument Passing, Variables and RecursionThe section contains Python MCQ on argument parsing, global and local variables, recursion, differences between shallow and deep copy. 16. Python MCQ on Mapping FunctionsThe section contains Python multiple choice questions and answers on functional programming tools and mapping functions. 17. Python MCQ on ModulesThe section contains questions and answers on Python modules like math module, random module, sys module, datetime module, pickle and tutrle modules. 18. Python MCQ on Regular ExpressionsThe section contains Python MCQ on different types of regular expressions (regex). 19. Python Multiple Choice Questions on FilesThe section contains multiple choice questions and answers on python files. 20. Python MCQ on Classes and ObjectsThe section contains questions and answers on operator overloading, classes and objects. 21. Python MCQ on OOPsThe section contains MCQ on oops concepts like inheritance, polymorphism and encapsulation. 22. Python MCQ on Exception HandlingThe section contains multiple choice questions and answers on exception handling. If you would like to learn "Python" thoroughly, you should attempt to work on the complete set of 1000+ MCQs - multiple choice questions and answers mentioned above. It will immensely help anyone trying to crack an exam or an interview. Note: We are working on pdf download for Python MCQs and will publish the download link here. Fill this Python mcq pdf download request form for download notification. Wish you the best in your endeavor to learn and master Python! Important Links:
|