Python quiz

Python Working with Files

Pre Quiz – Working with Files Q1 – Name the python module that supports regular expressions. re pyregex regexp regex Answer: re Explanation: The python module re supports regular expression. The functions in the re module lets you check if a particular string matches the given regular expression (or if a given regular expression matches…

Python Inheritance Quiz

Pre-quiz Inheritance Q1 – An object is created using __________ . None of the above constructor class functions Answer: constructor Show Answer Q2 – _____ is a python special method used to initialize the values of instance members for the new object. __self__ __call__ __add__ __init__ Answer: __init__ Show Answer Q3 – _________ is a…

Python Classes and Objects Question and Answer

Pre-Quiz classes and objects Q1 – Choose the correct built-in classes in Python. List String Set int Answer: List, int, Set Show Answer Q2 – A ______________ is a classication of certain objects and it is just a description of the properties and behavior of all objects of that classication should possess. Object Class Attribute…

Python Functions and Modules Quiz

Pre-Quiz Q1 – If a=[20,30,40,50,60], show the value of a[3]. 40 None of these options 60 50 Answer: 50 Explanation: List index starts with 0. Hence, a[3] refers to the 4th element in the list which is 50. Show Answer Q2 – Consider the following code snippet: 1. list = [ [ ] ] *…

Lists, Tuples, and Ditionaries Quiz

Pre-Quiz Q1 – Predict the right output for the following code. i = 5 while True:   if i%9 == 0:    break   print(i)   i += 1 5 6 7 8 5 6 7 8 9 5 6 7 8 10 11 12 13 14 15…. Error Answer: 5 6 7 8 Explanation:…

Control structures Quiz

Pre-Quiz Q1 – Dene what kind of language is python ? Interpreted Compiled Comiled and Interpreted Outsourced Answer: Interpreted Explanation: The terms interpreted or compiled is not a property of the language but a property of the implementation. There are multiple implementations of Python language. The ocial one is byte code ‘interpreted’. So, it is…

Introduction to Python Quiz

Pre-Quiz Q1 – Identify which of the following is an interpreted language. Python C C++ Pascal Answer: Python Explanation: Pascal, C and C++ are all compiled languages. Python is an interpreted language. Show Answer Q2 – Python syntax is case-sensitive. State true or false. True False Answer: ‘True’. Explanation: Case sensitive means that x is…

x