Question

In: Computer Science

Instructions from your teacher: Write a Python program that does the following: Displays a welcome message...

Instructions from your teacher:

Write a Python program that does the following:

  1. Displays a welcome message

  2. Prompts a user to enter a number (an integer), and then converts that value from inches to feet. If the user entered a negative number, display an error message telling the user that it was not a "positive " number and prompt the user to enter a number again.

  3. Displays the converted value, then " feet"

  4. Continue converting the user's valid values until the user enters 0. Your program should then display a goodbye message.

Example 1:

 
 

Welcome to my inches to feet converter!

 

Please enter a number of inches: 32

 

2.7 feet

 

Please enter a number of inches: 60

 

5.0 feet

 

Please enter a number of inches: -20

 

Please enter a positive number!

 

Please enter a number of inches: 40

 

3.3 feet

 

Please enter a number of inches: 0

 

Have a nice day!

Example 2:

 
 

Welcome to my inches to feet converter!

 

Please enter a number of inches: -32

 

Please enter a positive number!

 

Please enter a number of inches: -21

 

Please enter a positive number!

 

Please enter a number of inches: -10

 

Please enter a positive number!

 

Please enter a number of inches: 0

 

Have a nice day!

Solutions

Expert Solution

Python code:

#printing Welcome message
print("Welcome to my inches to feet converter!")
#accepting number of inches
inch=int(input("Please enter a number of inches: "))
#looping till inch is 0
while(inch!=0):
    #checking if inch is greater than 0
    if(inch>0):
        #printing feet rounded to 1 decimal
        print(str(round(inch/12,1))+" feet")
    else:
        #asking to enter positive number
        print("Please enter a positive number!")
    #accepting number of inches
    inch=int(input("Please enter a number of inches: "))
#printing goodbye message
print("Have a nice day!")

Screenshot:


Input and Output:


Related Solutions

(CODE IN PYTHON) Program Input: Your program will display a welcome message to the user and...
(CODE IN PYTHON) Program Input: Your program will display a welcome message to the user and a menu of options for the user to choose from. Welcome to the Email Analyzer program. Please choose from the following options: Upload text data Find by Receiver Download statistics Exit the program Program Options Option 1: Upload Text Data If the user chooses this option, the program will Prompt the user for the file that contains the data. Read in the records in...
PYTHON program that: Asks for a name, and then displays "Welcome student" plus your name on...
PYTHON program that: Asks for a name, and then displays "Welcome student" plus your name on the screen. (concatenate your name after the string) and prompts the user for 2 numbers, then calculates and displays the sum, product and average.
Program must use Python 3 Your program must have a welcome message for the user. Your...
Program must use Python 3 Your program must have a welcome message for the user. Your program must have one class called CashRegister. Your program will have an instance method called addItem which takes one parameter for price. The method should also keep track of the number of items in your cart. Your program should have two getter methods. getTotal – returns totalPrice getCount – returns the itemCount of the cart Your program must create an instance of the CashRegister...
IN PYTHON: Write a program that displays the lines from the total.txt file in the following...
IN PYTHON: Write a program that displays the lines from the total.txt file in the following output. Use a try catch phrase to check for errors. Use only one function for this portion [main()]. Remember to use Python. Sample output below: 19 16, 29 3, 30 4, 34
In C++ Instructions: Use a void function to print the following message (should be in welcome...
In C++ Instructions: Use a void function to print the following message (should be in welcome function) Welcome to the Event Scheduling program create 3 int arrays with 3 positions (one array for days one array for moths and one array for years) (should be in main) Create a file that contains the following (you can just create the file or write the file in the program) 1 / 26 / 2021 12 / 13 / 2020 2 / 1...
write a python program that inputs 10 integer values from the keyboard and then displays their...
write a python program that inputs 10 integer values from the keyboard and then displays their sum. use for loop
Using Python, write a program named hw3b.py that meets the following requirements: Welcome the user to...
Using Python, write a program named hw3b.py that meets the following requirements: Welcome the user to Zion's Pizza Restaurant and ask the user how many people are in their dinner group. If the answer is more than eight (8), print a message saying they'll have to wait for a table. Otherwise, report that their table is ready and take their order. Assume the client orders one pizza, and ask what he/she would like on their pizza, include a loop that...
Write a small program to encrypt and decrypt a message using Python library.
Write a small program to encrypt and decrypt a message using Python library.
(PYTHON) Write a program that does the following: reads each line from a txt file and...
(PYTHON) Write a program that does the following: reads each line from a txt file and convert it to lowercase counts the number of instances of: the characters 'a', 'e','i','o' and 'u' in the file creates a new file of file type .vowel_profile print outs lines in the file indicating the frequencies of each of these vowels Example input/output files: paragraph_from_wikipedia.txt (sample input) link: https://cs.nyu.edu/courses/fall19/CSCI-UA.0002-007/paragraph_from_wikipedia.txt paragraph_from_wikipedia.vowel_profile (sample output) link: https://cs.nyu.edu/courses/fall19/CSCI-UA.0002-007/paragraph_from_wikipedia.vowel_profile Please help!
Using python Write a program that displays all of states in the U.S. and display each...
Using python Write a program that displays all of states in the U.S. and display each state that begins with the letter A.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT