1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Novay_Z [31]
3 years ago
5

2. Now write a program named filereader.py that reads and displays the data in friends.txt. This program should also determine a

nd print the average age of the friends on file. That will require an accumulator and a counter. Use a while loop to process the file, print the data, and modify the accumulator and counter. Then close the file and display the average age accurate to one decimal place. See the Sample Output.. SAMPLE OUTPUT My friend Denny is 24 My friend Penny is 28 My friend Lenny is 20 My friend Jenny is 24 Average age of friends is 24.0

Computers and Technology
1 answer:
Andrew [12]3 years ago
6 0

Answer:

see explaination

Explanation:

# python code filereader.py

import sys

import readline

from sys import stdin

import random

## Open the file with read only permit

f = open('inputfile.txt')

## Read the first line

sum = 0.0

count = 0

#read file till the file is empty

while True:

line = f.readline()

if ("" == line):

print "Average age of friends is", sum/count

break

list = line.split()

print "My friend ",list[0], " is", list[1]

sum = sum + int(list[1])

count = count + 1

f.close()

'''

inputfile.txt

Denny 24

Penny 28

Lenny 20

Jenny 24

output:

My friend Denny is 24

My friend Penny is 28

My friend Lenny is 20

My friend Jenny is 24

Average age of friends is 24.0

see screenshot at attachment

You might be interested in
Garrett wants to search through a csv file to find all rows that have either the name John or Bob in them and display them out t
Olin [163]

Answer:

A.  grep -E "(John|Bob)" salesemployees.csv

Explanation:

The grep command is used to search text. It searches the given file for lines containing a match to the given strings or words.

How to use Grep Command:

grep 'letter' filename – Search any line that contains word 'letter' in filename on Linux

grep -i 'Alphabet' file1 – A case-insensitive search for the word ‘Alphabet’ in Linux and Unix

grep -R 'root' . – Search all files in the current directory and in all of its subdirectories in Linux for the word ‘root’

8 0
3 years ago
Jane wants to type a math assignment involving percentages she wants to insert the percent symbol after typing a number which ke
borishaifa [10]
To type a percent symbol. Press shift+5.
8 0
3 years ago
E-mail is an temporary message medium.<br> a. True<br> b. False
Volgvan

E-mail stands for Electronic mail. It is a method of exchanging messages ("mail") between people in a telecommunication network with the usage of electronic devices. There is a sender and a receiver for any given message, and they switch positions in turn.

The statement that E-mail is an temporary message medium is false. E-mail can be kept forever and are not temporary.


6 0
3 years ago
Read 2 more answers
Write an application that encodes English-language phrases into pig Latin. Pig Latin is a form of coded language. There are many
deff fn [24]

Answer:

Answer has been attached to this response as a source code file saved as "PigLatinWord.java"

Explanation:

Explanation has been added to the source code in the form of comments. Please go through the comments in the code.

Hope this helps!

Download java
3 0
4 years ago
You have a network that occupies the top floor of a three-story building. The WAN service provider has installed the line for th
patriot [66]

Answer:

Demarc Extension.

Explanation:

In this scenario, you have a network that occupies the top floor of a three-story building. The wide area network (WAN) service provider has installed the line for the WAN service in a wiring closet on the main floor.

Hence, you would use the Demarc Extension to relocate the WAN line into a wiring closet on your floor.

A Demarc Extension refers to a cabling channel or transmission path which typically originates from the interface of an internet service provider known as demarcation point to the termination point present at the premises of the end users, usually far from the minimum point of entry (MPOE).

4 0
3 years ago
Other questions:
  • What limits the impact of vehicle balance on view ghost ability during emergency vehicle maneuvers?
    15·1 answer
  • Select the most likely outcome of making only on-time minimum payments to a credit card with a balance for an entire year?
    7·2 answers
  • The chain of command is an unbroken line of authority that extends from the top of the organization to the lowest echelon and cl
    7·1 answer
  • What is a society that has moved to the internet Rather than relying on physical media called
    11·1 answer
  • Explain how software is distinct from hardware.
    8·2 answers
  • Which of the following contains hardware systems similar to the affected organization but does not host live data?
    13·1 answer
  • What is the term for a media piece that is ineligible for protection by copyright laws,
    15·1 answer
  • Which statement gives an advantage of multicellular organisms?
    7·2 answers
  • Hi good morning how are you all
    12·2 answers
  • Out of all the social media tools available today, the best tool to start when beginning your social marketing efforts is which
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!