Open the file hostdata.txt for reading.

Python - files: find a solution for each following:

Open the file hostdata.txt for reading

Answer

#1)

host=open("hostdata.txt", "r")

#2)

winter=open("winter2003.txt", "r")

spring=open("spring2003.txt", "r")

summer=open("summer2003.txt", "r")

fall=open("fall2003.txt", "r")

#3)

summary=open("yearsummary.txt", "w")

#4)

pi = open("pi","w+")

pi.write("3.14159")

pi.close()

#5)

data1 = open("data1.txt","r")

data2 = open("data2.txt","w+")

for line in data1:

data2.write(line)

data1.close()

data2.close()

#6). execution = open("execution.log","a") execution.write("Program Execution Successful")

#7). corpdata.close()

#8).

inp = open("rawdata","r")

datum = 0

for line in inp:

datum = int(line)

print datum

inp.close()

#9 sentence = "This is a sentence" length = len(sentence) print length

#10).

value = "www.turingscraft.com"

address = "http://"+value

print address

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts