Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write and test the program using IDLE or PyCharm. Then upload it here for testing and submission. Write a Python program (counting_box.py) to output a

Write and test the program using IDLE or PyCharm.

Then upload it here for testing and submission.

Write a Python program (counting_box.py) to output a counting box of even numbers. The program should prompt the user for these inputs, in exactly this order: the width of the box and the height of the box. Your program needs to make sure the inputs are greater than zero.

Your program should contain two functions:

(1) print_box(width, height): This function takes in width and height (both integers greater than zero), and prints counting box, no return statement in this function. Using this width and height, the function will print out a box where there are width numbers on each line and height rows. All numbers are even and must count up starting from 0. It should continue counting up (do not restart the numbering). (Submit for 5 points)

(2) __main__: In the main, you do the following: (Submit for 5 points)

a. Prompt the user to input the width. Reprompt the user if width is 0 or less. Hint: use a while loop.

b. Prompt the user to input the height. Reprompt the user if height is 0 or less. Hint: use a while loop.

c. Call print_box(width, height) and pass to it the values entered above.

Hint: You can keep the print() function from printing on a new line by using end=" " at the end: print("Hello", end=" "). If you do want to print a new line, you can call print without an argument: print().

Note: When printing the numbers, use this format '{:

Here are some example runs of the program:

image text in transcribed

Example 1: All values entered by the user are greater than 0. Please enter a width greater than 0: 5 Please enter a height greater than 0: 3 0 2 4 6 10 12 14 16 18 20 22 24 26 28 Example 2: The user entered values less than or equal to 0 Please enter a width greater than 0: 0 Please enter a width greater than 0: Please enter a height greater than 0: -1 Please enter a height greater than 0: 6 0 2 4. 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago