def simple_if(num): """ Given a number, prints out some comments based on the size of the number """ if num > 10: print "Greater than 10" print "That's a big number" print "I'm done" def stupid_name(): """ Prompts the user for their name and gives a subjective analysis of the name """ name = raw_input("Enter your name: ") if name == "Dave": print name + ", that's a great name!" else: print name + ", that's a stupid name!" print "Nice to meet you, " + name def forecast(temperature, rain_amount): """ Given the temperature and amount of rain, outputs a forecast of the weather in English as a string """ print "Today it will be " + temperature_report(temperature) + \ " with " + precipitation_report(rain_amount) + \ " rain" def temperature_report(temperature): """ Converts a numerical temperature to one of: hot, warm, cool or cold """ if temperature > 80: temp = "hot" elif temperature > 70: temp = "warm" elif temperature > 50: temp = "cool" else: temp = "cold" return temp def precipitation_report(amount): """ Converts a numerical amount of rain to one of: "no", "scattered", "heavy" or "a whole bunch\" """ if amount == 0: rain = "no" elif amount < 1: rain = "scattered" elif amount < 2: rain = "heavy" else: rain = "a whole bunch of" return rain # some other examples that we didn't look at in class, but # might also be interesting def iseven(num): """ Return True if num is even, False otherwise """ return num % 2 def isodd(number): """ Return True if num is even, False otherwise """ return not iseven(number)