Font size
WorksheetsL244P1 Basic Pyton Programming
Total questions: 20
Worksheet time: 10hrs 31mins
a = 2
b = 330
print("A") if a > b else print("B")
What is the Output?
A
B
Error
AB
Which of the following is the correct extension of the Python file?
.py
.python
.pyt
.exe
What will be the value of the following Python expression?
4 + 3 % 5
7
2
4
0
Which of the following is used to define a block of code in Python language?
{
}
[ ]
()
Indendation
Which of the following character is used to give single-line comments in Python?
/
//
///
#
What will be the output of the following Python code snippet if x=1?
x<<2
8
2
4
1
>>>what is the output of range(2,10,2)
1,3,5,6,7
2,4,6,8,10
2,4,6,8
2,4,6
Which one of the following is correct way of declaring and initializing a variable, x with value 5?
int x
x=5
int x=5
x=5
declare x=5
Which of the operator means less than equal to ?
>
<
>=
<=
else: is used
to give an extra condition
to provide an output when the other conditions are false
because it is required
if we do not use it, it gives error
Sonam has written this program in Python. One of the lines contains at least one error. Which line is it?
print(“Hello world!”)
name=input(‘please enter your name’)
print(happy to meet you)
print(‘you have great name’)
An instruction is written to determine if the value in a is equal to the value in b.
Choose the correct operator to complete the instruction:
if a ______ b:
<--
=
==
Choose the operators to represent "not equal to" in PYTHON
<>
/=
Not=
!=
What is the output of the following:
a=2
b=3
c=4
a=b
b=a
c=b
print(c)
(a)
What is the result of the following:
x = 10
m = x % 4
print (m)
(a)
A statement in the program that is not executed and can explain to another programmer what the code is about
(a)
Which of the following is the correct way to create a list in Python?
list = <1, 2, 3>
list = (1, 2, 3)
list = [1, 2, 3]
list = {1, 2, 3}
What is the output of the following code snippet?
for i in range(3):
print(i)
0 1 2 3
0 1
1 2 3
0 1 2
What will be the output of the following Python code snippet?
print(type(5.0))
str
NoneType
float
int
What is the output of the following code snippet?
for i in range(1, 5):
print(i * 2)
1 2 3 4
2 4 6 8
2 3 4 5
1 3 5 7
