Access Millions of academic & study documents

6 Write a python program that opens an output file with the filenam

Content type
User Generated
Showing Page:
1/2
6. Write a python program that opens an output file with
the filename careers.txt, writes 5 careers that you find
interesting to that file, and then closes the file.
Solution
>>> f = open(\'output\', \'w\') #open actual file
>>> print f
#create new text file
file = open(\"careers.txt\", \"w\")
#writing five carees
>>> file.write(\"digital career\")
>>> file.write(\"consulting carrer\")
>>> file.write(\"leadership carrer\")
>>> file.write(\"technology carrer\")
>>> file.write(\"services career\")
>>> file.close()
#look in the carerrs.txt, we can see the text that we wrote:
$ cat careers.txt

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/2

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
6. Write a python program that opens an output file with the filename careers.txt, writes 5 careers that you find interesting to that file, and then closes the file. Solution >>> f = open(\'output\', \'w\') #open actual file >>> print f #create new text file file = open(\"careers.txt\", \"w\") #writing five carees >>> file.write(\"digital career\") >>> file.write(\"consulting carrer\") >>> file.write(\"leadership carrer\") >>> file.write(\"technology carrer\") >>> file.write(\"services career\") >>> file.close() #look in the carerrs.txt, we can see the text that we wrote: $ cat careers.txt ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4