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
In 2011 a program named Watson running on an IBM supercomputer
lora16 [44]

Answer:C)Defeated the two most successful human Jeopardy! champions in a three-game match.

Explanation:  Watson emerged from the IBM supercomputer made by Thomas Watson .It is made from the two main component analytical software and the artificial intelligence which made it a optimal for the question-answer feature.

Watson defeated Ken Jennings and Brad Rutter(earlier successful contestants) in the program named Jeopardy by answering questions correctly and quickly in 2011.Other options are incorrect because it did not worked as the software engineer,humane genome or won crossword puzzle.Thus the correct option is option (c).

8 0
2 years ago
PLEASE HELP! WILL MARK AS BRAINLIEST JavaScript can be implemented using the _________ HTML tags in a web page.​
Keith_Richards [23]

Answer:

JavaScript can be implemented using JavaScript statements that are placed within the ...  HTML tag

Explanation:

8 0
2 years ago
Read 2 more answers
When would you use an omnidirectional microphone?
alina1380 [7]

Answer:

when it is a windy day and you want to reduce the sound of the wind in the recording

5 0
3 years ago
Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binar
mylen [45]

Answer:

The program to this question can be described as follows:

Program:

num= int(input('Enter a number: ')) #input value by user

st = '' #defining string variable

while num > 0: #define loop to calculte values binary number

   val= num % 2 # holding remainder (0 or 1) in val variable

   st =st+str(val) # store value in str variable

   num = num//2 #calculte quotient value

print("binary number is: ",st)

Output:

Enter a number: 5

binary number is:  101

Explanation:

Program description as follows:

Firstly the "num" variable is declared, for user input, then an "st" variable is declared, to calculates user input value binary number.

In the next step, a while loop is declared, inside the loop, another variable "Val" is declared, that holds value remainders, which is added on the "st" variable.

Outside the loop, the print method is used, that prints st variable holds value.

3 0
3 years ago
Which delivery model is an example of a cloud computing environment that provides users with a web based email service ?
Evgen [1.6K]

Cloud computing, also known as cloud services, cloud concepts or simply the cloud, is a paradigm that allows to offer computer services. through a network, which is usually the Internet.

(data persistence, authentication, messaging, etc.). for example, a Linux system, a web server, and a programming environment such as Perl or Ruby).

Commercial examples are Google App ,Microsoft Azure,

3 0
3 years ago
Read 2 more answers
Other questions:
  • Write a program that reads in text from standard input (hint: use Scanner) and prints out the number of words in the text. For t
    5·1 answer
  • If you want to track users and sessions across multiple domains, what must you set up?
    11·1 answer
  • I just want to ask if some one know an online school program that offer a live session and the cost of it not to expensive. for
    10·1 answer
  • Rank these three account types in order of decreasing liquidity. Start by picking the most liquid account type first
    13·2 answers
  • Convert (65.125)10 to octal.
    7·1 answer
  • Determine which Software Type on the right best corresponds to each Definition on the left. Then, click the Definition, and then
    8·1 answer
  • Jabria are you smart
    14·2 answers
  • You are a Data Scientist at Anthem Blue Cross Blue Shield. You want to check if a patient will develop diabetes. Please write th
    5·1 answer
  • What is the main fuction of command interpreter​
    11·1 answer
  • Heeeeeeeelp :)<br> thx<br> jfdyiusjmkdsuiho;dmcvrvho;j
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!