Coding Journey with Python
1) Which of the following is not a decision-making statement.
A. if-elif statement
B. for statement
C. if -else statement
D. if statement
2) Given the nested if-else below, what will be the value x when the code
executed successfully
a) 0
b) 4
c) 2
d) 3
3) Which one of the following is a valid Python if statement.
a) if a>=2 :
b) if (a >= 2)
c) if (a => 22)
d) if a >= 22
1
4) What is the output of the given below program?
if 1 + 3 == 7:
print("Hello")
else:
print("Know Program")
a) Hello
b) Know Program
c) Compiled Successfully, No Output.
d) Error
5) What is the output of the given below program?
if 3 + 4 == 7:
print("Hi")
else:
print("Know Program")
print("Hello")
a) Hi
b) Know Program
c) Hi
Hello
d) Know Program
Hello
6) Find the output of the given Python program?
a, b, c = 1, 3, 5
if a > 0:
if b < 2:
print("Hi")
elif c > 3:
print("Hello")
else:
2
print("Know Program")
a) Hi
b) Hello
c) Know Program
d) Compiled Successfully, No Output.
7) Which of the following is not a boolean expression?
A. True
B. 3 == 4
C. 3 + 4
D. 3 + 4 == 7
8) What does the following code print?
if 4 + 5 == 10:
print("TRUE")
else:
print("FALSE")
print("TRUE")
a. TRUE
b.
TRUE
FALSE
c.
FALSE
TRUE
d.
TRUE
FALSE
TRUE
9) What is the total for 12 items that weight 3 pounds?
weight = 0.5 #3
3
numItems = 5 #12
if weight < 1:
price = 1.45
if weight >= 1:
price = 1.15
total = weight * price
if numItems >= 10:
total = total * 0.9
print(weight)
print(price)
print(total)
A. $3.45
B. $3.11
C. $3.105
D. $3.10
10) Which one of the following is a invalid Python if statement :
A. if a>=2 :
B. if (a >= 2):
C. if (a => 22):
D. none of the above: