Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2011
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.65 KB | None | 0 0
  1. def greeter():
  2.     global name
  3.     name = input("What's yer name?")
  4.     greeting = "Howdy, " + name + "."
  5.     print (greeting)
  6.  
  7. def yourpay():
  8.     try:
  9.         name
  10.     except:
  11.         name = 'pardner'
  12.     try:
  13.         rate = float(input( "So, " + name + ", how much you make an hour?" ))
  14.     except:
  15.         rate = float(input( "Just gimme a number, in 'merican dollars." ))
  16.     try:
  17.         hours = float(input( "Yeah? An how many hours you work?" ))
  18.     except:
  19.         hours = float(input( "Just gimme the number of hours." ))
  20.     pay = rate * hours
  21.     if hours > 40:
  22.         pay += 0.5 * rate * (hours - 40)
  23.         reply = "So, with overtime I reckon you make $" + str(pay) + ", right?"
  24.     else:
  25.         reply = "So, I reckon you make $" + str(pay) + ", right?"
  26.     print( reply )
  27.  
  28. def tempconversion():
  29.     celsius = input("What's the temperature in Celsius?")
  30.     fahrenheit = float(celsius) * (9.0/5) + 32
  31.     print ("Well, here in 'merica, we call that " + str(fahrenheit) + " degrees, got it?")
  32.  
  33. def yourscore():
  34.     rejection =  "Ur dumb. I said a NUMBER, 'tween ZERO an' ONE. You fail."
  35.     try:
  36.         score = float(input( "Gimme a number 'tween zero an' one." ))
  37.     except:
  38.         print( rejection )
  39.         return
  40.     if score < 0 or score > 1:
  41.         print ( rejection )
  42.         return
  43.     if score < 0.6:
  44.         grade = "F"
  45.     elif score >= 0.9:
  46.         grade = "A"
  47.     elif score >= 0.8:
  48.         grade = "B"
  49.     elif score >= 0.7:
  50.         grade = "C"
  51.     elif score >= 0.6:
  52.         grade = "D"
  53.     else:
  54.         grade = "F"
  55.     print( "Ur grade is " + grade + "." )
  56.  
  57. def runningaverage():
  58.     print( "Let's begin. The rules are, you input numbers, as many as you want. Then when you're done, say \"done\" and I'll give you the average." )
  59.     total = 0
  60.     i = 0
  61.     average = 0
  62.     maxx = None    
  63.     x = input( "Beep boop boop. Number please." )
  64.     while x != "done":
  65.         try:
  66.             total += float(x)
  67.             i += 1
  68.             if i == 1:
  69.                 maxx = float(x)
  70.                 minx = float(x)
  71.             if float(x) > maxx:
  72.                 maxx = float(x)
  73.             if float(x) < minx:
  74.                 minx = float(x)
  75.             average = float(total) / float(i)
  76.             x = input( "Beep boop bop beep. Ready for another number." )
  77.         except:
  78.             x = input( "I said a number. Beep boop bip." )
  79.     print( "Beep beep beep boop beep bip bip bop beeeeeeeep." )
  80.     print( "The average is " + str(average) + "." )
  81.     if maxx:
  82.         print ( "The highest input is " + str(maxx) + "." )
  83.         print ( "The lowest input is " + str(minx) + "." )
  84.     return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement