Python Programming Question and Answers – Decorators
Q 1. In the following Python code, which function is the decorator? def mk(x): def mk1(): print(“Decorated”) x() return mk1 def mk2(): print(“Ordinary”) p = mk(mk2) p() A. p()B. mk()C. mk1()D. mk2() Show Answer Answer:-B. mk()…
Python Quizs Question and Answers – Bitwise – 2
Q 1. It is not possible for the two’s complement value to be equal to the original value in any case.A. TrueB. False Show Answer Answer:-B. False Explanation In most cases the value of two’s complement is different from the original value. However, there…
Python Quizs Question and Answers – Bitwise – 2
Q 1. It is not possible for the two’s complement value to be equal to the original value in any case.A. TrueB. False Show Answer Answer:-B. False Explanation In most cases the value of two’s complement is different from the original value. However, there…
Python Questions and Answers – Bitwise – 1
Q 1. What will be the output of the following Python code snippet if x=1? x<<2 A. 8B. 1C. 2D. 4 Show Answer Answer:-D. 4 Explanation The binary form of 1 is 0001. The expression x<<2 implies we are performing bitwise left shift on x. This…
Python Quizs Question and Answers Precedence and Associativity – 2
Q 1. What will be the output of the following Python expression? print(4.00/(2.0+2.0)) A. ErrorB. 1.0C. 1.00D. 1 Show Answer Answer:-B. 1.0 Q 2. What will be the value of X in the following Python expression? X = 2+9*((3*12)-8)/10 A. 30.0B. 30.8C. 28.4D.…
Python Quizs Question and Answers Precedence and Associativity – 1
Q 1. The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the same.A. TrueB. False Show Answer Answer:-A. True Explanation Explanation:- Although the presence of parenthesis does affect the order of precedence, in the case shown above, it is not…
Python Quizs Question and Answers – Basic Operators
Q 1. Which is the correct operator for power(xy)?A. X^yB. X**yC. X^^yD. None of the mentioned Show Answer Answer:-B. X**y Explanation Explanation:- In python, power operator is x**y i.e. 2**3=8. Q 2. Which one of these is floor division?A. /B. //C. %D.…
Python Quizs Question and Answers – Variable Names
Q 1. Is Python case sensitive when dealing with identifiers?A. machine dependentB. noC. yesD. none of the mentioned Show Answer Answer:-C. yes Explanation Explanation:- Case is always significant while dealing with identifiers in python. Q 2. What is the…
Python Questions and Answers – Numeric Types
Q 1. What is the output of print 0.1 + 0.2 == 0.3?A. TrueB. FalseC. Machine dependentD. Error Show Answer Answer:-B. False Explanation Explanation:- Neither of 0.1, 0.2 and 0.3 can be represented accurately in binary. The round off errors from 0.1 and…
Python Quizs Question and Answers – Core Data Types
Q 1. Which of these in not a core data type?A. ListsB. DictionaryC. TuplesD. Class Show Answer Answer:-D. Class Explanation Explanation:- Class is a user defined data type. Q 2. Given a function that does not return any value, What value is thrown by…