Question

I need to write a function that takes in 3 parameters, parameter_1, parameter_2, and parameter_3. It computes a value based upon the following formula and places it in the return_var variable:

return_var = (parameter_1 + parameter_2 * 47)/parameter_3

The value maintained in return_var variable must be returned by the function.

def main(): argA int (input(Enter value for Argument A: )) argB int(input(Enter value for Argument B )) argC int (input (

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#Defing the user defined function crazy formula

def crazy_formula(A, B, C):

#It computes the (parameter_1 + parameter_2 * 47)/parameter_3

              return_var = (A + B * 47)/C

#Returning the result

              return return_var

#Main function

# It gets the inputs from user

argA= int(input("Enter value of Argument A : "))

argB= int(input("Enter value of Argument B : "))

argC= int(input("Enter value of Argument C : "))

#Calling the crazy_formula Function with the user input parameters

answer = crazy_formula(argA, argB, argC)

#Printing the result with 2 decimal points

print ("Result from crazy formula: ",format(answer, ".2f"))

Output:

Python 3.6.1 (default, Dec 2015, 13:05:11) [GCC 4.8.2] on linux Enter value of Argument A 1 Enter value of Argument B 1 Enter

Add a comment
Know the answer?
Add Answer to:
I need to write a function that takes in 3 parameters, parameter_1, parameter_2, and parameter_3. It computes a value ba...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need to write a function that takes in 3 parameters, parameter_1, parameter_2, and parameter_3. It computes a value ba...

    I need to write a function that takes in 3 parameters, parameter_1, parameter_2, and parameter_3. It computes a value based upon the following formula and places it in the return_var variable: return_var = (parameter_1 + parameter_2 * 47)/parameter_3 The value maintained in return_var variable must be returned by the function. def main(): argA int (input("Enter value for Argument A: ")) argB int(input("Enter value for Argument B ")) argC int (input ("Enter value for Argument C ")) #invoke the crazy_formula function...

  • #function to covert kilometer to miles #takes km input as an argument and return the calculation...

    #function to covert kilometer to miles #takes km input as an argument and return the calculation def kilometer_to_miles(km): return km * 0.6214 #function to covert miles to kilometer #takes miles input as an argument and return the calculation def miles_to_kilometer(miles): return miles/0.6214 #Main function to find the distance #by calling either of the two functions #prompt the user to enter his/her choice of distance conversion restart = 0 while (restart == 'y'): user_input = input ("Enter k to convert kilometer...

  • PYTHON Create a function called squareValue. squareValue will calll the function getValue() to square the value...

    PYTHON Create a function called squareValue. squareValue will calll the function getValue() to square the value and return it back to the main portion of the program. In main call squareValue which will call getValue. def getValue():     val = int(input("Enter a number"))     return val myValue = getValue() print("The value entered is ", myValue)

  • Python 3 Question: All I need is for someone to edit the program with comments that...

    Python 3 Question: All I need is for someone to edit the program with comments that explains what the program is doing (for the entire program) def main(): developerInfo() #i left this part out retail = Retail_Item() test = Cash_Register() test.data(retail.get_item_number(), retail.get_description(), retail.get_unit_in_inventory(), retail.get_price()) answer = 'n' while answer == 'n' or answer == 'N': test.Menu() print() print() Number = int(input("Enter the menu number of the item " "you would like to purchase: ")) if Number == 8: test.show_items() else:...

  • (a) Write a Ruby function mean that computes the mean value of an arbitrary number of arguments. Function calls mean (1,2,3,4,5) mean 3 ,1 ,and "No arguments". (1) and mean should respect...

    (a) Write a Ruby function mean that computes the mean value of an arbitrary number of arguments. Function calls mean (1,2,3,4,5) mean 3 ,1 ,and "No arguments". (1) and mean should respectively return tion sigma that uses your function mean and computes the standard deviation of an arbitrary of arguments. Function calls sigma (1,2,1,2)sigma (1) and sigma should respectively return1, o, and "No arguments" (Hint: the standard deviation is the square root of (b) Write a Ruby func variance, and...

  • Use only C++ for all function Introduce a call-by-value function that computes the volume of a...

    Use only C++ for all function Introduce a call-by-value function that computes the volume of a box. Hint: Length, width, and height of a box is needed. Introduce a call-by-reference function with void output. that computes the square of an integer. Please double check the value of the function input before and after function call. Introduce a call-by-pointer function with void output. that computes the square of an integer. Please double check the value of the function input before and...

  • For Python debugExercise12.py is a recursive function that accepts an integer argument, n, and prints the...

    For Python debugExercise12.py is a recursive function that accepts an integer argument, n, and prints the numbers 1 up through n. By debugging these programs, you can gain expertise in program logic in general and the Python programming language in particular. def main(): # Local variable number = 0 # Get number as input from the user. number = int(input('How many numbers to display? ')) # Display the numbers. print_num(number) # The print_num function is a a recursive function #...

  • Program already solved, but I need to put function documentation headers for each and every function...

    Program already solved, but I need to put function documentation headers for each and every function in your program (for the ones you write, and keep the function header I give you for the main() function). Also make sure you keep the file block header at the top of the file, and fill in the information correctly. Secondly this week you must get your indentation correct. All indentation must use 2 spaces, and you should not have embedded tabs in...

  • 1. Palindrome Write a program that prompts the user for a positive integer number and output whet...

    Language is C 1. Palindrome Write a program that prompts the user for a positive integer number and output whether the number is a palindrome or not. A palindrome number is a number that is the same when reversed. For example, 12321 is a palindrome; 1234 is not a palindromoe. You will write a function named as palindrome. The function will have two arguments, number and isPalindrome. Both arguments are pass-by-reference. The argument number is a pointer to a variable...

  • For this portion of the lab, you will reuse the program you wrote before That means...

    For this portion of the lab, you will reuse the program you wrote before That means you will open the lab you wrote in the previous assignment and change it. You should NOT start from scratch. Also, all the requirements/prohibitions from the previous lab MUST also be included /omitted from this lab. Redesign the solution in the following manner: 1. All the functions used are value-returning functions. 2. Put the functions in an external module and let the main program...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT