Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise For/While Loops: Write a short program that prints the numbers 1 to 10 using a for loop. Then write an equivalent program that prints

Exercise For/While Loops:

Write a short program that prints the numbers 1 to 10 using a for loop. Then write an equivalent program that prints the numbers 1 to 10 using a while loop.

------------------------------------------------------------

Exercise 7-4:

Pizza Toppings: Write a loop that prompts the user to enter a series of pizza toppings until they enter a 'quit' value.

As they enter each topping, print a message saying youll add that topping to their pizza.

------------------------------------------------------------

Exercise 7-5:

Movie Tickets: A movie theater charges different ticket prices depending on a persons age.

If a person is under the age of 3, the ticket is free;

if they are between 3 and 12, the ticket is $10; and

if they are over age 12, the ticket is $15.

Write a loop in which you ask users their age, and then tell them the cost of their movie ticket.

------------------------------------------------------------

Exercise 7-6:

Three Exits: Write different versions of Exercise 7-5 that do each of the following at least once:

Use a conditional test in the while statement to stop the loop.

Use an active variable to control how long the loop runs.

Use a break statement to exit the loop when the user enters a 'quit' value.

------------------------------------------------------------

Exercise 7-7:

Infinity: Write a loop that never ends, and run it. (To end the loop, press ctrl-C or close the window displaying the output.

------------------------------------------------------------

i need the correct python codes fast please

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

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago