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
devlian [24]
3 years ago
15

Write a Python program that uses function(s) for writing to and reading from a file:

Computers and Technology
1 answer:
swat323 years ago
6 0

import random

def random_number_file_writer(nums):

   f = open("random.txt", "w")

   i = 0

   while i < nums:

       f.write(str(random.randint(1,500))+"\n")

       i += 1

   f.close()

def random_number_file_reader():

   f = open("random.txt", "r")

   total = 0

   count = 0

   for x in f.readlines():

       total += int(x)

       count += 1

   print("The total of the numbers is "+str(total))

   print("The number of random numbers read from the file is "+str(count))

def main():

   random_number_file_writer(int(input("How many random numbers do you want to generate? ")))

   random_number_file_reader()

main()

I hope this helps!

You might be interested in
E-commerce transactions that are executed using wireless mobile devices are known as
LUCKY_DIMON [66]

Answer:

Answer is Mobile commerce

4 0
3 years ago
Which device makes telecommunications possible?
Dmitrij [34]
A. modem or d. voice input. Not a port because a port allows one to insert a peripheral device but not really communicate. I have no idea what an expansion slot is. It could be d. voice input because this allows a person to hold an audible conversation.

But  I'd go for modem because a modem lets you connect devices like laptops, tablets, phones, computers etc. and share data between them. So things like mailing are possible (I THINK)!  <span />
7 0
3 years ago
What is full form of RAM??? ​
stepladder [879]

Answer:

Random Access Memory, it's used to store working data and machine codes

Explanation:

Hope it helped !
Adriel

7 0
2 years ago
Read 2 more answers
When creating a mail merge, you must insert all of the items from your data source into your merged document. Truth or false ?
ElenaW [278]
True <----------------
3 0
3 years ago
Read 2 more answers
How can anger cause workplace accidents?
Umnica [9.8K]
I think the corect answer is c
8 0
3 years ago
Read 2 more answers
Other questions:
  • Describe encryption at gateways in thePresentation layer of the OSI Reference Model
    6·1 answer
  • Which layer defines an interface that applications can use to request network services, rather than referring directly to applic
    5·1 answer
  • Which of the following is true? A)Checks and Debit Cards both withdraw money directly from a bank account. B)Checks are the most
    13·2 answers
  • In the RGB model, which color is formed by combining the constituent colors?
    14·2 answers
  • Summarizes statistical data ?
    11·1 answer
  • Which format is best for the image below?
    12·1 answer
  • Can anyone help me<br> I will make you a brainalist
    13·1 answer
  • If a small monster collector:- Has 16 small monster containment devices and intends to use all of them.
    10·1 answer
  • Why is Linux widespread in academic environments?
    7·1 answer
  • POINT AND BRAINLIEIST GIVE AWAY!!!
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!