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
Java question
skad [1K]

Answer:

To be honest why would you want to enter one character. Anyways the answer is option 4

6 0
3 years ago
Write an application that allows a user to enter the names and birth dates of up to 10 friends. Continue to prompt the user for
mylen [45]
Sorry I don’t know the answer I am really sorry
5 0
3 years ago
Imagine a mythical set of protocols with the following details. Maximum Link-Layer data frame: 1,455 bytes Network-Layer header
NemiM [27]

Answer:

The MSS is 1455

Explanation:

MSS or maximum segment size is the total number of data transferred minus the TCP and IP header. The total number of transmitted frames in a switch network is between 64 bytes to 1518 bytes with a header and trailer. The MSS does not exclude this data-link layer effect but only the transport layer like TCP and UDP, and IP address header, unlike the mtu (maximum transfer unit) which involves all headers.

4 0
3 years ago
When a Select Case statement executes, the value of the test expression is compared with the values that follow each of the ____
goldenfox [79]

Answer:

Case

Explanation:

In Computer programming, a variable can be defined as a placeholder or container for holding a piece of information that can be modified or edited.

Basically, variable stores information which is passed from the location of the method call directly to the method that is called by the program.

For example, they can serve as a model for a function; when used as an input, such as for passing a value to a function and when used as an output, such as for retrieving a value from the same function. Therefore, when you create variables in a function, you can can set the values for their parameters.

A Select Case statement can be defined as a conditional statement that avails software developers or programmers the ability to test a variable by comparing it with a list of values.

In a Select Case statement, each variable is referred to as a Case.

Generally, when a Select Case statement executes, the value of the test expression is compared with the values that follow each of the Case keywords.

7 0
3 years ago
Blank text has a darker apperance than normal texts
sammy [17]
That's cool, I guess. What was the question?
4 0
3 years ago
Other questions:
  • Because log-on procedures may be cumbersome and tedious, users often store log-on sequences in their personal computers and invo
    6·1 answer
  • Adult learners understand a topic best by doing it. It gives them both new skills and confidence in their ability to carryout th
    6·1 answer
  • In which of the following ways can using test-taking tips help you?
    7·1 answer
  • The help desk received a call from a user who cannot get any print jobs to print on the locally shared printer. While questionin
    10·2 answers
  • What is it called when an attacker convinces you to enter personal information at an imposter website after receiving an email f
    10·2 answers
  • Which type of choir often sings AND dances while they perform?
    9·1 answer
  • _____________________________________________________is a pre-designed format to help users with the creation of a document, lik
    6·1 answer
  • Henry has created a software product that manages a database of company clients. He wants to install the software on a client's
    13·1 answer
  • Cyber vulnerabilities to dod systems may include
    12·1 answer
  • Numerous engineering and scientific applications require finding solutions to a set of equations. Ex: 8x + 7y = 38 and 3x - 5y =
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!