Ad Code

✨🎆 Codex 1.0 PLACEMENT READY PROGRAM! 🎆✨

Get 75% Discount Early bird offer CLICK to JOIN CodeX 1.0 click

File Handling Operation in Python

Python Calendar Module

Python Calendar Module – Complete Guide with Examples

The calendar module in Python is used for handling dates, monthly calendars, leap-year calculations, and generating entire year calendars. It is part of Python’s standard library, making it extremely useful for date-based applications, schedulers, dashboards, and automation scripts.


Why Use the Calendar Module?

  • To display a month or full year calendar
  • To check whether a year is a leap year
  • To count leap years between two years
  • To get weekday index for any date
  • To build scheduling or date-based applications
  • To analyze date-related patterns

Basic Example of Calendar Module

import calendar

# Print calendar of March 2014
print(calendar.month(2014, 3))

# Get first weekday (0 = Monday, 6 = Sunday)
print(calendar.firstweekday())

# Check leap year
if calendar.isleap(2020):
    print("The year is leap year")
else:
    print("The year is not leap year")

# Count total leap years between two years
print(calendar.leapdays(1950, 2000))

Print Full Year Calendar

print("The calendar of year 2018 is:")
print(calendar.calendar(2018, 2, 1, 6))

Parameter Explanation

  • 2018 → Year
  • 2 → Space between columns
  • 1 → Number of lines per week
  • 6 → Number of columns per row

Useful Calendar Module Functions

1. calendar.month(year, month)

Returns formatted month calendar.

2. calendar.calendar(year)

Displays full year calendar in text format.

3. calendar.isleap(year)

Returns True if the given year is a leap year.

4. calendar.weekday(year, month, day)

Returns the weekday index (0 = Monday … 6 = Sunday).

5. calendar.monthrange(year, month)

Returns a tuple: (first_weekday, total_days_in_month).


Assignment 1: Calculate Age in Years, Months, Days

Solution by Shiva Sir:
from datetime import date

a = date(date.today().year, date.today().month, date.today().day)
b = date(
    int(input("enter year")),
    int(input("enter month")),
    int(input("enter day"))
)

# Calculate month difference
if a.month > b.month:
    months = a.month - b.month
else:
    months = b.month - a.month

# Year difference
years = a.year - b.year

# Day difference
if a.day > b.day:
    days = a.day - b.day
else:
    days = b.day - a.day

print('{0} years, {1} months, {2} days'.format(years, months, days))

Assignment 2: Day Before & After Calculator

User enters a number of days; program displays:

  • The date before given days
  • The date after given days

Hint: Use timedelta from datetime module.


Assignment 3: Create a Stopwatch

Build a stopwatch where:

  • s → Start
  • p → Pause
  • e → End

Hint: Use time.time() for timestamp calculation.


Extra Concepts for Better Understanding

1. Get Weekday Name

import calendar
days = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]

print(days[ calendar.weekday(2025, 12, 25) ])

2. Get Total Days in Any Month

import calendar
first, total = calendar.monthrange(2025, 5)
print("Total days:", total)

3. Generate Calendar as a Matrix

print(calendar.monthcalendar(2025, 1))

4. Iterate Through All Weeks of a Month

import calendar

for week in calendar.monthcalendar(2025, 1):
    print(week)

⭐ Additional Advanced Examples (Added for Extra Depth)

5. Find All Mondays in a Year

import calendar

year = 2025
mondays = []

for month in range(1, 12+1):
    for week in calendar.monthcalendar(year, month):
        if week[0] != 0:   # Monday exists
            mondays.append((year, month, week[0]))

print(mondays)

6. Display Calendar in HTML Format

import calendar

html_calendar = calendar.HTMLCalendar().formatmonth(2025, 3)
print(html_calendar)

Post a Comment

36 Comments

  1. # WAP to perform the addition of two numbers and write the output of addition under file?
    a=int(input("enter first number"))
    b=int(input("enter second number"))
    s=a+b
    f=open("addition.txt","w+")
    f.write("a is"+str(a)+"\n b is"+str(b)+"\nsum is"+str(s))
    f.close()

    ReplyDelete
  2. #wap to create bio data for marriag
    f = open("biodata.doc","w+")
    f.write("abc")
    f.write("\n In my family five member my parents and two sibling\n")
    f.write("\n i have complteted mbbs\n")
    f.write("\n age is 25\n")
    f.write("\n dob is 4-5-1995")
    f.write("\n hindu\n")
    f.write("\n working in govt college as a professor\n")
    f.write("\n i can speak hindi and english both\n")
    f.write("\n hindu\n")
    f.close()


    ReplyDelete
  3. #Program to create a resume using file handling?

    f = open("resume.doc","w+")
    f.write("Objective")
    f.write("\n I am seeking a job, where I can use my exp and skills for the growth of company")
    f.write("\n Qualification")
    f.write("\n I have completed B.E from Electronics and Communcation branch")
    f.write("\n Academic Qualification")
    f.write("\n 10th = 76% and 12th = 68%")
    f.seek(0)
    s=f.read()
    print(s)
    f.close()

    ReplyDelete
  4. #Program to calculate Simple Interest using Write and Read Mode?

    f=open("SI.txt","w+")
    p = int(input("Enter principal Amount"))
    r= int(input("Enter rate of interest = "))
    t = int(input("Enter time period = "))
    si = (p*r*t)/100
    f.write(str(si))
    f.seek(0)
    q=f.read()
    print("SI for ",p,r,t,"= ",q)
    f.close()

    ReplyDelete
  5. # Addition of two number
    a = int(input("Enter first number"))
    b = int(input("Enter second number"))
    ad =a +b

    f= open("Addition.txt","a+")
    f.write("\n"+str(ad))
    f.seek(0)
    q=f.read()
    print(str(a)+"+"+str(b)+"=" +str(ad))
    print(q)
    f.close()

    ReplyDelete
  6. # Biodata
    f= open("Biodata.doc","w+")
    f.write("Name - Parag")
    f.write("\n Occupation - Financial Advisor")
    f.write("\n DOB -26/11/1992")
    f.write("\n Manglik- No")
    f.write("\n Address- Indore")
    f.seek(0)
    q = f.read()
    print(q)
    f.close()

    ReplyDelete
  7. # Horoscope
    f=open("Horoscope.txt","w+")
    f.write("Aries- It is beat to not loosen the pursestrings till you become financially stable")
    f.write("\n Taurus - Money will come in as word about your skills gets around. taking break to go on a vaction is indicated")
    f.write("\n Cancer- Purchasing an expensive item can prove heavy on the pocket.")
    f.write("\n Leo- Agood understanding with spouse will bring happiness into your life.")
    f.write("\n Virgo- Homemakers will manage to reset the house")
    f.write("\n Libra- Paperwork regarding property is set to get completed soon")
    f.write("\n Scorpio - A professional advice taken from someone may not prove hundred percent correct")
    f.write("\n Sagittarius - Good preparation will find students performing well in a exam or competition")
    f.write("\n Capricon - You want to help out an elder by showing all your concern, but you can feel disappointed when it is not reciprocated.")
    f.write("\n Aquarius - You will managae to find time today to spend with family")
    f.write("\n Pisces - Family get-together will give you a chance to mingle with cousins and other relatives")
    f.seek(0)
    q= f.read()
    print(q)
    f.close()

    ReplyDelete
  8. #AKASH PATEL
    ADDITION OF TWO NUMBERS:----
    a=int(input("enter first number"))
    b=int(input("enter second number"))
    sum=a+b
    f=open("addition.txt","w+")
    f.write("a is"+str(a)+"\n b is"+str(b)+"\n sum is"+str(sum))
    f.close()

    ReplyDelete
  9. #Akash patel
    f= open("Biodata.doc","w+")
    f.write("Name - Akash Patel ")
    f.write("\n Job- Cloud Engineer ")
    f.write("\n DOB -14/07/1998 ")
    f.write("\n Manglik- No")
    f.write("\n Address- Khargone ")
    f. write("\n Zodiac Sign-pisces")
    Bdata= f.read()
    print(Bdata)
    f.close()

    ReplyDelete
  10. WAP to create complete expenses sheet?

    import time
    while True:
    o = input("\n Press w to write \n r to read \n e to exit")
    if o=='w' or o=='W':
    f = open("expenses.txt","a")
    expenseby = input("Enter expense by")
    grocerry = input("Enter grocerry details")
    milk = input("Enter milk expenses")
    rent = input("Enter rent expenses")
    date = time.asctime(time.localtime(time.time()))
    f.write("\n Today Expenses Details")
    f.write("\n Expenses By " + expenseby)
    f.write("\n")
    f.write("Grocerry:"+grocerry)
    f.write("\n")
    f.write("Milk:" +milk)
    f.write("\n")
    f.write("Rent:" +rent)
    f.write("\n")
    f.write("Date:" + date)
    f.close()
    elif o=='r' or o=='R':
    f = open("expenses.txt","r")
    f.seek(0)
    data = f.read()
    print(data)
    elif o=='e' or o=='E':
    break

    ReplyDelete
  11. x = open("biodata.txt","a")
    DOB= input("Enter DOB")
    name = input("Enter name")
    caste = input("Enter caste")
    job = input("Enter JOB")
    gender=input("enter gender")
    x.write("\n biodata Details")
    x.write("\n date of birth " + DOB)
    x.write("\n")
    x.write("name:"+name)
    x.write("\n")
    x.write("caste:" +caste)
    x.write("\n")
    x.write("job:" +job)
    x.write("\n")
    x.write("gender:" + gender)
    x.close()
    x = open("biodata.txt","r")
    x.seek(0)
    data = x.read()
    print(data)

    ReplyDelete
  12. #Program to create a resume using file handling?
    while True:
    o = raw_input("\n Press w to write \n r to read \n e to exit")
    if o=='w' or o=='W':
    f=open("resume.txt","w+")
    f.write("\n **************Resume**********\n")
    Name = raw_input("\n Enter your Name \n")
    f.write("\n Name --"+Name)
    Email_Id = raw_input(" \n Enter your Email \n ")
    f.write("\n Email --"+Email_Id+"\n")
    Address = raw_input("\n Enter your address \n")
    f.write("\n Address --"+Address)
    career_objective = raw_input("\n Enter career objectives \n")
    f.write("\n career objectives --"+career_objective)
    f.write("\n ************Academic Credentials************\n")
    PG= raw_input("\n Enter post graduation \n")
    per=raw_input("your percentage = ")
    f.write("\n post gradutaion --"+PG+"percentage --"+per+"% \n")
    G= raw_input("\n Enter graduation \n")
    per=raw_input("your percentage = ")
    f.write(" \ngradutaion --"+G+"percentage --"+per+"% \n")
    HS= raw_input("\n Enter Higher secondary \n")
    per=raw_input("your percentage = ")
    f.write("\n Higher secondary --"+HS+"percentage --"+per+"% \n")
    Hsc= raw_input("\n Enter High school \n")
    per=raw_input("your percentage = ")
    f.write("\n high school --"+Hsc+"percentage --"+per+"% \n")
    ITskill=raw_input("Enter your IT Skill --\n ")
    f.write=("\n ITskill - "+ ITskill +"\n")
    experienced=raw_input("Enter your experienced")
    f.write=(experienced+" -- years experienced \n")
    f.write("\n ************personal profile************\n")
    fathername=raw_input("Enter father name = ")
    f.write("\n Father Name --"+fathername+"\n")
    mothername=raw_input("Enter mother name = ")
    f.write("\n mother Name --"+mothername+"\n")
    DOB=input("Enter your date of birth")
    f.write("\n DOB -- "+DOB+"\n")
    gender=raw_input("Enter your gender")
    f.write("\n Gender --"+gender)
    f.seek(0)
    data = f.read()
    print(data)
    f.close()
    elif o=='e' or o=='E':
    break

    ReplyDelete
  13. #Create Expenses System using File Handling Program with read & write mode w+?
    import time
    import os
    while True:
    o = raw_input("\n Press w to write \n r to read \n e to exit")
    if o=='w' or o=='W':
    f = open("expenses.txt","w+")
    expenseby = raw_input("Enter expense by = ")
    grocerry = int(input("Enter grocerry expense = "))
    milk = int(input("Enter milk expenses = "))
    rent = int(input("Enter rent expenses = "))
    date = time.asctime(time.localtime(time.time()))
    f.write("\n Today Expenses Details")
    f.write("\n Expenses By = " + expenseby)
    f.write("\n")
    f.write("Grocerry: "+str(grocerry))
    f.write("\n")
    f.write("Milk: " +str(milk))
    f.write("\n")
    f.write("Rent: " +str(rent))
    f.write("\n")
    f.write("Date: " + date)
    f.write("\n")
    total=grocerry+milk+rent
    f.write("Total expense = "+str(total))
    f.seek(0)
    data = f.read()
    print(data)
    f.close()
    elif o=='e' or o=='E':
    break

    ReplyDelete
  14. # WAP to create complete biodata for a marriage proposal?
    while True:
    o = raw_input("\n Press w to write \n r to read \n e to exit")
    if o=='w' or o=='W':
    f=open("biodata.txt","w+")
    f.write("\n ***********Biodata for Marriage**********\n")
    Name = raw_input("Enter your Name --")
    f.write("\n Name --"+Name+"\n")
    DOB=raw_input("Enter your date of birth --")
    f.write("\n date of birth --"+ DOB +"\n")
    height=raw_input("Enter your Height --")
    f.write("\n Height --"+height+"\n")
    weight=raw_input("Enter your weight --")
    f.write("\n weight --"+weight+"\n")
    Education=raw_input("Enter your Education --")
    f.write("\n Education --"+Education+"\n")
    Profession=raw_input("Enter your Profession --")
    f.write("\n Profession --"+Profession+"\n")
    Hobbies=raw_input("Enter your Hobbies --")
    f.write("\n Hobbies --"+Hobbies+"\n")
    Religion=raw_input("Enter your Religion --")
    f.write("\n Religion --"+Religion+"\n")
    fathername=raw_input("Enter father name --")
    f.write("\n Father Name --"+fathername+"\n")
    mothername=raw_input("Enter mother name -- ")
    f.write("\n mother Name --"+mothername+"\n")
    Email_Id = raw_input("Enter your Email --")
    f.write("\n Email_Id --"+Email_Id+"\n")
    Address = raw_input("Enter your address --")
    f.write("\n Address --"+Address+"\n")
    f.seek(0)
    data = f.read()
    print(data)
    f.close()
    elif o=='e' or o=='E':
    break

    ReplyDelete
  15. SACHIN KUMAR GAUTAM


    #) WAP to create complete biodata for a marriage proposal user input?
    import time
    f=open("biodata.txt","a")
    name=input("Enter the name")
    dob=input("Enter the dob")
    caste=input("Enter your caste")
    horoscope=input("Enter the your horoscope")
    education=input("complete education")
    job=input("job info")
    date=time.asctime(time.localtime(time.time()))
    f.write("name:"+name)
    f.write("\n")
    f.write("dob:"+dob)
    f.write("\n")
    f.write("caste:"+caste)
    f.write("\n")
    f.write("horoscope:"+horoscope)
    f.write("\n")
    f.write("education:"+education)
    f.write("\n")
    f.write("job:"+job)
    f.write("\n")
    f.close()

    ReplyDelete
  16. # WAP to perform the addition of two numbers and write the output of addition under file?
    while True:
    o = raw_input("\n Press w to write \n r to read \n e to exit")
    if o=='w' or o=='W':
    x=int(input("Enter first number = "))
    y=int(input("Enter second number ="))
    z=x+y
    f=open("addition.txt","w+")
    f.write("x is"+str(x)+"\n y is"+str(y)+"\n sum is"+str(z))
    f.seek(0)
    data = f.read()
    print(data)
    f.close()
    elif o=='e' or o=='E':
    break

    ReplyDelete
  17. # WAP to create complete biodata for a marriage proposal
    # Ankit Saxena

    bd=open("Marrige Bio-Data","a")
    print("-----Bio Daata (Enter You Details)-----")
    date = time.asctime(time.localtime(time.time()))
    name=input("Enter Your Name: ")
    father =input("Father's Name: ")
    mother=input("Mother's Name: ")
    dob=input("Date of Birth: ")
    place=input("Place of Birth: ")
    mobile=input("Mobile No.: ")
    address=input("Address: ")
    cast=input("Cast: ")
    gotra=input("Gotra: ")
    language=input("Language: ")
    height=input("Hight: ")
    qualification=input("Qualification: ")
    occupation=input("Occupation: ")
    hobbies=input("Hobbies: ")
    bd.write("Date: " + date)
    bd.write("Name: " + name)
    bd.write("\n")
    bd.write("Father: " + father)
    bd.write("\n")
    bd.write("Mother: " + mother)
    bd.write("\n")
    bd.write("Date of Birth: " + dob)
    bd.write("\n")
    bd.write("Place: " + place)
    bd.write("\n")
    bd.write("Mobile No.: " + mobile)
    bd.write("\n")
    bd.write("Address: " + address)
    bd.write("\n")
    bd.write("Cast: " + cast)
    bd.write("\n")
    bd.write("Gotra: " + gotra)
    bd.write("\n")
    bd.write("Language: " + language)
    bd.write("\n")
    bd.write("Height: " + height)
    bd.write("\n")
    bd.write("Occupation: " + occupation)
    bd.write("\n")
    bd.write("Hobbies: " + hobbies)
    print("---- details has been completed ----")
    print("\n")
    bd.close()

    ReplyDelete
  18. # WAP to create horoscope software
    # Ankit Saxena
    while True:
    option=input("Press to\n w to Write \n r to Read \n e to Exit \n Enter Your Choice: ")
    if option=='w' or option=='W':
    hs = open("horoscope.txt","a")
    Aries=input("Enter Aries Horoscope Details: ")
    Taurus=input("Enter Taurus Horoscope Details: ")
    Gemini=input("Enter Gemini Horoscope Details: ")
    Cancer=input("Enter Cancer Horoscope Details: ")
    Leo=input("Enter Leo Horoscope Details: ")
    Virgo=input("Enter Virgo Horoscope Details: ")
    Libra=input("Enter Libra Horoscope Details:")
    Scorpio=input("Enter Scorpio Horoscope Details: ")
    Sagittarius=input("Enter Sagittarius Horoscope Details: ")
    Capricorn=input("Enter Capricorn Horoscope Details: ")
    Aquarius=input("Enter Aquarius Horoscope Details: ")
    Pisces=input("Enter Pisces Horoscope Details: ")

    hs.write("Aries:-" + Aries)
    hs.write("\n")
    hs.write("Taurus:-" + Taurus)
    hs.write("\n")
    hs.write("Gemini:-" + Gemini)
    hs.write("\n")
    hs.write("Cancer:-" + Cancer)
    hs.write("\n")
    hs.write("Leo:-" + Leo)
    hs.write("\n")
    hs.write("Virgo:-" + Virgo)
    hs.write("\n")
    hs.write("Libra:-" + Libra)
    hs.write("\n")
    hs.write("Scorpio:-" + Scorpio)
    hs.write("\n")
    hs.write("Sagittarius:-" + Sagittarius)
    hs.write("\n")
    hs.write("Capricorn:-" + Capricorn)
    hs.write("\n")
    hs.write("Aquarius:-" + Aquarius)
    hs.write("\n")
    hs.write("Pisces:-" + Pisces)
    hs.close()
    elif option=='r' or option=='R':
    hs = open("horoscope.txt","r")
    data = hs.read()
    print(data)
    elif option=='e' or option=='E':
    break

    ReplyDelete
  19. f=open("Horoscope.txt","w+")

    f.write("Aries - If you are aiming to marry soon, you can start making preparations today. However, before you take the final decision, it would be better to look at both sides of the coin, advises Ganesha." )
    f.write("\n Taurus - This day appears to be earmarked for a long shopping spree. Ganesha sees you doing the rounds of malls, markets, dollar stores and bargain counters." )
    f.write("\n Cancer - A string of domestic responsibilities awaits you; today, you are about to realise that it is a long, long string.")
    f.write("\n Leo - Nothing will overshadow your love for your kids today, and they will be the number one priority for you..")
    f.write("\n Virgo - You will begin your journey on the long, hard road to success, predicts Ganesha." )
    f.write("\n Libra - Today promises a definite sense of pride and joy from children who bring home glory, says Ganesha.")
    f.write("\n Scorpio - In all probability, your mood is extremely hawkish today. Your belligerence may even put off Lady Luck for the time being.")
    f.write("\n Sagittarius - Your business is all set to expand with you making the most of your overseas contacts.")
    f.write("\n Capricon - You want to help out an elder by showing all your concern, but you can feel disappointed when it is not reciprocated.")
    f.write("\n Aquarius - Success never comes easy, but in your case, it will make an exception, says Ganesha.")
    f.write("\n Pisces - Family get-together will give you a chance to mingle with cousins and other relatives")

    a= input(" today horosocope of ")
    a_dict={}
    a_file=open("Horoscope.txt",'r')
    for line in a_file:
    key,value=line.split(' - ')
    a_dict[key]=value

    if a in a_dict:
    print(a_dict.get(a))
    a_file.close()

    ReplyDelete
  20. #simple intrest
    p = float(input("enter amount"))
    r = float(input("enter rate"))
    t = float(input("enter time"))
    si = (p*r*t)/100
    f = open("sicalc.txt","a+")
    f.write("Amount is "+str(p)+ "\n Rate is "+str(r)+ "\n Time is "+str(t))
    f.write("Result is "+str(si))
    f.seek(0)
    data = f.read()
    print(data)
    f.close()

    ReplyDelete
  21. #biodata
    f= open("Biodata.doc","w+")
    name= input("enter name")
    school= input("enter school name")
    education= input("enter education")
    address= input("enter address")
    manglik= input("manglik")
    cast= input("enter cast")
    dob= input("enter dob")
    f.write("FULL Name - " +name)
    f.write("\n SCHOOL - " +school)
    f.write("\n EDUCATION - " +education)
    f.write("\n ADDRESS - " +address)
    f.write("\n MANGLIK- " +manglik)
    f.write("\n CAST - " +cast)
    f.write("\n Date of birth - " +dob)
    f.seek(0)
    q = f.read()
    print(q)
    f.close()

    ReplyDelete
  22. a=int(input("enter first no "))
    b=int(input("enter second no"))
    c=a+b
    f=open("add2no.txt","w+")
    f.write("1st no is"+str(a)+"\n2no is"+str(b)+"\n total is"+str(c))
    f.seek(0)
    d=f.read()
    print(d)
    f.close()

    ReplyDelete
  23. to perform the addition of two numbers and write the output of addition under file

    x=int(input("enter 1st number : "))
    y=int(input("enter 2nd number : "))
    z=x+y
    a=open("addition.txt","w+")
    a.write("x is"+str(x)+"\n y is"+str(y)+"\nsum is"+str(z))
    a.close()

    ReplyDelete
  24. n=input("enter name")
    fn=input("enter father name")
    mn=input("enter mother name")
    dob=input("enter date of birth")
    i=input("enter intrest areas")
    ed=input("enter education")
    o=input("enter ocupation")
    f=open("bio.txt","w+")
    f.write("Name:"+str(n)+"\nFather name:"+str(fn)+"\nMother name:"+str(mn)+"\nDate of birth"+str(dob)+"\nIntrest:"+str(i)+"\nEnter Education"+str(ed)+"\nEnter Occupation"+str(o))
    d=f.read()
    print(d)
    f.close()

    ReplyDelete
  25. n=int(input("enter your birth month"))
    f=open("Horoscope.txt","w+")
    if n==1:
    f.write("Aries- It is beat to not loosen the pursestrings till you become financially stable")
    elif n==2:
    f.write("\n Taurus - Money will come in as word about your skills gets around. taking break to go on a vaction is indicated")
    elif n==3:
    f.write("\n Cancer- Purchasing an expensive item can prove heavy on the pocket.")
    elif n==4:
    f.write("\n Leo- Agood understanding with spouse will bring happiness into your life.")
    elif n==5:
    f.write("\n Virgo- Homemakers will manage to reset the house")
    elif n==6:
    f.write("\n Libra- Paperwork regarding property is set to get completed soon")
    elif n==7:
    f.write("\n Scorpio - A professional advice taken from someone may not prove hundred percent correct")
    elif n==8:
    f.write("\n Sagittarius - Good preparation will find students performing well in a exam or competition")
    elif n==9:
    f.write("\n Capricon - You want to help out an elder by showing all your concern, but you can feel disappointed when it is not reciprocated.")
    elif n==10:
    f.write("\n Aquarius - You will managae to find time today to spend with family")
    elif n==11:
    f.write("\n Pisces - Family get-together will give you a chance to mingle with cousins and other relatives")
    f.seek(0)
    q= f.read()
    print(q)
    f.close()

    ReplyDelete
  26. #File Handeling using W+

    s = open("C:/Users/abhis/Desktop/Abhifilehandeling/resume.txt","w+")
    s.write('"Our courses"')
    s.write("\n1> Python")
    s.write("\n2> Java")
    s.write("\n3> php")
    s.write("\n4> Software Testing")
    s.write("\n5> ASP.Net")
    s.write("\n6> Advance Java")
    s.write("\n7> Angular")
    s.write("\n")
    s.write('"\n> Visit our institute website:- https://shivaconceptsolution.com/"')
    s.write("\n")
    s.write('"\n> Address:- M6 First Floor, Kanchan Sagar, Near Industry House, Palasia Indore"')
    s.write('"\n> Email us:- shivasirtutorials@gmail.com"')
    s.write("\n> Call at :- H.O. 07805063968, 0731-4069788")
    s.close()
    ___________________________________________________________
    OUTPUT:-
    "Our courses"
    1> Python
    2> Java
    3> php
    4> Software Testing
    5> ASP.Net
    6> Advance Java
    7> Angular
    "
    > Visit our institute website:- https://shivaconceptsolution.com/"
    "
    > Address:- M6 First Floor, Kanchan Sagar, Near Industry House, Palasia Indore""
    > Email us:- shivasirtutorials@gmail.com"
    > Call at :- H.O. 07805063968, 0731-4069788

    ReplyDelete
  27. data=open("student.txt","w+")
    data.write("Biodata of the student")
    data.write("\n Name = Pritesh Mahajan")
    data.write("\n Mobile Number = 8889615090")
    data.write("\n Date of Birth = 1/Nov/1997")
    data.write("\n Gender = Male")
    data.write("\n Blood Group = O+")
    data.write("\n Email ID = priteshmahajan@gmail.com")
    data.write("\n Educational Qualification =B.E(Mechanical)")
    data.write("\n Marital Status = Single")
    data.write("\n Nationality = Indian")
    data.write("\n Religion = Hindu")
    data.write("\n Permanent Address = Ring Road Near Radisson blu Hotel")
    data.write("\n Hobbies = Cricket, Gymming")
    data.write("\n Language Known =Hindi, English")
    data.close()

    ReplyDelete
  28. #MArksheet manager

    f=open("Marksheet.text","a+")
    name= input("Enter name:")
    physics=input("Enter physics marks:")
    chemistry=input("Enter chemistry marks:")
    maths=input("Enter maths marks:")
    f.write("\n")
    f.write("Student name:"+name)
    f.write("\n")
    f.write("Physics marks:"+physics)
    f.write("\n")
    f.write("Chemistry marks:"+chemistry)
    f.write("\n")
    f.write("Maths marks:"+maths)
    f.seek(0)
    data=f.readlines()

    x=0
    for i in data:
    if i[0]=="P" or i[0]=="C" or i[0]=="M":

    x=x+int(i[i.find(":")+1:])
    print("The total marks is:",x)


    f.close()

    ReplyDelete
  29. #Marksheet.

    math = float(input("enter marks: "))
    hindi = float(input("enter marks: "))
    english = float(input("enter mark: "))
    physics = float(input("enter mark: "))
    chemistery = float(input("enter mark: "))
    total = math+hindi+english+physics+chemistery
    per = total/5
    print("per is","=",per,"%")
    data = open("Marksheetusingfilehandeling.txt","w+")
    data.write("-----Abhishek Parihar-----")
    data.write("\n")
    data.write(" Math: "+str(math)+ "\n Hindi: "+str(hindi)+ "\n English: "+str(english)+ "\n Physics: "+str(physics)+ "\n Chemistery: "+str(chemistery))
    data.write("\n")
    data.write("> result is "+str(per))
    data.write("\n")
    data.write("Pass")
    data.seek(0)
    f=data.read()
    print(f)
    data.close()
    __________________
    output
    __________
    -----Abhishek Parihar-----
    Math: 87.0
    Hindi: 78.0
    English: 89.0
    Physics: 90.0
    Chemistery: 92.0
    > result is 87.2
    Pass

    ReplyDelete
  30. #WAP to using write methad "w"?
    f = open("E://FileSachin.txt","w")
    f.write("My first program using file handling")

    f.close()

    ReplyDelete
  31. #WAP to using read methad "r"?
    f = open("E://FileSachin.txt","r")
    s=f.read()
    print(s)


    f.close()

    ReplyDelete
  32. #Create Student Details System using File Handling Program:-
    import time
    f = open("E://Filesachin2.txt","w")
    stdname = input("Enter Student Name ")
    address = input("Enter Student address ")
    rollno = int(input("Enter Student Roll Number "))
    college = input("Enter Student college Name ")
    date = time.asctime(time.localtime(time.time()))
    f.write("Sudent Details")
    f.write("\n")
    f.write("Student Name:"+stdname)
    f.write("\n")
    f.write("Student Adress:"+address)
    f.write("\n")
    f.write("Student Roll Number:"+str(rollno))
    f.write("\n")
    f.write("Student College Name:"+college)
    f.write("\n")
    f.write("date:"+date)
    f.close()

    ReplyDelete
  33. #Student Details System program to append mode:-
    import time
    f = open("E://Filesachin2.txt","a")
    stdname = input("Enter Student Name ")
    adress = input("Enter Student Adress ")
    rollno = int(input("Enter Student Roll Number "))
    collegename = input("Enter Student College Name ")
    date = time.asctime(time.localtime(time.time()))
    f.write("Student Details")
    f.write("Student Name:"+stdname)
    f.write("\n")
    f.write("Student adress:"+adress)
    f.write("\n")
    f.write("Student Roll Number:"+str(rollno))
    f.write("\n")
    f.write("Student college Neme:"+collegename)
    f.write("\n")
    f.write("Date"+date)
    f.close()

    ReplyDelete
  34. #Wap To Calculate Triangele Using File Handling "W+" ?
    base = int(input("enter Base "))
    heigth = int(input("Enter heigth "))
    Area = (base*heigth)/2
    f = open("E://Filesachin3.txt","w+")
    f.write("\n Base of Triangle "+str(base) + "\n Heigth of Triangle "+str(heigth))
    f.write("\n Area Is "+str(Area))
    f.seek(0)
    data = f.read()
    print(data)
    f.close()

    ReplyDelete
  35. #@WAP to perform the addition of two numbers and write the output of addition under file?
    f=open("C:\\files\\add.txt","w")
    a=int(input("1:"))
    b=int(input("2:"))
    c=a+b
    f.write(f"result of addition: {c}")
    f.close()

    ReplyDelete
  36. Pawan singh Rathore
    Batch (11 AM to 12 PM )

    import time
    f=open("Resume1.doc","w")
    name=input("enter your name")
    mobile=int(input("enter mobile number"))
    email=input("enter email id")
    address=input("enter your address")
    graduation=input("enter graduation")
    school1=input("enter higher secondary")
    school2=input("enter higher secondary")
    sub=input("enter sub")
    father_name=input("enter father name")
    dob=input("enter dob")
    marital=input("enter marital")
    gender=input("enter gender")
    nationlity=input("enter nation")
    date=time.asctime(time.localtime(time.time()))
    place=input("enter place")
    f.write(name+"\n")
    f.write("Mobile:"+str(mobile)+"\n")
    f.write("Email:"+str(email)+"\n")
    f.write("Address:"+str(address)+"\n")
    f.write("\nCARRIER OBJECTIVE \n")
    f.write("I am seeking job and i will work with full honesty and learn new skills \n")
    f.write("\nQUALIFICATION \n")
    f.write("Graduation "+graduation+"\n")
    f.write(str(school1)+"\n")
    f.write(str(school2)+"\n")
    f.write("\nTRANING \n")
    f.write(str(sub)+"\n")
    f.write("\nPERSONAL PROFILE \n")
    f.write("Father Name :"+str(father_name)+"\n")
    f.write("Date of Birth :"+str(dob)+"\n")
    f.write("Marital status :"+str(marital)+"\n")
    f.write("Gender :"+str(gender)+"\n")
    f.write("Nationality :"+str(nationlity)+"\n")
    f.write("\nDECLARATION \n")
    f.write("I hereby declare that all the information given above is true and authentic as per my knowledge.\n")
    f.write("\nDate :"+str(date)+"\n")
    f.write("Place :"+str(place)+"\n")
    f.close()

    ReplyDelete

POST Answer of Questions and ASK to Doubt