Question

Python Programming 4th Edition: Write a program that asks the user for the number of feet....

Python Programming 4th Edition:

Write a program that asks the user for the number of feet.

The program converts those feet to inches by using the formula ’12 * feet’.

Hint:

Define main () program

Get the number of feet from the user

Define variables

Call a function feet_to_inches(feet)

The function receives the number of feet and returns the number of inches in that many feet.

The output should look like as follows:

Enter the number of feet: If the user enters 27 for example, the print should display ‘27.0 feet = 324.0 inches’

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

Please find the answer below:-

CODE:-

main.py 1. def feet_to_inches (feet): global inches inches = float(12 feet) 4 return inches 5. def main(): feet = input(Ente

OUTPUT:-

Enter the number of feet27 27.0 feet = 324.0 inches

Hope you like the answer.
Thanks!!!

Please find the code snippet:-

def feet_to_inches(feet):
global inches
inches = float(12*feet)
return inches
def main():
feet = input("Enter the number of feet")
feet = float(feet)
feet_to_inches(feet)
print(float(feet)," feet = ",float(inches)," inches")
main()

Add a comment
Know the answer?
Add Answer to:
Python Programming 4th Edition: Write a program that asks the user for the number of feet....
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
  • Python Programming 4th Edition Write a program that calculates the length of a right triangle's hypotenuse....

    Python Programming 4th Edition Write a program that calculates the length of a right triangle's hypotenuse. Hints: Define main() program Get the length of the triangle’s two sides (user input) Call math function to calculate the length of the hypotenuse. The output should look like as follows: The length of the hypotenuse is 12.041594578792296

  • Write a Program that has a menu with a  layout below, that asks the user if they...

    Write a Program that has a menu with a  layout below, that asks the user if they want to: 1. Converts from feet and inches to meter and centimeters 2. Converts from meter and centimeters to feet and inches 3. Quit the program The program should continue as long as the user asks it to. The program will use a switch statement for the menu option selection. Either a do loo or a do-while loop can be used for the overall...

  • Write a program that asks the user to enter a string and then asks the user...

    Write a program that asks the user to enter a string and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the string. python programming

  • In Python, write a program that asks the user for a positive integer number. If the...

    In Python, write a program that asks the user for a positive integer number. If the user enters anything else, the program would ask the user to re-enter a number or enter -1 to quit. If it is a positive number, the program then prints out a multiplication table that goes up to that number. For example, if the user enters 10, the output would look something like this. https://www.vectorstock.com/royalty-free-vector/multiplication-table-on-white-background-vector-2721686

  • Write a program that asks the user to input the number of males and females registered...

    Write a program that asks the user to input the number of males and females registered in a class (Max 30 members in the class). The program should display the percentage of males and females in the class. Python programming question

  • #Starting Out With Python, 4th Edition #Chapter 7 #Exercise 6 #in a program, write a function...

    #Starting Out With Python, 4th Edition #Chapter 7 #Exercise 6 #in a program, write a function named roll that #accepts an integer argument number_of_throws. The #function should generate and return a sorted #list of number_of_throws random numbers between #1 and 6. The program should prompt the user to #enter a positive integer that is sent to the function, #and then print the returned list. How would you do this?

  • Write a Python program that asks the user to type in their three quiz scores (scores...

    Write a Python program that asks the user to type in their three quiz scores (scores between 0 and 100) and displays two averages. The program should be written so one function gets the user to input a score, another function takes the three scores and returns the average of them. And another function takes the three scores and averages the two highest scores (in other words, drops the lowest). Each of these functions should do the computation and return...

  • Python Programming 4th Edition: Need help writing this program below. I get an error message that...

    Python Programming 4th Edition: Need help writing this program below. I get an error message that says that name is not defined when running the program below. My solution: def main(): filename = "text.txt" contents=f.read() upper_count=0 lower_count=0 digit_count=0 space_count=0 for i in contents: if i.isupper(): upper_count+=1 elif i.islower(): lower_count+=1 elif i.isdigit(): digit_count+=1 elif i.isspace(): space_count+=1 print("Upper case count in the file is",upper_count) print("Lower case count in the file is",lower_count) print("Digit count in the file is",digit_count) print("Space_count in the file is",space_count)...

  • 1. In Python, Write a function to convert inches into yards, feet and inches. The functions...

    1. In Python, Write a function to convert inches into yards, feet and inches. The functions should take one parameter, 'inches', and print out the number of yards, feet, and inches equivalent to the value of the argument. Call the function after prompting the user to enter the number of inches. Don't forget to convert the input to an 'int'. 2. In Python,Write a function to convert celsius to fahrenheit. The function should return a value, which you should assign...

  • Python Programming Q.3) Write a program that repeatedly asks the user to enter words until they...

    Python Programming Q.3) Write a program that repeatedly asks the user to enter words until they enter a period ("."). Your program should then print all of the words they entered including the period) on a single line separated by spaces. For example, Enter some words (. to stop): > hello > world hello world.

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