# ------------------------------------------------------------ #Student: Austin Wells #Class: CIS122 #Date: 4/29/2015 #Program Title: Chapter 6 Programming Excercise 4.py #(Maximum of Two Values) #Program Description: The program prompts the user for two numbers and #displays the greatest value of the two. # ------------------------------------------------------------ # prints the greatest number def printMax(greatestNum): print 'The greatest number is {}' .format(greatestNum) # prompts user for input. def promptForNumber(strPrompt): userInput = int(raw_input(strPrompt + ": ")) print '{}' .format(userInput) return userInput #determines which number is greater def max(inputNum1, inputNum2): if(inputNum1 > inputNum2): greatestNum = inputNum1 else: greatestNum = inputNum2 return greatestNum #main driver function def main(): try: inputNum1 = promptForNumber("Please enter a number") inputNum2 = promptForNumber("Please enter a number") printMax(max(inputNum1,inputNum2)) except (ValueError): print '\n\nInvalid input. You have entered a non integer. Please enter an integer' except (EOFError): print '\n\nInvalid input. You have forgotten to add input. Please Reset the program' 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