1 Replies - 949 Views - Last Post: 12 February 2009 - 05:27 PM Rate Topic: -----

#1 vieirabear  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-December 08

Compare age, weight and birth month

Post icon  Posted 08 February 2009 - 11:29 PM

def main():
	age = getAge
	weight = getWeight
	birthMonth = getMonth

	getAge(age)
	getWeight(weight)
	getMonth(birthMonth)
	correctAnswers(age,weight,birthMonth)
End Module

def getAge(age):
	age = input('Enter your age.')
	if age <= 25 Then
	   Display "Congratulations, the age is 25 or less."
	else
	   Display "Your old"
	End if
End Module

def getWeight(weight)
	weight = input ('Enter your weight')
	if weight >= 128 Then
	   Display "Congratulations, the weight is 128 or more."
	else
	   Display "You are too thin."
	End if
End Module

def getMonth(birthMonth):
	birthMonth = input ('Enter the month')
	if birthMonth = April Then
	   Display 'Congratulations, the month is April.'
	else
	   Display 'Wrong month.'
	End if
End Module

def correctAnswers(age,weight,birthMonth):
	print 'The correct age is 25'
	print 'The correct weight is 128'
	print 'The correct month is April'
End Module


main()
	 

I have written this code as homework. I wrote it the same way I have been writing my other codes. But this one seems to have a lot of syntax errors. But I do see why it should have any. My other codes ran fine. Please can somebody give me some help. Thanks!!!

Is This A Good Question/Topic? 0
  • +

Replies To: Compare age, weight and birth month

#2 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 674
  • View blog
  • Posts: 4,349
  • Joined: 24-October 08

Re: Compare age, weight and birth month

Posted 12 February 2009 - 05:27 PM

am not that good at python but this should work for you
def main():
	age = getAge()
	weight = getWeight()
	birthMonth = getMonth()

	correctAnswers()


def getAge():
	age = input('Enter your age.')
	if age <= 25:
	   print "Congratulations, the age is 25 or less."
	else:
	   print "Your old"
	

def getWeight():
	weight = input ('Enter your weight')
	if weight >= 128:
	   print "Congratulations, the weight is 128 or more."
	else:
	   print "You are too thin."
	

def getMonth():
	birthMonth = raw_input ('Enter the month')
	if birthMonth == 'April':
	   print 'Congratulations, the month is April.'
	else:
	   print 'Wrong month.'

def correctAnswers():
	print 'The correct age is 25'
	print 'The correct weight is 128'
	print 'The correct month is April'



main()


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1