Create a Very Simple Program in Python
Python is a simple yet powerful programming language to learn. Have you learned about the bare basics of python but are confused on how to apply them? Well this article shows you how to make a program that calculates your total days, minutes, and seconds you have been alive! It is a very simple program that demonstrates how some things work in this programming language.Note that this is for users who have a basic understanding of python.
Steps
- Open up a new window in python shell by pressing ctrl-N or going to 'File' and 'New window'.
- You need an introductory sentence. So you have to use the print function. Type below codes:
Template:CodeBox - It's nice to know what the user's name is, so type this in line 2:
Template:CodeBox- The variable "name" has now been replaced by the user's input.
- You need to know the age, now you do the same thing as above except you have to use the "int" function, because the user will enter a number, like this:
Template:CodeBox- The variable "age" has now been replaced by the user's input.
- You need to do the conversions using the user's given age.
Template:CodeBox- Once you have wrote this, python automatically changes the values for days, minutes, and seconds, based on the user's input of age.
- It's time to display to the user his/her information.
Template:CodeBox - Congrats! you made a real program that serves a purpose! Save it and run it by going to 'run' and 'run module'. Try it out for yourself!
Related Articles
- Experiment With Python
- Program in Python With Pygame
- Print in Python
- Start Programming in Python
- Make Variables in Python
- Create a Simplistic Sub Language with Python