Assessment#1 My biggest issue was creating a loop to cycle my program once executed so my users can restart within, rather than closing and re-launching it. I tested my loop() code which works on its...

1 answer below »
Provide feedback in paragraph form on the 2 assessments provided in order to improve the code.


Assessment#1 My biggest issue was creating a loop to cycle my program once executed so my users can restart within, rather than closing and re-launching it. I tested my loop() code which works on its own, works with selecting the count down, but errors when running the factorial. Any insight? print("---------------Loops & Functions---------------") def countdown(): count_down = integer while (count_down >= 0): print(count_down) count_down -= 1 def factorial(): global integer factorial = 1 if integer < 0:="" print("factorial="" will="" not="" define="" for="" a="" negative="" number")="" elif(integer="=" 0):="" print("the="" factorial="" of="" 0="" is="" 1")="" else:="" while(integer=""> 0): factorial = factorial * integer integer -= 1 print("factorial of the given number is: ") print("-----------------------------------------------") print(factorial) integer = int(input("Please enter a number greater than 1: ")) #Enter your integere here with 1 or greater print() print('User selected:', integer) print() print('Please select the following option below:') print () print('Option 1: Your integer will count down from', integer) print () print('Option 2: Find the factorial of', integer) print() if integer < 0:="" print("please="" enter="" number="" greater="" than="" zero")="" elif(integer="=" 0):="" print("please="" enter="" number="" greater="" than="" 0")="" else:="" select="int(input("Please" select="" an="" option:="" "))="" #select="" either="" options="" 1="" or="" 2="" by="" inputing="" numbers="" 1-2="" if="" select="=" 1:="" countdown()="" elif="" select="=" 2:="" factorial()="" print("-----------------------------------------------")="" print("thank="" you="" for="" testing="" my="" program!="" good="" day!")="" loop="" code:="" def="" loop():=""    ="" repeat="input("Would" you="" like="" to="" try="" again="" (yes/no)?="" ").lower()=""    ="" if="" repeat="=" "yes":=""        ="" loop()=""    ="" else:=""        ="" print("goodbye!")=""        ="" exit()="" loop()="" i="" started="" my="" process="" by="" defining="" the="" countdown="" and="" factorial="" functions,="" utilizing="" the="" while="" loop,="" if-else,="" and="" elif="" statements="" to="" compute="" and="" execute="" the="" countdown="" from="" whichever="" integer="" is="" inputted="" along="" with="" its="" factorial.="" i="" find="" it="" quite="" frustrating="" how="" particular="" python="" is="" with="" spacing="" and="" that="" every="" variable="" is="" case-sensitive.="" assessment#2="" i="" was="" able="" to="" set="" the="" definitions="" of="" counting="" down="" as="" well="" as="" the="" factorials.="" after="" trial="" and="" error,="" i="" started="" the="" program="" off="" with="" defining="" the="" two="" items.="" i="" them="" set="" two="" user="" inputs="" (one="" for="" the="" number,="" and="" the="" other="" for="" the="" option). ="" after="" the="" user="" inputs="" i="" put="" if="" options="" to="" determine="" how="" the="" inputs="" acted="" within="" the="" program.="" the="" only="" option="" i="" was="" struggling="" with="" and="" could="" not="" come="" up="" with="" is="" the="" negative="" number="" ending="" the="" program.="" i="" tried="" to="" understand="" this="" part="" and="" failed.="" if="" anyone="" has="" any="" suggestions="" or="" recommends="" another="" material="" i="" greatly="" appreciate.="" i="" look="" forward="" to="" hearing="" back="" from="" anyone.="" #determine="" number="" to="" enter="" x="()" factorial="1" #request="" number="" from="" end="" user="" x="int(input("Please" enter="" an="" integer="" (number)="" greater="" than="" 1:"))="" #ask="" user="" which="" step="" to="" follow="" selection="input" ("please="" enter="" 1="" for="" a="" countdown="" or="" 2="" to="" find="" the="" factorial:")="" #print="" end="" user="" selection="" if="" selection="=" "1":="" while="" x=""> 0: print (x) x = x - 1 elif selection == "2": # check if the number is negative, positive or zero if x < 0: print ("factorial does not exist for negative numbers") elif x == 0: print ("the factorial of 0 is 1") else: for i in range(1,x + 1): factorial = factorial*i print ("the factorial of",x,"is",factorial) else: print ("invalid selection entered") 0:="" print="" ("factorial="" does="" not="" exist="" for="" negative="" numbers")="" elif="" x="=" 0:="" print="" ("the="" factorial="" of="" 0="" is="" 1")="" else:="" for="" i="" in="" range(1,x="" +="" 1):="" factorial="factorial*i" print="" ("the="" factorial="" of",x,"is",factorial)="" else:="" print="" ("invalid="" selection="">
Answered Same DayMar 20, 2021

Answer To: Assessment#1 My biggest issue was creating a loop to cycle my program once executed so my users can...

Pratap answered on Mar 20 2021
138 Votes
Assessment#1
Feedback and/or suggestions:
1. The user interaction which asks for a number at the b
eginning will happen only once all through the program. Include these interaction and validation in a new function, so that it becomes flexible enough to execute whenever necessary. Let this new function be called as “user_input” just for the reference.
2. Above created “user_input” function should be the main function of the program. That is the program should execute this function when it is executed.
3. Loop function: The basic functionality is to continue or exit on user wish.
· The query itself has a misleading guideline. The user will...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here