100% satisfaction guarantee Immediately available after payment Read online or as PDF No strings attached 4.6 TrustPilot
logo-home
Exam (elaborations)

python control strucures questions with correct answers.

Rating
-
Sold
-
Pages
6
Grade
A+
Uploaded on
25-03-2026
Written in
2025/2026

python control structures

Institution
Probability
Course
Probability

Content preview

Python Control Structures Quiz

1. What is the last thing printed by the following program?

start = 30 stop = 10 for I in range(start, stop - 1, -5): if I % 2 == 0: print(I *

2) else: print(I): 20

2. We want to simulate constantly flipping a coin until we get 3 heads in a

row. What kind of loop should we use?: While Loop

3. How many times will the following program print "hello"?: This code will loop

infinitely

4. The following code continually asks the user for a password until they

guess the correct password, then ends. But there is one problem.: Add a break; statement

after line 6 so that the program doesn't loop infinitely

5. What will the following program print when

run? for j in range(2): for I in range(6, 4, -1):

print (): 6

5

6

1/
6

, 5

6. What is the value of the Boolean variable can_ vote at the end of this

program?



age = 17 is _citizen = True can _vote = age >= 18 and is citizen: False

7. What will be the output of this program?




number = 5 greater_ than _zero = number > 0 if greater_ than _zero:

print(number): 5

8. What will be the output of this program?




number = 5 greater than zero = number > 0 if greater than zero: if number >

5: print(number): Nothing will print

9. What is printed by the following program?




Is raining = False is _cloudy = False is_ sunny = not is _raining and not is_ cloudy

is _summer = False is_ warm = is _sunny or is _summer print("Is it warm: " +
2/
6

Written for

Institution
Probability
Course
Probability

Document information

Uploaded on
March 25, 2026
Number of pages
6
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$12.89
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Read online or as PDF
No strings attached

Get to know the seller
Seller avatar
smartthinker1
4.0
(2)

Get to know the seller

Seller avatar
smartthinker1 Walden University
View profile
Follow You need to be logged in order to follow users or courses
Sold
4
Member since
2 year
Number of followers
3
Documents
927
Last sold
1 year ago

4.0

2 reviews

5
1
4
0
3
1
2
0
1
0

Trending documents

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions