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 and use main program:
if __name__ == "__main__":
as following:
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
def specialsum(num1,num2,num3,num4):
if(num1==17):
return 0;
elif(num2==17):
return num1;
elif(num3==17):
return num1+num2;
elif(num4==17):
return num1+num2+num3;
else:
return num1+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:"));
print("You entered: ",num1,",",num2,",",num3," and ",num4);
print("The special sum of entered numbers is:
",specialsum(num1,num2,num3,num4));
Expected output:

Write a Python program (special_sum.py) that calculate a special sum of 4 numbers, all int. The...
Create a program that creates an array of 500 random numbers between -10 and 10. Write several functions: Function 1 - prints the array with a certain number of elements per line. Prototype: void printArray(int array[], int numElements, int numPerLine, ostream &os) Function 2 prints only the array elements that are evenly divisible by an input number. Prototype: void printDivBy(int array[], int numElements, int numPerLine, int divBy, ostream &os) Function 3 takes the input array and returns the maximum, the...
Need help figuring this out Write a program that reads in a sequence of numbers (doubles) from standard input until 0 is read, and stores them in an array, This part is done using iteration (loop). You may assume that the maximum size of the array will not be more than 100. Your program computes the maximum number stored in the array, the count of negative numbers, and computes the sum of positive numbers, using recursion. You need to have...
USING PYTHON - Write a program that calls a function that prompts the user to enter a real number. The function should verify that the user entered a valid real number, and should prompt the user to re-enter any invalid input. After a valid real number has been entered, the function should return the number as a number. To test your function, from a main function, call the function two separate times and print the sum of the two numbers...
use python: Write a program that reads in X whole numbers and outputs (1) the sum of all positive numbers, (2) the sum of all negative numbers, and (3) the sum of all positive and negative numbers. The user can enter the X numbers in any different order every time, and can repeat the program if desired. Sample Run How many numbers would you like to enter? 4 Please enter number 1: 3 Please enter number 2: -4 Please enter...
Python 3.6 "While Loops" Write a program that adds up a series of numbers entered by the user. The user should enter each number at the command prompt. The user will indicate that he or she is finished entering the number by entering the number 0. Example This program will sum a series of numbers. Enter the next number (enter 0 when finished) > 5 Enter the next number (enter 0 when finished) > 2 Enter the next number (enter...
Python 3 Modify the sentence-generator program of Case Study so that it inputs its vocabulary from a set of text files at startup. The filenames are nouns.txt, verbs. txt, articles.txt, and prepositions.txt. (HINT: Define a single new function, getWords. This function should expect a filename as an argument. The function should open an input file with this name, define a temporary list, read words from the file, and add them to the list. The function should then convert the list...
61. The following program is accepted by the compiler: int sum( int x, int y ) { int result; result = x + y; } T__ F__ 62. The following implementation is accepted by the compiler: void product() { int a; int b; int c; int result; cout << "Enter three integers: "; cin >> a >> b >> c; result = a * b * c; ...
Write a C program convert.c that converts each number in an array by the sum of that number plus 6 modulus 10. A sample input/output: Enter the length of the array: 5 Enter the elements of the array: 3 928 4 14 77 Output: 9 4 0 0 3 The program should include the following function: void convert(int *a1, int n, int *a2) The function converts every element in array a1 of length n to an output array a2. The...
Write a Python program: In main function the user is asked to enter distance traveled and time and then send this information to a Python function that calculates and returns the speed of a car. The function will need to have parameters for distance traveled and time taken for the travel. The speed is calculated as: Speed = distance traveled / time In the main function show how to call this function in a print statement.
Python help! Any help is appreciated, thank you! Fill in the missing function, monthString(), in the program. The function should take number between 1 and 12 as a parameter and returns the corresponding month as a string. For example, if the parameter is 1, your function should return "January". If the parameter is 2, your function should return out "February", etc. def monthString(monthNum): """ Takes as input a number, monthNum, and returns the corresponding month name as a string. Example:...