Question: Help with step 1 & 2 Python coding Find the factorial function. Given a number, find the factorial of it. For example 4!=4321=24 You should
Help with step 1 & 2 Python coding



Find the factorial function. Given a number, find the factorial of it. For example 4!=4321=24 You should be using a while loop to do this. Since this is your first lab using a while loop, it has already been done for you. All you need to do is add one line of code in the while loop. Before writing any code, run the program to see what it does. Make sure to have input in the Predefine program input (optional) box or else you will get an error. Did you get an error? That was supposed to happen! The error says: "We couldn't run your program to completion. Could be a temporary system issue - please try again. Could be your program never finished, due to an infinite loop, infinite recursion, waiting for input, or other possibilities." This error was caused by an infinite loop. This is because the number passed in from input never decreases, so it's stuck in the while loop because it never reaches 0 . Your goal is to add a statement to decrease that number by 1 each time it goes through the while loop. Once you add your code, run it again! You should get the factorial this time. Given a random number, calculate the remainder if that number is divided by 9 . Make sure to use the modulo operator. For example: If 81 is passed in, the result returned should be 0 . >> 81%9 If 4 is passed in, the result returned should be 4 . This is because you cannot divide 4 by 9 , so the remainder will be 4 because 4/9=0 with a remainder of 4 . >>>% 4 If 64 is passed in, the result returned should be 1. >64%9 1 Remember to run and test it. \begin{tabular}{l|l} 12 & def \\ 13 & total =1 \\ 14 & while (numi>0): \\ 15 & total = total num1 \\ 16 & \\ 17 & return total \\ 18 & \\ 19 & \# step 2 \\ 20 & def moduloPractice ( num1): \\ 21 & return None \# TODO \\ 22 & \\ 23 & \# step 3 \\ 24 & def evenNum(num1): \\ 25 & return None \# TODO \\ 26 & \end{tabular}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
