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
The correct order of operations is _____. brackets, exponents, division, multiplication, addition, and subtraction subtraction,
bija089 [108]

brackets, exponents, division, multiplication, addition, and subtraction

6 0
3 years ago
Read 2 more answers
Which technology do online storesusually use to present customized content?
k0ka [10]

Answer:

real time analytics technology

Explanation:

Online stores usually use real-time analytics technology to present customized content. Explanation: Real-time analytics is gaining popularity nowadays. It is basically the procedure of measuring and preparing the data as it enters the database

8 0
2 years ago
Part B: Find the value of G: if A = 3, b=4, and C = 5.
antiseptic1488 [7]

Answer:

G=(A^3 + B) * 4-c^2

To calculate G if A=3, b=4 and C=5

cobegin

p1: A^3 = 27

P2:C^2 =25

P3: p1 +B =31

P4:P3*4 =124

P5:P4-P2 =99

coend

Explanation:

One operation is performed at a time, and on the basis of priority as we have only one processor.

6 0
3 years ago
Help!!
Eduardwww [97]

the undo option is the right answer



8 0
3 years ago
Read 2 more answers
HURRRYYYY PLZZ!!
vivado [14]

Answer: A. How much is this vehicle's resale value?

6 0
3 years ago
Read 2 more answers
Other questions:
  • You are reluctant to write an extra credit book report because you are afraid that your language and punctuation skills are not
    11·1 answer
  • To avoid potential documentary errors and security leaks, the configuration of firewalls should not be documented unless strictl
    5·1 answer
  • Why is it important to verify a customer complaint?
    6·1 answer
  • 1. What is Java SE?
    11·2 answers
  • The _____ search algorithm searches a list for a given item, starting with the first element and continues to compare the item w
    12·1 answer
  • By the 1990s, ______________ technology enabled one person operating a desktop computer to control most—or even all—of these fun
    8·2 answers
  • What is the relationship between agile teams and project requirements
    9·1 answer
  • In which of the following movies, multimedia's special effect is used ? *
    8·2 answers
  • Question 2 of 25
    11·1 answer
  • Discussion Topic
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!