How to Create a Very Simple Program in Python
Open up a new window in python shell by pressing ctrl-N or going to 'File' and 'New window'., You need an introductory sentence., It's nice to know what the user's name is, so type this in line 2: name = input("name: ") The variable "name" has now...
Step-by-Step Guide
-
Step 1: Open up a new window in python shell by pressing ctrl-N or going to 'File' and 'New window'.
So you have to use the print function. Type below codes: print("Let's see how long you have lived in days, minutes and seconds.") ,,, days = age * 365 minutes = age * 525948 seconds = age * 31556926 Once you have wrote this, python automatically changes the values for days, minutes, and seconds, based on the user's input of age. , print(name, "has been alive for"
days,"days"
minutes, "minutes and"
seconds, "seconds! Wow!") , 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! -
Step 2: You need an introductory sentence.
-
Step 3: It's nice to know what the user's name is
-
Step 4: so type this in line 2: name = input("name: ") The variable "name" has now been replaced by the user's input.
-
Step 5: You need to know the age
-
Step 6: now you do the same thing as above except you have to use the "int" function
-
Step 7: because the user will enter a number
-
Step 8: like this: print("now enter your age") age = int(input("age: ")) The variable "age" has now been replaced by the user's input.
-
Step 9: You need to do the conversions using the user's given age.
-
Step 10: It's time to display to the user his/her information.
-
Step 11: Congrats!
Detailed Guide
So you have to use the print function. Type below codes: print("Let's see how long you have lived in days, minutes and seconds.") ,,, days = age * 365 minutes = age * 525948 seconds = age * 31556926 Once you have wrote this, python automatically changes the values for days, minutes, and seconds, based on the user's input of age. , print(name, "has been alive for"
days,"days"
minutes, "minutes and"
seconds, "seconds! Wow!") , 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!
About the Author
Jessica Turner
A passionate writer with expertise in hobbies topics. Loves sharing practical knowledge.
Rate This Guide
How helpful was this guide? Click to rate: