NEW
Font size
WorksheetsPython
Total questions: 25
Worksheet time: 13mins
Which of the following is the correct extension of the Python file?
.python
.pl
.py
.p
Is Python code compiled or interpreted?
Python code is both compiled and interpreted
Python code is neither compiled nor interpreted
Python code is only compiled
Python code is only interpreted
What will be the value of the following Python expression?
print(4 + 3 % 5)
7
2
4
1
Which of the following is used to define a block of code in Python language?
Indentation
Key
Brackets
All of the mentioned
Which of the following character is used to give single-line comments in Python?
//
#
!
/*
Which of the following is true for variable names in Python?
underscore and ampersand are the only two special characters allowed
unlimited length
all private members must have leading and trailing underscores
none of the mentioned
What will be the output of the following Python statement?
print("a"+"bc")
bc
abc
a
bca
What are arithmetic operators in Python?
*
-
+
All
What is the average value of the following Python code snippet?
grade1 = 80
grade2 = 90
average = (grade1 + grade2) / 2
print(average)
85.0
85.1
95.0
95.1
What is a correct syntax to output "Hello World" in Python?
print("Hello World")
p("Hello World")
echo("Hello World")
echo "Hello World"
Which one is NOT a legal variable name?
Myvar
my_var
my-var
_myvar
How do you create a variable with the numeric value 5?
x=5
x=int(5)
Both a & b
none of the above
What is the correct syntax to output the type of a variable or object in Python?
print(typeOf(x))
print(type(x))
print(typeof(x))
print(typeof x)
Which operator can be used to compare two values?
=
==
<>
><
How do you start writing an if statement in Python?
if x>y then:
if (x>y)
if x>y :
None of the above
What does the following expression return?
not (True and False)
True
False
Error
None
What will be printed by the following code?
x = 5
x += 3
print(x)
5
3
8
15
What does the following expression return in Python 3?
5 / 2
2
2.5
2.0
Error
What does the += operator do?
Assigns a value
Adds and reassigns
Compares values
Increments without assignment
What is the result of 5 ^ 3? (bitwise XOR)
6
7
2
1
What is 5 // 2 in Python 3?
0
1
2
3
What is the result of:
True and False
True
False
Error
None
What is the result of 2 & 4 | 1?
1
0
5
3
What is the binary number of 5?
111
001
101
011
what is the decimal form of binary number 1010?
7
8
10
5
