use python 3 computer science i lab 9 objectives work with for loops assignment use 5155039
USE PYTHON 3
Computer Science I Lab 9
Objectives
Work with for loops
Assignment – Use Python
Name the file for this part lab9a_abc.py, where abc are your initials.
This part will draw an outline of a rectangle on the screen using “*”. The code written in part c of the in class lab should help with this assignment. I suggest creating a variable which stores the character to be written to the screen. This will make it easier to make changes to the code in the future. Something like:
symbol = “*”
Ask the user for a width and a height for the rectangle. ONLY accept values between 1 and 20 for the width and between 1 and 10 for the height. If any number entered falls outside of the valid range, ask the user to reenter the value.
A sample of running the program, where the width is 8 and the height is 6, might be:
Please enter the width: 8 Please enter the height: 30 The height must be between 1 and 10 Please enter the height: 20 The height must be between 1 and 10 Please enter the height: 6
******** ** ** ** ** ********
Part B
Name the file for this part lab9b_abc.py, where abc are your initials.
Write a program that creates a small, single value multiplication table. The program will ask for a value between 1 and 10. If the value is less than 1 or greater than 10, display an error message stating that the input is invalid and end the program.
If the input is valid, display a table that shows the results of multiplying the input value times the numbers one through ten. Make all the columns of numbers be right justified. Write a label for the table at the top of the table.
For example: Enter a number between 1 and 10: 5 Multiplication table for 5
1*5= 5 2 * 5 = 10 3 * 5 = 15 4 * 5 = 20 5 * 5 = 25 6 * 5 = 30 7 * 5 = 35 8 * 5 = 40 9 * 5 = 45
10 * 5 = 50