Python programming

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jctech
    DK Veteran
    • Dec 2009
    • 664

    #1

    Python programming

    My Daughter (10) has started to teach herself programming and is set on learning Python, she has got a lot of inspiration and asistance from youtube and some forums.
    She is trying to write a programme that will advise on your age, but cannot compare the input with the parameter in python.


    name = input("what is your name?")
    print ("Hello", name)
    age = input("how old are you")

    if age < 35:
    print ("thats young")

    elif age > 60:
    print ("thats old")

    I think the problem is comparing a string with an integer.
    Anybody have an idea how to turn the string into an integer, so that they can be compared? or another solution.

    The error message tells us the error is on line 5, but I do not have the complete eror message.
    Last edited by jctech; 13 December, 2011, 00:11.
  • GastonJ
    V.I.P. Member
    • Dec 2009
    • 5505

    #2
    Try this:


    name = raw_input("what is your name?: ")
    print "Hello", name
    age = input("how old are you")

    if age < 35:
    print ("thats young")

    elif age > 60:
    print ("thats old")
    My master plan is to live forever..... going to plan so far
    Despite the cost of living, it's still very popular.
    No good deed goes unpunished....

    Comment

    • m9g
      DK Veteran
      • Dec 2009
      • 704

      #3
      blimey not alot has changed since i did "basic" programming back in the 80's


      DONT FORGET TO CLICK THE THANKS BUTTON IN THE BOTTOM LEFT CORNER OF THE POST IF ANYONE HELPED YOU

      Comment

      • GastonJ
        V.I.P. Member
        • Dec 2009
        • 5505

        #4
        Nothing much changes, just generally got easier over the years. Line numbers are a thing of the past though, even though they still get used for reference when debugging.
        My master plan is to live forever..... going to plan so far
        Despite the cost of living, it's still very popular.
        No good deed goes unpunished....

        Comment

        Working...