python - PDA (Permissible Dating Age) Algorithm? -


the project create simple python program prompt user or age , print out lower , upper age limits user's date based on permissible dating age algorithm.

the pda algorithm is: d = a/2 + 7, age, , d lowest permissible age of date integer.

here code have far:

import random import sys import time def findacompanion():      print "welcome permissible dating age program!"      sys.stdoutflush()      time.sleep(3)      = float(raw_input("what age?"))      if <= 14:           print "you young!"      else:            d = a/2 + 7           print "you can date someone"           print d           print "years old." 

it seems running okay, yet nothings printing out , i'm confused what's going wrong print statements.

you weren't far off mark honest print statements not faulty. rather, contained within function never call never run. there small typo. code run:

import random #not needed current code import sys import time  def findacompanion():      print "welcome permissible dating age program!"      sys.stdout.flush() #you missed full-stop      time.sleep(3)      = float(raw_input("what age?"))      if <= 14:           print "you young!"      else:            d = a/2 + 7           print "you can date someone"           print d           print "years old."  #something call function , start off start_program  = findacompanion() 

stick classes, won't take long till falls place. being thrown in @ deep-end best way :)


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -