Step 8 – Finishing off
You should now have a program that works to say hello, ask the user their name and then tell them how old they'll be at their next birthday.
You can improve your program in a number of ways:
- Add blank lines to make the program easier to read (use print())
- Personalise the output by using their name ("Hey Sam, you'll be 56 at your next birthday")
- Ask more questions!
- Add comments to your code
- Something else...
Once you're done you've mastered the basics of using variables in Python. Now we can go on to something trickier...
Adding two numbers together
Here's an idea.
You know how to get Python to deal with numbers.
So add to your program to ask the user for two numbers and then add them together.
Test your program. Try some really big numbers. How quickly does Python do it?
Then get Python to take the numbers away. Again, test it with some really big numbers. Check what happens when the answer is negative. And then check Python can deal with the user entering negative numbers.