Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions

Question

The C++ statement used to close the file named infile is

Answered: 1 week ago

Question

Describe the sources of long term financing.

Answered: 1 week ago