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

Sample Assignment Assignment 4 Name: ___________________________ CSC-1110 Section: ______ Assignment 4 COMPLETE THE HONOR CODE BELOW HONOR CODE: I pledge that this program represents my own program...

1 answer below »
Sample Assignment
Assignment 4
Name: ___________________________
CSC-1110
Section: ______
Assignment 4
COMPLETE THE HONOR CODE BELOW
HONOR CODE:
I pledge that this program represents my own program code, I have received help from no one and I have given help to no one.
OR
I received help from NAME OR NO ONE in designing and debugging my program.
I have given help to NAME OR NO ONE in designing and debugging my program.
This assignment is required.
The grading form shows point values for this assignment. Please review it now.
Show screen shots of the python code with comments and your input/output window.
You should use several well-planned sets of data to check out your program. Testing your programs with just the data that is asked for in the assignment does not necessarily mean that the programs will work for all cases.
Please include the following comments in each of your Python programs:
Your Name
Section
Date
Description
Assignment Numbe
A python template (python_template.py) has been provided for you to use.
Name this document XXX_Assignment 4 where XXX are your initials. Include a python file named P01.py, P02.py, etc. for each problem.
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 values 1 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 the input/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.
Write a program that asks a user to enter a starting value. Then the program will ask for an operation to perform on that number. The available operations are add, subtract, multiply, and division. The program will make sure a valid operation is selected. If there is not a valid operation chosen, then the program will notify the user and keep asking. When a valid operation is chosen then the user is asked to enter a number to perform the operation. The result of the operation is output to the screen and the user is prompted to enter the next operation to perform on the result followed by the value to use. The program will continue until a sentinel value of -999 is input.
Below is the input/output that you are to use.
Enter your starting number: -157
Enter A for Add, S for Subtract, M for multiply, or D for Divide to perform on -157 or enter -999 to end: add
So
y, ‘add’ is not a valid operation. Try Again!
Enter A for Add, S for Subtract, M for multiply, or D for Divide to perform on -157 or enter -999 to end: Add
So
y, ‘Add’ is not a valid operation. Try Again!
Enter A for Add, S for Subtract, M for multiply, or D for Divide to perform on -157 or enter -999 to end: A
Add -157 with what value: 357
The result is 200
Enter A for Add, S for Subtract, M for multiply, or D for Divide to perform on 200 or enter -999 to end: divide
So
y, ‘divide’ is not a valid operation. Try Again!
Enter A for Add, S for Subtract, M for multiply, or D for Divide to perform on 200 or enter -999 to end: Divide
Divide 200 with what value: 100
The result is 2
Enter A for Add, S for Subtract, M for multiply, or D for Divide to perform on 200 or enter -999 to end: -999
Program ended with a result of 2
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.
Answered 18 days After Feb 10, 2021

Solution

Sahil answered on Mar 01 2021
142 Votes
P01.py
"""
Name:-
Section:-
Date:-
Description:-
Assignment Number:-
"""
# this is the main function of the program that is executing the instructions
def main():
flag = True
while flag:
cu
entNum = int(input("Enter a positive number starting number:\n"))
flag = False if cu
entNum > 0 else True
if flag is True:
print("So
y, %d is not a positive number. Try again!"%cu
entNum)
print(cu
entNum)
print()
for cu
entVal in range(1, cu
entNum+1):
print("%d and cube of %d is: %d"%(cu
entVal, cu
entVal, cu
entVal ** 3))
print("Finished!")
return
# calling the main function
if __name__ == "__main__":
main()
P02.py
"""
Name:-
Section:-
Date:-
Description:-
Assignment Number:-
"""
# this is the main function of the program that is executing the instructions
def main(count):
flag = True
# while flag is True that means we are not getting a number in between 3 and 12
while flag:
# taking input
cu
entNum = int(input("Enter a number between 3 and 12: "))
# changing flag
flag = False if cu
entNum >= 3 and cu
entNum <= 12 else True
# if flag is still true, that means we need to take the input again
if flag:
print("\nSo
y, %d is not in the range of 3 and 12."%cu
entNum)
print("Try Again!")
print("Here is your square!\n")
# print the square co
esponding to the value entered by use
for row in range(cu
entNum):
print('X' * cu
entNum)
flag = True
count[0] += 1
# go for second input till the point user is not entering a valid value
while flag:
cu
entInput = input("\n WouLd like to create another? (Enter Y or Yes to continue or N or No to Quit)\n")
# checking the conditions of the valid input, if none is there that means we have a invalid input
tempVal = not (cu
entInput == 'Y' or cu
entInput == 'Yes' or cu
entInput == 'N' or cu
entInput == 'No')
# change value as per tempVal
flag = True if tempVal else False
# if value entered is invalid print it, and try again
if flag:
print("'%s', is not a valid response. Please try again!"%cu
entInput)
continue
# if value entered is a 'Y' or a 'Yes' call the function recursively
if cu
entInput == 'Y' or cu
entInput == 'Yes':
main(count)
return
# calling the main function
if __name__ == "__main__":
# variable to take care that how many times this function is called
count = [0]
# calling main
main(count)
print("Thank you, you created %d squares before quitting."%count[0])
P03.py
"""
Name:-
Section:-
Date:-
Description:-
Assignment Number:-
"""
# this is the main function of the program that is executing the instructions
def main():
# taking input
cu
entNum = int(input("Enter your starting number: "))
# declaring a flag variable to keep track the times we have to take input
flag = True
while flag:
# taking the operation as input
secondInput = input("Enter A for Add, S for Subtract, M for...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here