Python consists of various logical and conditional operators and statements as well. We also have comments available to us in Python. All good developers have a habit of documenting their code. To document the code, we mostly use the comments and if the documentation is to be on an enterprise-level, we create separate documentation.
Let us now start our quiz on statements and comments in Python.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Which of the following are possible reasons for using comments in Python?
Correct
Incorrect
Question 2 of 15
2. Question
What will be the result of the following code?
val1 = 23
val2 = 23.0
if val1 == val2:
print(“Matched values!”)
elif val1 > val2:
print(“Val1 is larger.”)
elif val2 > val1:
print(“Val2 is larger.”)
else:
print(“Mismatched Values”)
Correct
Incorrect
Question 3 of 15
3. Question
Write the output of the following code in Python? name = “QuizOrbit” ”’Ace your skils”’ print(“Welcome to – “, name)
Correct
Incorrect
Question 4 of 15
4. Question
Which of the following is a loop statement in python?
Correct
Incorrect
Question 5 of 15
5. Question
What is the error in the below code?
for i range(0,10):
print(i)
Correct
Incorrect
Question 6 of 15
6. Question
Which of the below code is not correct:
Correct
Incorrect
Question 7 of 15
7. Question
Point out the error in the below code.
i = 10
if i = 10 :
print(“Value of i is 10.”)
Correct
Incorrect
Question 8 of 15
8. Question
Which of the following is a logical operator in Python?
Correct
Incorrect
Question 9 of 15
9. Question
Select the correct output of the below code? number = 123 print(123<<1)
Correct
Incorrect
Question 10 of 15
10. Question
Which of the below Python statement gives a boolean output?
Correct
Incorrect
Question 11 of 15
11. Question
Find the output of the below code?
value = 230
while(value>112):
print(value)
value = value>>1
Correct
Incorrect
Question 12 of 15
12. Question
What will be the output of the below code?
val1 = 100
val2 = 23
if val1 ^ val2 :
print(val1 ^ val2)
else:
print(“We lost!”)
Correct
Incorrect
Question 13 of 15
13. Question
Which of the following is a valid Python statement?
Correct
Incorrect
Question 14 of 15
14. Question
Find the output of code given below:
val1 = 78
val2 = 0
try:
val1 = val1/val2
print(“Try block is run.”)
except:
print(“Catch is run!”)
Correct
Incorrect
Question 15 of 15
15. Question
How many spaces is an indentation made of in python?
Correct
Incorrect
Summary
With this, we have come to an end to the Python quiz for Statements, Indentation and Comments. We have plenty of concepts in Python which you need to know to master the language, and statements is the start of all of them. For more details on each of them don’t forget to refer to the tutorials.
At QuizOrbit, our team specializes in fun, informative quizzes across topics like general knowledge, technology, and entertainment. Boost your knowledge with our expert-designed quizzes.