# ------------------------------------------------------------ #Student: Austin Wells #Class: CIS122 #Date: 4/29/2015 #Program Title: Chapter 6 Programming Excercise 2.py #(Feet to Inches) #Program Description: The program prompts the user for a number in feet and #displays the number in feet # ------------------------------------------------------------ INCH_CONST = 12 # prints the number of feet in inches def printInches(numOfInches): print 'The number in inches is {}' .format(numOfInches) # prompts user for input. def promptForNumber(strPrompt): userInput = int(raw_input(strPrompt + ": ")) print '{}' .format(userInput) return userInput #calculates feet to inches def feetToInches(numOfFeet): numOfInches = numOfFeet * INCH_CONST return numOfInches #main driver function def main(): try: numOfFeet = promptForNumber("Please enter the width of a number in feet") printInches(feetToInches(numOfFeet)) except (ValueError): print '\n\nInvalid input. You have entered a non integer. Please enter an interger' except (EOFError): print '\n\nInvalid input. You have forgotten to add input. Please Reset the program and enter an interger' main()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question