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
Which type of microscope can only be used to view non-living specimens?
Fynjy0 [20]

Answer is D: Electronic microscope

An electronic microscope has greater resolving power and much higher magnifications. Most high-resolution electron microscope cannot be used to image living cells because the particle beam of powerful electrons used to illuminate a specimen also destroys the samples. Engineers, however, are coming up with ways to overcome this critical limitation by using quantum mechanical measurement. Quantum mechanical measurement will help avoid damage to the specimen by sensing objects remotely without ever hitting the imaged object.

5 0
3 years ago
Read 2 more answers
A web page created expressly in hopes of ranking well for a term in a search engine's organic/non-paid listings and which itself
Irina18 [472]

Answer:

doorway page

doorway page

doorway pages

Explanation:

A website consists of many web pages linked together.

A web page refers to specific information provided by a website that is displayed to a user in an internet browser.

A web page is written in HTML. It may contain text, graphics, and hyperlinks to other web pages and files.

As per the given question,

A web page created expressly in hopes of ranking well for a term in a search engine's organic/non-paid listings and which itself does not deliver much information to those viewing it. Instead, visitors will often see only some enticement on the <u>doorway page</u> leading them to other pages, or they may be seamlessly redirected to a real page within the existing web site. With cloaking, visitors may never see the <u>doorway page</u> at all. Several search engines have guidelines against <u>doorway pages</u>, though they are more commonly allowed in through paid inclusion programs.

7 0
3 years ago
Suppose a data broker correctly identifies that your grandmother is addicted to playing online hearts. From its business intelli
lara31 [8.8K]

Answer:

Check the explanation

Explanation:

A. No. the act of selling customer's data for financial advantages and gain without the permission of customer is illegal and so unethical.

B. No. even though the Grandmother choice by itself but selling out her game data to broker without letting the concerned person know about it is not allowed.

C. Yes. It was Grandmothers' choice to play certain kind of game. As gambling vendor provides a fare game they are not doing any bad.

4 0
3 years ago
The software concept ___________and defines a need for the new system.
lubasha [3.4K]

Answer:

application

hope it helps you

3 0
3 years ago
Write a single statement that assigns avg_sales with the average of num_sales1, num_sales2, and num_sales3.
sammy [17]

Answer:

Explanation:

try numpy:

import numpy as np

print(np.average([3, 4, 8]))

output:

5.0

3 0
3 years ago
Other questions:
  • How do the principles behind the Agile Manifesto suggest approaching architecture?A. Architecture emergesB. Architecture is not
    10·1 answer
  • Which field in a Transmission Control Protocol (TCP) header provides the next<br> expected segment?
    5·1 answer
  • Given that Apache and Internet Information Services (IIS) are the two most popular web application servers for Linux and Microso
    10·1 answer
  • me pueden ayudar con mi trabajo sii porfss si me dan la respuesta correcta y les doy la mejor coronita si​
    12·1 answer
  • Think back on the Font Tester App. Can you think of an example of another app or feature of an app which would use a loop to con
    14·1 answer
  • Make a list of five primary raw materials, for each one, indicate and industrial material that is created from it
    10·2 answers
  • What is a document you can create with word-processing software
    9·1 answer
  • In a List of Positive Integers, Set MINIMUM to 1. For each number X in the list L, compare it to MINIMUM. If X is smaller, set M
    11·1 answer
  • We can save our data peremently on a
    7·2 answers
  • A small square at the right corner of the table is what?​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!