0% found this document useful (0 votes)
40 views6 pages

Python Methods and Data Types Quiz

Uploaded by

indrayanmondal99
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views6 pages

Python Methods and Data Types Quiz

Uploaded by

indrayanmondal99
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Multiple Choice Questions (Python)

1. Which one of these is floor division?

Answer: //

2. Which of the following data type is used to store values in Key & Value format?

Answer: Dictionary

3. Which of the following is the truncation division operator?

Answer: %

4. Select the reserved keyword in Python

Answer: All of these (Else, Import, Raise)

5. What will be the output of 7^10 in Python?

Answer: 13

6. What is used to take input from the user in Python?

Answer: input()

7. What is the data type of X in X = [12.12, 13, 'rkm']?

Answer: List

8. Which of the following is correct way to declare string variable in Python?

Answer: fruit = 'banana'

9. Which of these is not a core data type?

Answer: Class

10. Which of the following is not a complex number?

Answer: k = 2 + 3l

11. Suppose list1 = [2445,133,12454,123], what is max(list1)?

Answer: 12454

12. What is the answer to this expression, 22 % 3 is?

Answer: 1
13. What is the output of "hello" + 1 + 2 + 3 ?

Answer: Error

14. Operators with the same precedence are evaluated in which manner?

Answer: Left to Right

15. What is the output of this expression, 3*1**3?

Answer: 3

16. Which one of the following has the highest precedence in the expression?

Answer: Parenthese

17. Which of the following is invalid?

Answer: none of this

18. Which of the following is not a keyword?

Answer: Eval

19. What is the type of inf?

Answer: float

20. Which of the following is incorrect?

Answer: float('12+34')

Fill in the Blanks (Python)

1. _____ code is used to open a file for binary writing?

Answer: "wb"

2. To start Python from the command prompt, use the command _____.

Answer: python

3. The expression a{5} will match _____ characters with the previous regular expression.

Answer: exactly 5
4. In the functions [Link](group) and [Link](group), if the argument group is not
specified, it defaults to _____.

Answer: Zero

5. The character Dot (.) in the default mode, matches any character other than _____.

Answer: newline

6. _____ of the following function convert a string to a float in Python.

Answer: float(x)

7. _____ of the following functions clears the regular expression cache.

Answer: [Link]()

8. _____ keyword is used to start a function in Python.

Answer: def

9.

Answer:

10. _____ is correct syntax to copy one list into another.

Answer: listA = listB[:]

11. The output of 7^10 in Python will be _____.

Answer: 13

12. The correct method to load a module in Python is _____.

Answer: import math

13. _____ of the following data type is not supported in Python.

Answer: Slice

14. _____ of the following is not a Python's predefined data type.

Answer: Class

15. The statement using and operator results true if _____.


Answer: both operands are true

16. A recursive function is _____.

Answer: A function that calls itself

17. The answer to this expression, 22 % 3 is _____.

Answer: 1

18. _____ of the following commands will create a list.

Answer: all of the mentioned

19. _____ of the following expressions results in an error.

Answer: 4.0 + float(3)

20. _____ is the output of the following

Answer: Error

True/False Questions with Answers

1. Python is case sensitive when dealing with identifiers.


Answer: TRUE

2. A list can have different types of values.


Answer: TRUE

3. Variable name can start with an underscore.


Answer: TRUE

4. Python treats a string as special kind of tuple.


Answer: TRUE

5. The continue command is used to exit a loop.


Answer: FALSE

6. Variable name can have symbols like: @, #, $ etc.


Answer: FALSE

7. Python is an object-oriented language.


Answer: TRUE

8. Checking multiple conditions in Python requires elif statements.


Answer: TRUE
9. Functions make your program run faster.
Answer: FALSE

10. Python has two loops: for and while loops.


Answer: TRUE

11. A function is a piece of code that performs a specific task.


Answer: TRUE

12. What is the output of print(0.1 + 0.2 == 0.3)?


Answer: FALSE

13. Functions are used to create objects in Python.


Answer: FALSE

14. Nested if-else are allowed in Python.


Answer: TRUE

15. In Python, you can define a variable without specifying its data type.
Answer: TRUE

16. You can run any executable program from run menu.
Answer: TRUE

17. The print function is used to receive data from keyboard in a program.
Answer: FALSE

18. In Python, to access the type of a variable, you can use the type function.
Answer: TRUE

19. A comment in Python language can start with # sign.


Answer: TRUE

20. In Python, a string can be formatted using %s.


Answer: TRUE

Matching

[Link]("hello") → ['h', 'e', 'l', 'l', 'o']

[Link] format function, when applied on a string returns → Str

[Link](r"\nHello") → \nHello

[Link](ord("A")) → A
[Link] is an invalid variable → 1age

[Link]("abc. DEF".capitalize()) → Abc. def

[Link] is used to read a string → input("String")

8."Hello".replace("l", "e") → Heeeo

[Link] does not accept any argument → [Link]

[Link] is used to create an empty set → set()

11.

12. This function accepts only integers as arguments → chr()

13. This function does not throw an error → ord(' ')

14. The output when we execute list("hello") is → ['h', 'e', 'l', 'l', 'o']

15 This code will not show a match → [Link]('ab', 'ba')*

16.. [Link](3) return is → 1

17. This type of elements are accepted by [Link]() → lists

18. Built-in function & User defined function is → two main types of functions

19 . This is a variable defined outside a function referred to as → global variable

20. This is not a valid namespace → Public namespace

You might also like