Question: File output Instructions Some coding practice. This one is straightforward. To output to a file in Python, we use the following syntax: with open('file_for_output.txt',

File output

Instructions 

 Some coding practice.  This one is straightforward.  To output to a file in Python, we use the following syntax:

with open('file_for_output.txt', 'w') as open_file:
    open_file.write('blah blah test test')

where "file_for_output.txt" can be changed to whatever you want the output file to be.

For this assignment, the name of your output file should be "Ozymandias.txt"

Output the following poem using a separate "write" command for each line of the poem below.  Be sure to test your code to make sure it works.

What to submit: your Python code file; attach here 

The poem to output:


Ozymandias by Percy Shelley
I met a traveller from an antique land
Who said: ‘Two vast and trunkless legs of stone
Stand in the desert. Near them, on the sand,
Half sunk, a shattered visage lies, whose frown,
And wrinkled lip, and sneer of cold command,
Tell that its sculptor well those passions read
Which yet survive, stamped on these lifeless things,
The hand that mocked them and the heart that fed.
And on the pedestal these words appear —
“My name is Ozymandias, king of kings:
Look on my works, ye Mighty, and despair!”

Step by Step Solution

3.40 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Sure you can use Python to output the poem Ozymandias to a file named Ozymandiastxt using the ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!