Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

File Handling Operation in Python:-


The file is a collection of records, if we want to store program output permanently under a computer harddisk then we can use file handling operation.

File handling provide multiple operations on a file


Python Provide a predefined method to manage file handling operation.

1 open():-  using this method we can open the file for operation, if the file not exist then it will create the file.

  f = open("filename",mode)    # w for write ,r for read ,w+ for write|read,r+ for read|write,a for append, a+ append and read

2 write():-  this method is used to write content into a file.

f.write(data)

code for write

f = open("student.txt","w")
f.write("student information")
f.close()

3 read()

code for read

f = open("student.txt","r")
s=f.read()
print(s)
f.close()


  s = f.read()
  print(s)



..................................................................................................................

4 append file:-

code for append

f = open("student.txt","a")
s = input("write content")
f.write(s)

f.close()

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,


Create Expenses System using File Handling Program:-

import time
f = open("expenses.txt","w")
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("Today Expenses Details")
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()



Expenses System program to append mode:-

import time
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("-------------*------------")
f.write("Today Expenses Details 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.write("-------------*------------")
f.close()



Expenses System Write and Read using Single File?

import time
f = open("expenses.txt","w+")
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("-------------*------------")
f.write("Today Expenses Details 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.write("-------------*------------")
f.seek(0)
s = f.read()
print(s)
f.close()




Expenses System Example With Append Mode:-

import time
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("-------------*------------")
f.write("Today Expenses Details 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.write("-------------*------------")
f.seek(0)
s = f.read()
print(s)
f.close()










Program of file handling using class and object:-

class FileOperation:
    def createFile(self):
       self.f = open("info.txt","a+")
    def writeFile(self):
      title = input("Enter title")
      self.f.write("\n"+title)
      desc = input("Write content")
      self.f.write("\n"+desc)
    def readFile(self):
      self.f.seek(0)  #it will reset cursor position to any index
      res = self.f.read()
      print(res)
      self.f.close()

obj = FileOperation()
obj.createFile()
obj.writeFile()
obj.readFile()


Program to create a resume using file handling?

f = open("resume1.doc","w+")
f.write("Objective")
f.write("\n I am seeking job and i will work with full honesty and learn new skills")
f.write("\n Qualification")
f.write("\n I have completed BTECH from IPS college Indore")
f.write("\n Academic Qualification")
f.write("\n 10th 80% \n 12th 90% ")
f.close()



Program to calculate SI using P, R, and T?

p = float(input("enter amount"))
r = float(input("enter rate"))
t = float(input("enter time"))
si = (p*r*t)/100
f = open("sicalc.txt","w")
f.write("Amount is "+str(p)+ "\n Rate is "+str(r)+ "\n Time is "+str(t))
f.write("Result is "+str(si))
f.close()


Program to calculate Simple Interest using Write and Read Mode?

p = float(input("enter amount"))
r = float(input("enter rate"))
t = float(input("enter time"))
si = (p*r*t)/100
f = open("sicalc.txt","w+")
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()


Program to calculate Simple Interest using Append and Read Mode?

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()




Assignment:-

1)  WAP to perform the addition of two numbers and write the output of addition under file?


2)  WAP to create complete biodata for a marriage proposal?


3)  WAP to create horoscope software?










25 Comments

If you have any doubt in programming or join online classes then you can contact us by comment .

  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

Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post