Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

need your opinion about my python program?

I am 14 and I am beginner in programming. I started learning python like 1 week ago (online).

and i just created this little program its really silly.. but i just want your opinion and suggestions if there are... its a age finding program btw

here is the code

print "If any where in this program if it pauses press any key to continue"

print "helo ! how are you "

raw_input ()

print "great then"

x = raw_input ("what is your name")

print x + ", welcome to this program"

raw_input ()

q= raw_input("In which year do you want to know what your age will be:")

e= raw_input ("In which year were you born in:")

z = int(q) - int (e)

abs(z)

raw_input()

print "you will be " + str(z) + " in year " + str(q)

raw_input()

print "well " + x + " this was fun hope we see you soon"

raw_input ()

1 Answer

Relevance
  • Russel
    Lv 5
    8 years ago
    Favorite Answer

    It's not bad at all for a beginner on week 1.

    One of the emediately noticeable things I would change is your variable names. Single letter variable names like x, y and z are not very descriptive and should only be used in cases where it's emediately obvious what the variable is.

    For x I would use name. For q I would probably use something like target_year and for e I would use something like born_year. For z I think a descriptive name would be difference since it hold the difference of q and e, or target_year and born_year, or you could even use age.

    There's two things wrong with abs(z). The first is that abs() is a function that returns the result. Meaning the correct usage would be z = abs(z) othewise z would be unaffected at all. The other thing is that it shouldn't be there at all. See if I was born in 1988 and I want to know how old I will be in 1975 the program shouldn't say 13 years. It should either say I wouldn't have been born then or it should say -13 years.

    Still there's not as much wrong with this program as you would expect after 1week of learning.

    If you've learned how to use functions you should try and refactor your code to use some functions. Some thoughts for functions could be

    def how_old(born_year, target_year):

    ...."""

    ....prints your age or appropriate message if arguments invalid.

    ...."""

    ....# code goes here

    Remember practice is key.

Still have questions? Get your answers by asking now.