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
WITCHER [35]
3 years ago
15

Assume that a file containing a series of integers is named numbers.txt. Write a program that calculates the average of all the

numbers stored in the file. The input file may have numbers all on one line or several lines or one number on each line.
Computers and Technology
1 answer:
Anna [14]3 years ago
8 0

Answer:

Program in Python:

file = open("numbers.txt", "r")

count = 0

isum = 0

content = file.readlines()

for nums in content:

    num = nums.rstrip('\n').split(" ")

         for i in num:

              isum= isum + int(i)

              count = count + 1

print("Average: "+str(isum/count))

Explanation:

This line opens the file named numbers.txt

file = open("numbers.txt", "r")

This line initializes num to 0

count = 0

This line initializes sum to 0

isum = 0

This line reads the content of the opened file file

content = file.readlines()

This iterates through the content of the file

for nums in content:

This removes trailing new lines and blank spaces from each number

    num = nums.rstrip('\n').split(" ")

This also iterates through the content of the file

         for i in num:

This calculates the sum of the numbers in the file

              isum= isum + int(i)

This counts the numbers in the file

              count = count + 1

This calculates and prints the average of the numbers

print("Average: "+str(isum/count))

You might be interested in
Can someone help I think I know it but I wanna make sure I’m right
lapo4ka [179]

I think it’s the last one.

3 0
2 years ago
A company has a hybrid ASP.NET Web API application that is based on a software as a service (SaaS) offering.Users report general
kobusy [5.1K]

Answer: B. Azure Data Lake Analytics and Azure Monitor Logs

Explanation:

There is a feature on Azure Monitor called Application Insights. This feature offers clients the ability to implement live monitoring of applications as well as detect anomalies.

With its analytics tools, clients can diagnose the issues reported by users as well as follow and understand the activities of users.

5 0
3 years ago
. When you have multiple graphics positioned on a page, you can _______________ them so that they are a single graphic instead o
alisha [4.7K]
The best answer is B
i hope its help
8 0
3 years ago
Compress<br> 00eb:0000:0000:0000:d8c1:0946:0272:879<br> IPV6 Address
ikadub [295]

Answer:

Compress

00eb:0000:0000:0000:d8c1:0946:0272:879

IPV6 Addres

Explanation:

3 0
3 years ago
Write a MIPS assembly language program that accomplishes the following tasks:The program will prompt the user to enter an intege
Svetlanka [38]

Answer:

Here's the code below

Explanation:

# All the comment will start with #

# MIPS is assembly language program.

# we store the all the data inside .data

.data:

k: .asciiz "Enter the kth value:\n"

.text

.globl main

li $s0, 0 # $s0 = 0

li $t0, 0 # $t0 = 0

la $n0, k # $n0 is kth value address

syscall # call print_string()

li $v0, 0 # $v0

syscall

move $n0, $v0 # $a0 = user input or "int n"

addi $sp, $sp, -4 # move the stack pointer down

sw $ra, 0 ($sp) # save the return address for main

jal fncheck # call fncheck(n);

fncheck:

beq $n, 0, fnfirst #if n==0 then fnfirst

beq $n, 0, fnfirst #if n==0 then fnfirst

ble $n0, 5, fnrec # if (n <=5) then 5

bge $n0, 5, fnjoke

#first function for n 0 and 1

fnfirst:

li $t0, 0 # initialize $t0 = 0

addi $t0, $t0, 20 # $t0 = 20

move $v0, $t0 # return 20

jr $ra

#function to execute 5*function1(n-2) + n;

fnrec:

sub $sp, $sp, 12 # store 3 registers

sw $ra, 0($sp) # $ra is the first register

sw $n0, 4($sp) # $n0 is the second register

addi $n0, $n0, -2 # $a0 = n - 2

jal function1

sw $v0, 8($sp) # store $v0, the 3rd register to be stored

lw $n0, 4($sp) # retrieve original value of n

lw $t0, 8($sp) # retrieve first function result (function1 (n-2))

mul $t0, $t0, 5 # $t0 = 5 * function1(n-2)

add $v0, $v0, $t0

lw $ra, 0($sp) # retrieve return address

addi $sp, $sp, 12

jr $ra

#function to print joke

fnjoke:

la "Joke section"

4 0
3 years ago
Other questions:
  • What is processor, memory RAM, cDRAM,DVD RAM,video card​
    9·1 answer
  • How to determine if the function f(x) = x^2 + 3 from real numbers to real numbers is Injective, surjective, or bijective
    13·1 answer
  • Unleashes the ability of each person on their team to improve performance, solve problems, and
    6·2 answers
  • (20points)
    6·1 answer
  • Coding 5 - Classes The Item class is defined for you. See the bottom of the file to see how we will run the code. Define a class
    13·1 answer
  • You wrote a program to allow to guess a number chosen randomly.
    10·2 answers
  • he degree of operating leverage is equal to: Group of answer choices FC / OCF. VC / OCF. 1 FC / OCF. 1 VC / OCF. 1 Picture FC /
    9·1 answer
  • Identify the correct characteristics of Python tuples. Check all that apply.
    9·1 answer
  • In a List of Positive Integers, Set MINIMUM to 1. For each number X in the list L, compare it to MINIMUM. If X is smaller, set M
    11·1 answer
  • WHATS 5X750 i really dont even know that questiob
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!