Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
Question
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
- Open the source code file named Flowers.py
- Write a while loop to read the input until EOF is reached.
- In the body of the loop, print the name of each flower and where it can be grown (sun or shade).
- Execute the program.
Transcribed Image Text:# Flower Sunlight Preferences
This document contains a list of flowers along with their sunlight preferences. Each flower name is followed by either "Sun" or "Shade," indicating whether the flower thrives better in sunny conditions or shaded areas.
### List of Flowers and Sunlight Preferences:
1. **Astilbe** - Shade
2. **Marigold** - Sun
3. **Begonia** - Sun
4. **Primrose** - Shade
5. **Cosmos** - Sun
6. **Dahlia** - Sun
7. **Geranium** - Sun
8. **Foxglove** - Shade
9. **Trillium** - Shade
10. **Pansy** - Sun
11. **Petunia** - Sun
12. **Daisy** - Sun
13. **Aster** - Sun
This information is useful for gardeners to understand which flowers to plant based on the available sunlight in their gardens.
Transcribed Image Text:Certainly! Below is the transcribed content from the image for an educational website context:
---
**Python Script: Understanding Flowers.py**
This Python script, titled `Flowers.py`, is designed to read the names of flowers and determine whether they thrive in sun or shade. It retrieves this information from an input file and displays it on the user’s screen. Here’s a breakdown of the script structure:
**Purpose:**
- To read and display flower names alongside their growing preferences (sun or shade).
**Inputs:**
- The information is sourced from a file named `flowers.dat`.
**Outputs:**
- Displays the names of flowers with the associated words "sun" or "shade" on the screen.
**Script Overview:**
```python
# Flowers.py - This program reads names of flowers and whether they are best suited for shade
# or sun from an input file and prints the information to the user's screen.
# Input: flowers.dat.
# Output: Names of flowers and the words sun or shade.
# Open input file
# Write while loop here
# Print flower name using the following format
# print(var + " grows in the " + var2)
```
**Instructions:**
- The script needs to open the input file (`flowers.dat`), presumably containing the necessary data.
- A while loop is suggested for iterating over the entries in the file.
- Each flower name should be printed using the format: `print(var + " grows in the " + var2)`, where `var` is the flower name and `var2` indicates whether it grows in the sun or shade.
**Note:**
- Completing the script requires implementing the file opening mechanism and the logic for reading and printing data in a loop structure.
This basic framework serves as an initial guide for understanding file handling and conditional data display in Python.
---
Expert Solution
Check MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
This is a popular solution
bartleby
Trending nowThis is a popular solution!
bartleby
Step by stepSolved in 5 steps with 3 images
Knowledge Booster
Background pattern image
Similar questions
- A while loop is a form of Select one: a. transitive loop b. definite loop c. indefinite loop d. finite looparrow_forward4. Write a python program with a loop that asks the user to enter a series of positive numbers. The user should enter a negative number to signal the end of the series. After all the positive numbers have been entered, the program should display the largest and smallest of the numbers entered.arrow_forwardPythonarrow_forward
- 2. Write a program that uses a while loop to play a number guessing game. The computer should pick a number using random number generation and then continue asking the user to guess the number until they get it right. For each, gues, the computer should tell the user if the guess is too high or too low or is correct. 3. Using nested for loops, right a program that displays a bar chart (using asterisks) for a number entered by the user. For example, if the user enters 4, the bar chart looks like this:arrow_forwardPlease write a python program that follows the following criteria: Write a program that asks the user to enter the amount that he or she has budgeted for a month. A loop should then prompt the user to enter each of his or her expenses for the month and keep a running total. When the loop finishes, the program should display the amount that the user is over or under budget. Thanks so much for your help!arrow_forwardUsing a Counter-Controlled whileLoop Summary In this lab, you use a counter-controlled while loop in a Java program provided for you. When completed, the program should print the numbers 0 through 10, along with their values multiplied by 2 and by 10. The data file contains the necessary variable declarations and some output statements. Instructions Ensure the file named Multiply.java is open. Write a counter-controlled while loop that uses the loop control variable to take on the values 0 through 10. Remember to initialize the loop control variable before the program enters the loop. In the body of the loop, multiply the value of the loop control variable by 2 and by 10. Remember to change the value of the loop control variable in the body of the loop. Execute the program by clicking Run. Record the output of this program.arrow_forward
- Construct a single for loop to print out the following lines. You may use as many variables as you wish, but you may not use multiple loops. 4 4 4 8 2 7 16 1 10 32 0.5 13 64 0.25 16arrow_forwardPlease help me with this question in python using psedocode details. I have attached both pictures below:-arrow_forwardIn python, create a while Loop Create a while loop that will print the John Wayne quote "Slap some bacon on a biscuit and let's go! We're burnin' daylight!" five times; each sentence on a separate line.arrow_forward
- Write a Python code This lab requires you to write a complete program using a condition controlled loop, a counter controlled loop, and an accumulator. The program is as follows: Write a program that will allow a grocery store to keep track of the total number of bottles collected for seven days. The program will calculate the total number of bottles returned for the week and the amount paid out (the total returned times .10 cents). The output of the program should include the total number of bottles returned and the total paid out. The program will ask the user if they have more data to enter and will end the program if they do not. Step 1: In the pseudocode below, declare the following variables under the documentation for Step 1. A variable called totalBottles that is initialized to 0 This variable will store the accumulated bottle values A variable called counter and that is initialized to 1 This variable will control the loop A variable called todayBottles...arrow_forwardPython questionarrow_forwardTrue/False 9. A loop is used to skip over a section of a programarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Text book imageComputer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONText book imageComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceText book imageNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Text book imageConcepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningText book imagePrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationText book imageSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY