Question

Write the following function and provide a program to test it (main and function in one...

  1. Write the following function and provide a program to test it (main and function in one .py) 5 pts

def readFloat(prompt)

that displays the prompt string, followed by a space, reads a floating-point number in, and returns it. Below is how you’re going to call the function:

salary = readFloat(“Please enter your salary:”)

percentageRaise = readFloat(“What percentage raise would you like?”)

print("The salary is", salary)

print("The raise percentage is", percentageRaise)

keep it simple, python

Homework Answers

Answer #1
def readFloat(prompt):
    n = float(input(prompt+" "))
    return n

def main():
    salary = readFloat("Please enter your salary:")
    percentageRaise = readFloat("What percentage raise would you like?")
    print("The salary is", salary)
    print("The raise percentage is", percentageRaise)

main()

Know the answer?
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
Similar Questions
Write the following functions and provide a program to test them (main and all functions in...
Write the following functions and provide a program to test them (main and all functions in one .py). 5 pts def firstDigit(n) (returning the first digit of the argument) def lastDigit(n) (returning the last digit of the argument) def digits(n) (returning the number of digits of the argument) For example, firstDigit(1729) is 1, lastDigit(1729) is 9, and digits(1729) is 4. keep it simple python
Write the following functions and provide a program to test them (main and all functions in...
Write the following functions and provide a program to test them (main and all functions in one .py). 6 pts def allTheSame(x, y, z) (returning true if the arguments are all the same) def allDifferent(x, y, z) (returning true if the arguments are all different) def sorted(x, y, z) (returning true if the arguments are sorted, smallest one first keep it simple, python
Create a Python main program which calls two functions enterNum and calcResult and accomplishes the following:...
Create a Python main program which calls two functions enterNum and calcResult and accomplishes the following: 1. The main program calls the function enterNum 3 times. The first time enterNum is called, the main program stores the returned output in the variable xx. The second time, the returned output is stored in the variable yy and the third time in zz. 2. enterNum asks the user to enter a floating point number. This function has no input arguments and returns...
Function Example: Write a Python function that receives two integer arguments and writes out their sum...
Function Example: Write a Python function that receives two integer arguments and writes out their sum and their product. Assume no global variables. def writer(n1, n2): sum = n1 + n2 product = n1*n2 print("For the numbers", n1, "and", n2) print("the sum is", sum) print("and the product is", product) ... 1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both...
using Python: Write a function named safe input(prompt,type) that works like the Python input function, except...
using Python: Write a function named safe input(prompt,type) that works like the Python input function, except that it only accepts the specified type of input. The function takes two arguments: r prompt: str r type: int, float, str The function will keep prompting for input until correct input of the specified type is entered. The function returns the input. If the input was specified to be a number ( float or int), the value returned will be of the correct...
Write the function definition for a function which accepts 2 values from the main program and...
Write the function definition for a function which accepts 2 values from the main program and returns the average of the two numbers. DO NOT WRITE AN ENTIRE PROGRAM. DO NOT WRITE THE STATEMENT THAT CALLS THE FUNCTION! JUST WRITE THE FUNCTION DEFINITION python program
python code Write the function definition for a function which accepts one value from the main...
python code Write the function definition for a function which accepts one value from the main program and prints three times the number that is sent to it. For example, if the program sent 8, the function would print 24.
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first,...
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first, third, fifth (and so on) characters of the strings, with each character both preceded and followed by the ^ symbol, and with a newline appearing after the last ^ symbol. The function returns no value; its goal is to print its output, but not to return it. Q2) Write a Python function called lines_of_code that takes a Path object as a parameter, which is...
Please write the code in Python. Write a program/function in any Object-Oriented programming language that will...
Please write the code in Python. Write a program/function in any Object-Oriented programming language that will implement Queue Abstract Data Type with the following functions/methods.  Any build-in/pre-defined Queue function/library (e.g., java.util.Queue in Java) is NOT allowed to use in your code. push(Element):  insert the input Element (e.g., String or Integer in Java) to the end of the queue. pop(): remove the head element of the queue and print the head element on screen. count():  return the total number of elements in the queue...
Write spim program and execute it on mars. Your program reads two integer values x and...
Write spim program and execute it on mars. Your program reads two integer values x and y. Write a function called sum that gets x and y passed as parameters and return the sum of odd values between x and y inclusive. In addition write another function called even that gets x and y as parameters and returns the count of all even numbers between x and y inclusive. Also in main print the quotient and remainder of diving y...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT