Summary In this lab, you open a file and read input from that file in a prewritten Python program. The program should read and print the names of flowers and whether they are grown in shade or sun....


Summary


In this lab, you open a file and read input from that file in a prewritten Python program. The program should read and print the names of flowers and whether they are grown in shade or sun. The data is stored in the input file named flowers.dat.


Instructions



  1. Open the source code file named Flowers.py

  2. Write a while loop to read the input until EOF is reached.

  3. In the body of the loop, print the name of each flower and where it can be grown (sun or shade).

  4. Execute the program.


Flowers.py<br>flowers.dat<br>+<br>1 Astilbe<br>2 Shade<br>3 Marigold<br>4 Sun<br>5 Begonia<br>6 Sun<br>7 Primrose<br>8 Shade<br>9 Cosmos<br>10 Sun<br>11 Dahlia<br>12 Sun<br>13 Geranium<br>14 Sun<br>15 Foxglove<br>16 Shade<br>17 Trillium<br>18 Shade<br>19 Pansy<br>20 Sun<br>21 Petunia<br>22 Sun<br>23 Daisy<br>24 Sun<br>25 Aster<br>26 Sun<br>27<br>

Extracted text: Flowers.py flowers.dat + 1 Astilbe 2 Shade 3 Marigold 4 Sun 5 Begonia 6 Sun 7 Primrose 8 Shade 9 Cosmos 10 Sun 11 Dahlia 12 Sun 13 Geranium 14 Sun 15 Foxglove 16 Shade 17 Trillium 18 Shade 19 Pansy 20 Sun 21 Petunia 22 Sun 23 Daisy 24 Sun 25 Aster 26 Sun 27
Flowers.py<br>flowers.dat<br>+<br>1 # Flowers.py - This program reads names of flowers and whether they are g<br>or sun from an input<br>2 # file and prints the information to the user's screen.<br>3 # Input: flowers.dat.<br>4 # Output: Names of flowers and the words sun or shade.<br>5<br>6 # Open input file<br>7<br>8 # Write while loop here<br># Print flower name using the following format<br>10<br># print(var +<br>grows in the

Extracted text: Flowers.py flowers.dat + 1 # Flowers.py - This program reads names of flowers and whether they are g or sun from an input 2 # file and prints the information to the user's screen. 3 # Input: flowers.dat. 4 # Output: Names of flowers and the words sun or shade. 5 6 # Open input file 7 8 # Write while loop here # Print flower name using the following format 10 # print(var + grows in the " + var2) 11

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here