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
damaskus [11]
2 years ago
14

Write a program that computes and prints the average of the numbers in a text file. You should make use of two higher-order func

tions to simplify the design.
Computers and Technology
1 answer:
lara [203]2 years ago
4 0

Answer:import functools

# open your file

file = open("integers.txt", 'r')

file = file.read()

# put numbers into a list

file = file.split()

# convert list into integers

file = list(map(int, file))

# use lambda function to get average.

print(functools.reduce(lambda x, y: x+y / len(file), file, 0))

Explanation:

You might be interested in
Uses of keyboard as a input device
KATRIN_1 [288]

helps us for typing letters, numbers and symbols etc.

3 0
3 years ago
Read 2 more answers
Write a program that prompts for a positive integer and prints the factors of all integers from 1 to that input integer. For exa
xeze [42]
74(Frequency) or 34(frequency)
7 0
3 years ago
PC’s & More has shifted to sales and service of laptops and PCs, where it has the potential to triple the number of its cust
photoshop1234 [79]

Answer:

Growth Strategy

Explanation:

A growth strategy is a plan of action that allows you to achieve a higher level of market share than you currently have. Such as the case in the question, PC's shifted so sales and service of Laptops and PCs because there is a greater market share for them there than where they currently operate from.

5 0
3 years ago
Cell styles can only be applied to the first five columns of a worksheet.<br> a.true<br> b.false
andreyandreev [35.5K]
The correct answer is A true! 
6 0
3 years ago
Read 2 more answers
For this exercise, you are going to complete the printScope() method in the Scope class. Then you will create a Scope object in
iragen [17]

Answer:

Explanation:

The following is the entire running Java code for the requested program with the requested changes. This code runs perfectly without errors and outputs the exact Sample Output that is in the question...

public class ScopeTester

{

public static void main(String[] args)

{

       Scope scope = new Scope();

       scope.printScope();

}

}

public class Scope

{

private int a;

private int b;

private int c;

public Scope(){

a = 5;

b = 10;

c = 15;

}

public void printScope(){

       System.out.println("a = " + a);

       System.out.println("b = " + b);

       System.out.println("c = " + c);

       System.out.println("d = " + getD());

       System.out.println("e = " + getE());

}

public int getA() {

return a;

}

public int getB() {

return b;

}

public int getC() {

return c;

}

public int getD(){

int d = a + c;

return d;

}

public int getE() {

int e = b + c;

return e;

}

}

4 0
3 years ago
Other questions:
  • The mouse and keyboard are also sometimes called
    5·1 answer
  • Can i earn money at weegy.com ?
    10·1 answer
  • Which directory in the FHS stores programs and configuration information that can only be executed and modified by the root user
    10·1 answer
  • Create a function named first_a that uses a list comprehension. The function will take a single integer parameter n. Find every
    13·1 answer
  • The operating system’s application programming interface (API) provides software developers with tools they use to build applica
    5·1 answer
  • Assume that an array named salarySteps whose elements are of type int and that has exactly five elements has already been declar
    12·1 answer
  • Charlie makes pizza at a restaurant. The customers always compliment how great the pizza tastes. But Charlie takes a long time t
    7·2 answers
  • Help Me<br><br> What are the four types of graphic models?
    10·1 answer
  • Which similar computer network components connect multiple devices?
    7·1 answer
  • When you're writing for mobile devices, use ________ to present the most important information first and provide successive laye
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!