Question: Write a Python program (special_sum.py) that calculate a special sum of 4 numbers, all int. The rule for this special sum is as follow: If

 Write a Python program (special_sum.py) that calculate a special sum of

Write a Python program (special_sum.py) that calculate a special sum of 4 numbers, all int. The rule for this special sum is as follow: If one of the entered numbers is 17, then it does not count towards the sum and the numbers entered after it do not count. For full credit, you must use function. Your function should have 4 int as parameters, and returns the special sum (as an int). Call this function specialsum You will complete this program in several steps. For each of the following steps, end the program's output with a newline. (1) Prompt the user to input 4 numbers, then display them in one line. (Submit for 2 points) Enter the first number: 1 Enter the second number: 2 Enter the third number: 17 Enter the fourth number: 5 You entered: 1, 2, 17 and 5 (2) Calculate and print the special sum. To do this part, you need to define the function specialsum then call it. final output should look like the following: (Submit for 8 points, total 10) Enter the first number: 1 Enter the second number: 2 Enter the third number: 17 Enter the fourth number: 5 You entered: 1, 2, 17 and 5 The special sum of the entered numbers is: 3

Everything is good except for "has specialsum Function" according to Zybooks program.

def specialsum (numi, num2, num3, num4) : if (numl == 17): return 0 elif (num2 == 17): return num1 elif (num3 == 17): 1 return num1 + num2 elif (num4 == 17): return num1 + num2 + num3 else: return numl + num2 + num3 + num4 if name main num1 int (input ("Enter the first number: ")) num2 = int(input ("Enter the second number: ")) num3 = int(input ("Enter the third number: ")) num4 = int(input ("Enter the fourth number: ")) specialsum (numi, num2, num3, num4) print ("You entered:", num1, ",", num2, ",", num3, "and", num4 ) print ("The special sum of the entered numbers is:", specialsum (numi, num2, num3, num4) )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!