Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Questions 1. In the following code, what is the iteration variable? there is none, cnt or country cnt = 0 for country in [Canada,Mexico,

Python Questions

1.

In the following code, what is the iteration variable? there is none, cnt or country

cnt = 0 for country in ["Canada","Mexico", "United States"]: cnt = cnt + 1 print(cnt)

2.

This code should repeatedly print whatever the user enters, until the user enters "done" (no quotes). It should *not* print the word "done" though.

while True: # line 1 w = input("> ") # line 2 print(w) # line 3

To make it work correctly we need to add the following code:

if w == "done": break

Where should we add this code?

before line 1

after line 1

after line 2

after line 3

3. Fill in the blank in this code so it prints the sequence 10, 5, 0. Use the fewest spaces that makes a legal Python statement.

y = 10

while y >= 0:

print(y)

___________

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions