1. Write a program in python with no imports named filemaker.py that will be used to store the first name and age of some friends in a text file named friends.txt. The program must use a while loop that prompts the user to enter the first name and age of each friend. Each of these entries should be written to its own line in the text file (2 lines of data per friend). The while loop should repeat until the user presses Enter (Return on a Mac) for the name. Then, the file should be closed and a message should be displayed. See Sample Output.SAMPLE OUTPUT Enter first name of friend or Enter to quit DennyEnter age (integer) of this friend 24Enter first name of friend or Enter to quit PennyEnter age (integer) of this friend 28Enter first name of friend or Enter to quit LennyEnter age (integer) of this friend 20Enter first name of friend or Enter to quit JennyEnter age (integer) of this friend 24Enter first name of friend or Enter to quitFile was created 2. Now write a program named filereader.py that reads and displays the data in friends.txt. This program should also determine and 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 24My friend Penny is 28My friend Lenny is 20My friend Jenny is 24Average age of friends is 24.0   ANSWER #2

Question

1. Write a program in python with no imports named filemaker.py that will be used to store the first name and age of some friends in a text file named friends.txt. The program must use a while loop that prompts the user to enter the first name and age of each friend. Each of these entries should be written to its own line in the text file (2 lines of data per friend). The while loop should repeat until the user presses Enter (Return on a Mac) for the name. Then, the file should be closed and a message should be displayed. See Sample Output.
SAMPLE OUTPUT

Enter first name of friend or Enter to quit Denny
Enter age (integer) of this friend 24
Enter first name of friend or Enter to quit Penny
Enter age (integer) of this friend 28
Enter first name of friend or Enter to quit Lenny
Enter age (integer) of this friend 20
Enter first name of friend or Enter to quit Jenny
Enter age (integer) of this friend 24
Enter first name of friend or Enter to quit
File was created

2. Now write a program named filereader.py that reads and displays the data in friends.txt. This program should also determine and 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

 

ANSWER #2

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times vary by subject and question complexity. Median response time is 34 minutes and may be longer for new subjects.

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: Question in Image. I was wondering why they are not equal even thought their contents are the same

A: Code:

Q: Given the assumptions above and the page table below, translate the following virtual addresses (exp...

A: Assuming the page size to be 4KB. The calculations for physical addresses are given below: (a) VA = ...

Q: Compiler returning errors with calculations and declarations. Screenshot of File.txt included.  ...

A: The code is working fine as I have tested it and the Output is attached at the end.Code://importing ...

Q: Implement the following two methods in javascript:   String multiply2(String num) - return num*2 wit...

A: Program Instructions:In the function multiply2(), take one digit at a time, multiply it by two, and ...

Q: The prompt asks: Write a function that calculates the amount of money a person would earn over a per...

A: Program Approach-1)Define function named totalEarned () with years as a parameter.2)Declare and init...

Q: Explain why web application security is vital. What could happen to an insecure application? Why is ...

A: Web application securityWeb application security testing ensures that the information system is capa...

Q: Write a recursive function rec_string that produces the output shown below for the corresponding fun...

A: Program Algorithm-STARTStep1: Define the rec_string method.Step2: Compare the length of string to ze...

Q: Write a program in python with no imports named filemaker.py that will be used to store the first na...

A: Create a file named filemaker.pyPrompt user for name of a friend and his age repeatedly until user e...

Q: Exercise 1 Consider a hash table of size 13, and assume open addressing with linear probing   Show ...

A:  As the given size of the table is 13, as well as the number of elements to be inserted in the table...