Skip to main content
  1. Posts/

My First Program

·188 words·1 min

Today I made my first program it tells you about the date its called age cal I made it on Python.

Here is the source code of my program which I saved in a file called today_date.py.

import datetime

#print()
print("\n My first Python program")
date = datetime.date.today()

print("sit back and relax open this program and know the date") 

print("Today's date is...")
print(date)

input("hit enter to exit this program")

To run this Python program, I open a terminal then I navigate to the directory where the today_date.py file is kept. For example, the file is located under C:\Users\kodert\dev\programming\ directory. So, first I need to change to the above directory as the folllowing:

PS C:\Users\kodert> cd .\dev\programming\
PS C:\Users\kodert\dev\programming> pwd

Path
----
C:\Users\kodert\dev\programming


PS C:\Users\kodert\dev\programming>

PS C:\Users\kodert\dev\programming> ls


    Directory: C:\Users\kodert\dev\programming


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        25/06/2023   9:51 AM            251 today_date.py

To run the program, in the terminal run the command:

PS C:\Users\kodert\dev\programming> python .\today_date.py

 My first Python program
sit back and relax open this program and know the date
Today's date is...
2023-06-25
hit enter to exit this program

And that’s how you do it!