Python Questions and Answers – While and For Loops – 5
This set of Python Questions & Answers focuses on “While and For Loops” and is useful for experienced people who are preparing for their interviews.
1. What is the output of the following?
a) 0.0 1.0
b) 0 1
c) error
d) none of the mentioned
View Answer
b) 0 1
c) error
d) none of the mentioned
View Answer
2. What is the output of the following?
a) 0.0 1.0
b) 0 1
c) error
d) none of the mentioned
View Answer
b) 0 1
c) error
d) none of the mentioned
View Answer
3. What is the output of the following?
a) 0.0 0.1 0.2 0.3 …
b) 0 1 2 3 …
c) 0.0 1.0 2.0 3.0 …
d) none of the mentioned
View Answer
b) 0 1 2 3 …
c) 0.0 1.0 2.0 3.0 …
d) none of the mentioned
View Answer
4. What is the output of the following?
advertisements
b) 0 1 2 3 …
c) 0.0 1.0 2.0 3.0 …
d) none of the mentioned
View Answer
5. What is the output of the following?
a) 1 2 3 4
b) 4 3 2 1
c) error
d) none of the mentioned
View Answer
b) 4 3 2 1
c) error
d) none of the mentioned
View Answer
6. What is the output of the following?
a) a b c d
b) d c b a
c) error
d) none of the mentioned
View Answer
b) d c b a
c) error
d) none of the mentioned
View Answer
7. What is the output of the following?
a) a b c d
b) d c b a
c) error
d) none of the mentioned
View Answer
b) d c b a
c) error
d) none of the mentioned
View Answer
advertisements
a) None
b) (nothing is printed)
c) error
d) none of the mentioned
View Answer
b) (nothing is printed)
c) error
d) none of the mentioned
View Answer
9. What is the output of the following?
a) 0 1 2 3 4 …
b) 0 1
c) 3 4
d) 0 1 2 3
View Answer
b) 0 1
c) 3 4
d) 0 1 2 3
View Answer
10. What is the output of the following?
a) 0 1 2 3 4 …
b) 0 -2
c) 0
d) error
View Answer
b) 0 -2
c) 0
d) error
View Answer
Answer: b
Explanation: The loop is entered twice.
Explanation: The loop is entered twice.
No comments:
Post a Comment