Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Sample Assignment Write a program that asks the user for a number that is positive. If the number entered is not positive, then an error message is displayed, and the user is prompted to enter another...

1 answer below »
Sample Assignment
Write a program that asks the user for a number that is positive. If the number entered is not positive, then an e
or message is displayed, and the user is prompted to enter another number. This validation will continue until the user enters a valid positive number. When the user enters a valid number then the program prints to the console all cube values1 to the number the user entered.Show screen shots of the PYTHON program, all input and output. Save this program.
Below is the input/output that you are to use for this problem:
Enter a positive number starting number: -3
So
y, -3 is not a positive number. Try again!
Enter a positive number starting number: 0
So
y, 0 is not a positive number. Try again!
Enter a positive number starting number: -7
So
y, -7 is not a positive number. Try again!
Enter a positive number starting number: 10
1 and cube of 1 is: 1
2 and cube of 2 is: 8
3 and cube of 3 is: 27
4 and cube of 4 is: 64
5 and cube of 5 is: 125
6 and cube of 6 is: 216
7 and cube of 7 is: 343
8 and cube of 8 is: 512
9 and cube of 9 is: 729
10 and cube of 10 is: 1000
Finished!
PLACE SCREEN SHOTS OF THE PYTHON CODE AND ALL I/O BELOW.
Write a program that asks the user for a number no greater than 12 and no less than 3. Based on the number the user enters create a square where the number entered is the length of the square. If an invalid value is given, print out an e
or and prompt the user to try again.After displaying the square, ask the user if they want to create another square. Use ‘Y’ or ‘Yes’ as the co
ect response to continue or ‘N’ or ‘No’ to quit. Anything else is invalid and the user should be notified and asked to re-enter their selection.When the program has ended output the number of squares created.
Here's theinput/output to use to show your program works:
Enter a number between 3 and 12: 1
So
y,1 is not in the range of 3 and 12. Try Again!
Enter a number between 3 and 12: 20
So
y,20 is not in the range of 3 and 12. Try Again!
Enter a number between 3 and 12: -15
So
y,-15 is not in the range of 3 and 12. Try Again!
Enter a number between 3 and 12: 3
Here is your square!
XXX
XXX
XXX
Would like to create another? (Enter Y or Yes to continue or N or No to Quit)
yes
‘yes’ is not a valid response. Please try again!
Would like to create another? (Enter Y or Yes to continue or N or No to Quit)
Yes
Enter a number between 3 and 12: 50
So
y,50 is not in the range of 3 and 12. Try Again!
Enter a number between 3 and 12: 4
Here is your square!
XXXX
XXXX
XXXX
Would like to create another? (Enter Y or Yes to continue or N or No to Quit)
NO
‘NO’ is not a valid response. Please try again!
Would like to create another? (Enter Y or Yes to continue or N or No to Quit)
N
Thank you, you created 2 squares before quitting.
Comment your source code and describe your code to someone who may be viewing it for the first time.
PLACE SCREEN SHOTS OF THE PYTHON CODE AND ALL I/O BELOW.
PLACE SCREEN SHOTS OF THE PYTHON CODE AND ALL I/O BELOW.
Answered 1 days After Jun 30, 2021

Solution

Sushma answered on Jul 02 2021
161 Votes
Solution_Id_87366/assignment_4.docx
1. Write a program that asks the user for a number that is positive. If the number entered is not positive, then an e
or message is displayed, and the user is prompted to enter another number. This validation will continue until the user enters a valid positive number. When the user enters a valid number then the program prints to the console all cube values1 to the number the user entered. Show screen shots of the PYTHON program, all input and output. Save this program.
Below is the input/output that you are to use for this problem:
Enter a positive number starting number: -3
So
y, -3 is not a positive number. Try again!
Enter a positive number starting number: 0
So
y, 0 is not a positive number. Try again!
Enter a positive number starting number: -7
So
y, -7 is not a positive number. Try again!
Enter a positive number starting number: 10
1 and cube of 1 is: 1
2 and cube of 2 is: 8
3 and cube of 3 is: 27
4 and cube of 4 is: 64
5 and cube of 5 is: 125
6 and cube of 6 is: 216
7 and cube of 7 is: 343
8 and cube of 8 is: 512
9 and cube of 9 is: 729
10 and cube of 10 is: 1000
Finished!
PLACE SCREEN SHOTS OF THE PYTHON CODE AND ALL I/O BELOW.
Code: -
(
# Define the cube fuction to calculate cube of numbe
def cube(num):

for i in range(1,num+1):
print(i," and cube of",i,' is:', i**3,)
print('Finished !')

while 1:
num = int(input("Enter a positive number starting number: ")) # take input from the use
if num > 0: # any number which more than zero is positive number.
cube(num)

eak
print("So
y", num,"is not a positive number. Try again!")
)
Output: -
(
Enter a positive number starting number: 0
So
y 0 is not a positive number. Try again!
Enter a positive number starting number: -5
So
y -5 is not a positive number. Try again!
Enter a positive number starting number: 7
1 and cube of 1 is: 1
2 and cube of 2 is: 8
3 and cube of 3 is: 27
4 and cube of 4 is: 64
5 and cube of 5 is: 125
6 and cube of 6 is: 216
7 and cube of 7 is: 343
Finished !
)
2. Write a program that asks the user for a number no greater than 12 and no less than 3. Based on the number the user enters create a square where the number entered is the length of the square. If an invalid value is given, print out an e
or and prompt the user to try again. After displaying the square, ask the user if they want to create another square. Use ‘Y’ or ‘Yes’ as the co
ect response to continue or ‘N’ or ‘No’ to quit. Anything else is invalid and...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here