IDLE
PYCHARM
JUPYTER-NOTEBOOK
ECLIPSE
Thonny
100

if 5 > 2:
print("Five is greater than two!") 

What is the output?

syntax error

100

1. Who developed Python Programming Language?
a) Wick van Rossum
b) Rasmus Lerdorf
c) Guido van Rossum
d) Niene Stom

c) Guido van Rossum

100

2. Which type of Programming does Python support?
a) object-oriented programming
b) structured programming
c) functional programming
d) all of the mentioned

d) all of the mentioned

100

3. Is Python case sensitive when dealing with identifiers?
a) no
b) yes
c) machine dependent
d) none of the mentioned

Answer: a
Explanation: Case is always significant.

100

4. Which of the following is the correct extension of the Python file?
a) .python
b) .pl
c) .py
d) .p

Answer: c
Explanation: ‘.py’ is the correct extension of the Python file. Python programs can be written in any text editor. To save these programs we need to save in files with file extension ‘.py’.

200

Is Python code compiled or interpreted?
a) Python code is both compiled and interpreted
b) Python code is neither compiled nor interpreted
c) Python code is only compiled
d) Python code is only interpreted

Answer: b
Explanation: Many languages have been implemented using both compilers and interpreters, including C, Pascal, and Python.

200

6. All keywords in Python are in _________
a) Capitalized
b) lower case
c) UPPER CASE
d) None of the mentioned

Answer: d
Explanation: True, False and None are capitalized while the others are in lower case.

200

What will be the value of the following Python expression?

4 + 3 % 5

Answer: a
Explanation: The order of precedence is: %, +. Hence the expression above, on simplification results in 4 + 3 = 7. Hence the result is 7.

200

Which of the following is used to define a block of code in Python language?
a) Indentation
b) Key
c) Brackets
d) All of the mentioned

Answer: a
Explanation: In Python, to define a block of code we use indentation. Indentation refers to whitespaces at the beginning of the line.

200

Which keyword is used for function in Python language?
a) Function
b) Def
c) Fun
d) Define

b) Def

300

Which of the following character is used to give single-line comments in Python?
a) //
b) #
c) !
d) /*

Answer: b
Explanation: To write single-line comments in Python use the Numero sign (#) at the beginning of the line. To write multi-line comments, close the text between triple quotes.
Example: “”” comment
text “””

300

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
b) error
c) 1 2
d) none of the mentioned

Answer: b
Explanation: SyntaxError, there shouldn’t be a space between + and = in +=.

300

Which of the following functions can help us to find the version of python that we are currently working on?
a) sys.version(1)
b) sys.version(0)
c) sys.version()
d) sys.version

Answer: a
Explanation: The function sys.version can help us to find the version of python that we are currently working on. For example, 3.5.2, 2.7.3 etc. this function also returns the current date, time, bits etc along with the version.

300

Python supports the creation of anonymous functions at runtime, using a construct called __________

a) pi
b) anonymous
c) lambda
d) none of the mentioned  

Answer: c
Explanation: Python supports the creation of anonymous functions (i.e. functions that are not bound to a name) at runtime, using a construct called lambda. Lambda functions are restricted to a single expression. They can be used wherever normal functions can be used.

300

What is the order of precedence in python?
a) Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
b) Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
c) Parentheses, Exponential, Multiplication, Division, Subtraction, Addition
d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction

Answer: d
Explanation: For order of precedence, just remember this PEMDAS (similar to BODMAS).

400

What will be the output of the following Python code snippet if x=1?

x<<2

a) 4
b) 2
c) 1
d) 8

Answer: a
Explanation: The binary form of 1 is 0001. The expression x<<2 implies we are performing bitwise left shift on x. This shift yields the value: 0100, which is the binary form of the number 4.

400

What does pip stand for python?
a) unlimited length
b) all private members must have leading and trailing underscores
c) Preferred Installer Program
d) none of the mentioned

Answer: c
Explanation: Variable names can be of any length.

400

Which of the following is true for variable names in Python?
a) underscore and ampersand are the only two special characters allowed
b) unlimited length
c) all private members must have leading and trailing underscores
d) none of the mentioned

Answer: b
Explanation: Variable names can be of any length.

400

What are the values of the following Python expressions?

 2**(3**2) (2**3)**2 2**3**2

a) 512, 64, 512
b) 512, 512, 512
c) 64, 512, 64
d) 64, 64, 64

Answer: a
Explanation: Expression 1 is evaluated as: 2**9, which is equal to 512. Expression 2 is evaluated as 8**2, which is equal to 64. The last expression is evaluated as 2**(3**2). This is because the associativity of ** operator is from right to left. Hence the result of the third expression is 512.

400

Which of the following is the truncation division operator in Python?
a) |
b) //
c) /
d) %

Answer: b
Explanation: // is the operator for truncation division. It is called so because it returns only the integer part of the quotient, truncating the decimal part. For example: 20//3 = 6.

500

Which of the following functions is a built-in function in python?
a) factorial()
b) print()
c) seed()
d) sqrt()

Answer: b
Explanation: The function seed is a function which is present in the random module. The functions sqrt and factorial are a part of the math module. The print function is a built-in function which prints a value directly to the system output.

500

Which of the following is the use of id() function in python?
a) Every object doesn’t have a unique id
b) Id returns the identity of the object
c) All of the mentioned
d) None of the mentioned

Answer: b
Explanation: Each object in Python has a unique id. The id() function returns the object’s id.

500

Which of the following is not a core data type in Python programming?
a) Tuples
b) Lists
c) Class
d) Dictionary

Answer: c
Explanation: Class is a user-defined data type.

500

Which of these is the definition for packages in Python?
a) A set of main modules
b) A folder of python modules
c) A number of files containing Python definitions and statements
d) A set of programs making use of Python modules

Answer: b
Explanation: A folder of python programs is called as a package of modules.

500

Which one of the following is not a keyword in Python language?
a) pass
b) eval
c) assert
d) nonlocal

Answer: b
Explanation: eval can be used as a variable.

M
e
n
u