0% found this document useful (0 votes)
2 views5 pages

Python Programming Questions Formatted

The document contains a series of multiple choice questions, fill-in-the-blank questions, and true/false questions related to Python programming concepts. It covers topics such as variable naming, data types, operators, expressions, and control flow statements. Each question is accompanied by the correct answer for reference.
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)
2 views5 pages

Python Programming Questions Formatted

The document contains a series of multiple choice questions, fill-in-the-blank questions, and true/false questions related to Python programming concepts. It covers topics such as variable naming, data types, operators, expressions, and control flow statements. Each question is accompanied by the correct answer for reference.
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
You are on page 1/ 5

Python Programming Revision Tour – 1.

Multiple Choice Questions (MCQ)


1.Which of the following is an invalid variable?
(a) my_day_2 (b) 2nd_day (c) Day_two (d) _2

Ans. (b) 2nd_day

2. Find the invalid identifier from the following:


(a) name (b) break (c) section (d) mark12

Ans. (d) mark12

3. Which of the following is not a keyword?


(a) eval (b) assert (c) nonlocal (d) pass

Ans. (a) eval

4. Which of the following cannot be a variable?


(a) __init__ (b) in (c) it (d) on

Ans. (b) in

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


(a) Lists (b) Dictionary (c) Tuples (d) Class

Ans. (d) Class

6. How would you write x^y in Python as an expression?


(a) x^y (b) x**y (c) x^^y (d) none of these

Ans. (b) x**y

7. What will be the value of the expression? 14 + 13 % 15


(a) 14 (b) 27 (c) 12 (d) 0
Ans. (c) 12

8. Evaluate the expression given below if A=16 and B=15. A*B//A


(a) 0.0 (b) 0 (c) 1.0 (d) 1

Ans. (b) 0

9. What is the value of x? x = int(13.25 + 4/2)


(a) 17 (b) 14 (c) 15 (d) 23

Ans. (c) 15

10. The expression 8/4/2 will evaluate equivalent to which of the following
expressions:
(a) 8/(4/2) (b) (8/4)/2

Ans. (b) (8/4)/2

11. Which among the following list of operators has the highest precedence?
(a) <<, >> (b) ** (c) | (d) %, /, *, +, -

Ans. (b) **

12. Which of the following expressions results in an error?


(a) float('12') (b) int('12') (c) float('12.5') (d) int('12.5')

Ans. (d) int('12.5')

13. Which of the following statement prints the shown output below?
hello\example\test.txt
(a) print("hello\example\test.txt")

(b) print("hello\\example\\test.txt")

(c) print("hello\"example\"test.txt")

(d) print("hello\\example\"test.txt")
Ans. (b) print("hello\\example\\test.txt")

14. Which value type does input() return?


(a) Boolean (b) String (c) Int (d) Float

Ans. (b) String

15. Which two operators can be used on numeric values in Python?


(a) @ (b) % (c) + (d) #

Ans. (b) % (c) +

16. Which of the following four code fragments will yield following output?
Eina
Mina
Dika
Select all of the function calls that result in this output
(a) print('''Eina
Mina
Dika''')

(b) print('''EinaMinaDika''')

(c) print('Eina\nMina\nDika')

(d) print('Eina\nMina\nDika')

Ans. (c) print('Eina\nMina\nDika')

17. Which of the following is valid arithmetic operator in Python:


(a) // (b) ? (c) < (d) and

Ans. (a) //

18. For a given declaration in Python as s = 'WELCOME', which of the following will be
the correct output of print(E[1::2])?
(a) WEL (b) COME (c) WLOE (d) ECM

Ans. (d) ECM


19. Which of the following is an incorrect Logical operator in Python?
(a) not (b) in (c) or (d) and

Ans. (b) in

20. Which of the following is not a Tuple in Python?


(a) (1, 2, 3) (b) ("One", "Two", "Three") (c) (10, ) (d) ("One")

Ans. (d) ("One")

Fill in the Blanks

1.The smallest individual unit in a program is known as a ____.. Ans. Token


2. A token is also called a ____. Ans. lexical unit

3. A _____ is a word having special meaning and role as specified by programming language.
Ans. keyword

4. The data types whose values cannot be changed in place are called _____ types. Ans.
Immutable.

5. In a Python expression, when conversion of a value’s data type is done automatically by


the compiler without programmer’s intervention, it is called _____. Ans. Implicit type
conversion

6. The explicit conversion of an operand to a specific type is called _____. Ans. type casting

7. The _____ statement is an empty statement in Python. Ans. pass

8. A _____ statement skips the rest of the loop and jumps over to the statement following the
loop. Ans. break

9. The _____ statement skips the rest of the loop statements and causes the next iteration of
the loop to take place. Ans. continue

10. Python’s _____ cannot be used as variable name. Ans. keyword.


True/False Questions
1. The expression int(x) implies that the variable x is converted to integer. (TRUE)

2. The value of the expressions 4/(3*(2–1)) and 4/3*(2–1) is the same. (TRUE)

3. The value of the expressions 4/(3*(4–2)) and 4/3*(4–2) is the same. (FALSE)

4. The expression 2**2**3 is evaluated as: (2**2)**3. (FALSE)

5. A string can be surrounded by three sets of single quotation marks or by three sets of
double quotation marks. (TRUE)

6. Variables can be assigned only once. (FALSE)

7. In Python, a variable is a placeholder for data. (FALSE)

8. In Python, only if statement has else clause. (FALSE)

9. Python loops can also have else clause. (TRUE)

10. In a Python program, if a break statement is given in a nested loop, it terminates the
execution of all loops in one go. (FALSE)

You might also like