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
Ber [7]
3 years ago
13

Write a program to store water usage data of 4 customers in a text file. The program asks the user to enter account number, cust

omer type (R for residential or B for business), and number of gallons used for each of the 4 customers. Store the data in a text file named "water.txt". Overwrite old data in "water.txt" if the file already exists. The following is an example.
Enter account number: 3147
Enter R for residential, B for business: R
Enter number of gallons used: 1000
Enter account number: 2168
Enter R for residential, B for business: R
Enter number of gallons used: 6002
Enter account number: 5984
Enter R for residential, B for business: B
Enter number of gallons used: 2000
Enter account number: 7086
Enter R for residential, B for business: B
Enter number of gallons used: 8002
The example above writes the following data to the file "water.txt":
3147 R 1000
2168 R 6002
5984 B 2000
7086 B 8002
Please answer with code i can use with pycharm for python programming?
Computers and Technology
1 answer:
posledela3 years ago
4 0

Answer:

The program for this question can be given as:

Program:

def main():

    f= open("water.txt","w+")

    for i in range(4):

        f.write(input('Enter account number:\r\n'))

        f.write(input('Enter R for residential,B for business:\r\n'))

        f.write(input('Enter number of gallons used:\r\n'))

    f.close()    

if __name__== "__main__":

 main()

Output:

Enter account number:12

Enter R for residential,B for business:R

Enter number of gallons used:12345

Enter account number:13

Enter R for residential,B for business:B

Enter number of gallons used:8906

Enter account number:11

Enter R for residential,B for business:B

Enter number of gallons used:56789

Enter account number:10

Enter R for residential,B for business:R

Enter number of gallons used:12348

create a file water.text

12R12345

13B8906

11B56789

10R12348

Explanation:

In the above python program firstly we define the main function in this function we use the f.open() function. This function helps to open a file, and returns its values as a file object. In this function, we pass the file name and mode that is "water.txt" and "w+". The "w+" mode is used for writing mode and  If the file does not exist then it will create a new file and "+" is used for reading and writing (updating) the file. Then we will use the input() function. This function helps to take input from the user. then we will close the file and end the main function.

You might be interested in
When a program lets the user know that an invalid menu choice has been made, this is an example of?
kolezko [41]

The question has the multiple choices below

A) Input validation
B) output correction
C) compiler criticism
D) output validation

The answer is (A) Input validation

Also known as data validation, it is the correct and proper testing of any input supplied by an application or a user. It prevents wrongly formed data from entering the system. Applications should be able to check and validate every input entered into the system since it is hard to detect a malicious user trying to gain entry into software.










5 0
3 years ago
Imagine you're in charge of managing an annual fest at your school. You have to select students and assign them different tasks.
kenny6666 [7]

Answer:

Quality traits are important in many ways. A persons traits identifies them of how they treat you or how you might treat them. It is important to find good working people for the job. For example if one student is good at a specific task I might put them in that task or if another is good at stocking shelves or finding books I might put them in the library to help students find books. It is important as a supervisor to find people that listen and follow instructions not people that mess around and are unorganized. These qualities and traits are important to see the real potential of the employees. Finding the right people for the job will help the school and you as the supervisor to manage these employees. Making a application or employment sheet will help to find the right people making a sheet with some questions and have the potential employees fill it out to find their traits and skills.

Explanation:

Sorry I didn't have much background information on what you wanted me to write hope this works you can edit and change stuff though.

Also run this through Grammarly's plagiarism tester to see if it is plagiarism!

5 0
3 years ago
Im doing a computer project and I would need some help
lisabon 2012 [21]
- Tons of celebrities live in California. You have the kardashians, youtubers and internet stars, musicians, millionaires, etc.

-California is known for gold, silicon, etc.

-Some words that describe California are "economic", "melting pot", "adventurous" "beaches" "Hollywood" "sunny" etc.
6 0
3 years ago
PLZ ANSWER I WILL GIVE BRAINLIEST
scoray [572]

Answer:

The correct answer is A, spreadsheets. Spreadsheet programs are similar to and include Excel, with grids of cells for organizing numerical data

7 0
3 years ago
Read 2 more answers
HOW MANY PROGRAMMING LANGUAGES SHOULD I LEARN TO MAKE A GAME LIKE AGAR.IO, SLITHER.IO ETC
maria [59]

Answer:

learn to make slither

Explanation:

it is such a cool game

also please can you heart and like my comment and rate it 5 stars please and give it brainliest pls i beg you thx !!!

8 0
3 years ago
Other questions:
  • Suppose we are given an arbitrary digraph G = (V, E) that may or may not be a DAG. Modify the topological ordering algorithm so
    8·1 answer
  • What is the program that searches through data bases?
    10·1 answer
  • The term _____ refers to computers that are among the fastest of any in the world at the time of their introduction.
    6·1 answer
  • In risk management what does risk evaluation involved
    14·1 answer
  • If an individual column is listed in a SELECT clause, along with a group function, the column must also be included in a(n) ____
    12·1 answer
  • ANY MHA FANS SAY DEKU
    6·1 answer
  • "Look at the following code. Which line will cause a compiler error?
    8·1 answer
  • Select three physical forms of storage. USB drive Primary cache Magnetic storage Secondary cache Dynamic RAM Optical drive
    7·2 answers
  • Who is the father of computer​
    7·1 answer
  • A web server on your network hosts your company's public website. You want to make sure that an NIC failure doesn't prevent the
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!