Advertisement
The_KGB

[Python-Lab 3] Challenge Solution

Apr 23rd, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. #Guessing program
  2.  
  3. #def main -- program :D
  4. def main():
  5.  
  6.     #the actual values
  7.     #Could also be set to global constants.
  8.     realWeight = 190
  9.     realAge = 27
  10.     realName = 'bob'
  11.  
  12.     #the guessed variables
  13.     guessWeight = input('Guess the weight: ')
  14.     guessAge = input('Guess the age: ')
  15.     guessName = raw_input('Guess the name: ')
  16.  
  17.     #essentially runs the modules
  18.     getWeight = weightRight(guessWeight, realWeight)
  19.     getAge = ageRight(guessAge, realAge)
  20.     getName = nameRight(guessName, realName)
  21.  
  22. #If name is right or not
  23. def nameRight(guessName, realName):
  24.     if guessName == realName:
  25.         print 'That is the right name!!!'
  26.     elif guessName != realName:
  27.         print 'That is not the right name :( '
  28.     return nameRight
  29.  
  30. #if weight is right or not
  31. def weightRight(guessWeight, realWeight):
  32.     if guessWeight == realWeight:
  33.         print 'That is the right weight'
  34.     elif guessWeight != realWeight:
  35.         print 'That is the wrong weight'
  36.     return weightRight
  37.  
  38. #if age is right or not
  39. def ageRight(guessAge, realAge):
  40.     if guessAge == realAge:
  41.         print 'That is the correct age!'
  42.     elif guessAge != realAge:
  43.         print 'that is not the correct age!'
  44.     return ageRight
  45.  
  46. #calls main
  47. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement