Python Core



Admission Enquiry Form


Built in Modules in Python

datetime module

Example of datetime module :

#there is datetime module
from datetime import date
mydate=date(2023,9,25)
print(mydate.day)
print(mydate.month)
print(mydate.year)
print("Current date is ",date.today())
print(mydate.day +20)



Example of timer objects in python :

import threading
def bye():
print("Using Timer in Python\n")

print("Program will terminate after five seconds")
timer = threading.Timer(5.0,bye)
timer.start()
print("Bye Dear....\n")




Example of os module in python :

import os
os.system("cls")#will clear the screen
#following command will print the windows environment variable
print("Environment ",os.environ)
#following command will execute system commands
os.system("pause")
#following command will clear the screen
os.system("cls")
#following command will open notepad app of windows
os.system("notepad.exe first.txt")
#following code is also using exception handling code
try:
#following function will create compuhelp folder in current folder
ans=os.mkdir("compuhelp")
print(ans)
except FileNotFoundError:
print("Directory/Folder already exists")
except FileExistsError:
print("Directory or Folder already Exists")
cwd=os.getcwd()
print("Current Working Directory :",cwd)
dir_list=os.listdir()
print("Following is the list of Directories and file:")
for x in dir_list:
print(x)
#print("list of Directories of ",dir_list)
print("OS name : ",os.name) #will display nt it is windows NT
#file will be renamed from first.txt to second.txt
try:
os.rename("first.txt","second.txt")
except FileNotFoundError:
print("File not found")

try:
os.remove("second.txt")
print("File deleted")
except FileNotFoundError:
print("Now not found to delete")