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
Given the following MIPS Code Fragment:
galben [10]

Answer:

There are 3 Data Hazard

Explanation:

Find attached the solution

6 0
3 years ago
Develop a CPP program to test is an array conforms heap ordered binary tree. This program read data from cin (console) and gives
mafiozo [28]

Answer:

Following are the code to this question:

#include<iostream>//import header file

using namespace std;

int main()//defining main method

{

int ar[7];//defining 1_D array that stores value      

int i,x=0,l1=1,j; //defining integer variable

for(i=0;i<7;i++)//defining for loop for input value from user ends  

{

cout<<"Enter a Number: ";//print message

cin>>ar[i];//input value in array

if(l1<=2 && i>0)//using if block that checks the array values  

{

x++;//increment the value of x by 1  

}

if(l1>2 && i>0)//using if block that checks the array values  

{

l1=l1-2;//using l1 variable that decrases the l1 value by 2  

}

j=i-x;//using j variable that holds the index of the root of the subtree

if(i>0 && ar[j]>ar[i])// use if block that checks heap condition  

{

l1++; //increment the value of l1 variable

}

if(i>0 && ar[j]<ar[i])// using the if block that violate the heap rule  

{

cout<<ar[i]<<" "<<"Violate the heap";//print message with value

break;//using break keyword  

}

}

return 0;

}

Output:

1)

Enter a Number: -15

Enter a Number: -5

-5 Violate the heap

2)

Enter a Number: 45

Enter a Number: 0

Enter a Number: 55

55 Violate the heap

Explanation:

  • In the above-given C++ language code, an array "ar" and other integer variables " i,x,l1, j" is declared, in which "i" variable used in the loop for input values from the user end.
  • In this loop two, if block is defined, that checks the array values and in the first, if the block it will increment the value of x, and in the second if the block, it will decrease the l1 value by 2.
  • In the next step, j variable is used that is the index of the root of the subtree. In the next step, another if block is used, that checks heap condition, that increment the value of l1 variable. In the, if block it violate the heap rule and print its values.
5 0
3 years ago
In a typical e-mail address the host is
Tresset [83]
The receiver of an e-mail message. 
7 0
3 years ago
XBRL: a. Is an XML-based language b. Can be read by almost any software package and easily searched by Web browsers c. All of th
Tema [17]

Answer:

c. All of these choices are correct

Explanation:

XBRL (eXtensible Business Reporting Language) is a freely available and global framework for exchanging business information which uses XML-based data tags to describe financial statements for both public and private companies. It is a normalized version of XML. It leverages efficiencies of the Internet as today’s primary source of financial information by making Web browser searches more accurate and relevant.

Therefore, options a, b and d can be identified in the above definition of XBRL. Therefore,all the choices are correct.

6 0
3 years ago
____ is the phase of a technology cycle characterized by technological substitution and design competition. question 9 options:
lilavasa [31]
Innovation streams is the answer i believe


6 0
3 years ago
Other questions:
  • Which option is referred to by the Animals tag?
    5·1 answer
  • Match the element of a presentation program to its description
    11·1 answer
  • What are the features of the Outline view in Word? Select three options.
    12·2 answers
  • Which of these is a Microsoft certification for system engineers?
    9·1 answer
  • What is a main cause of an aurora?
    8·1 answer
  • Erik is the president and owner of Watch Out, a local website development company that helps clients create and build unique web
    15·1 answer
  • 1. When the Cisco 2950 switch is first turned on, it behaves like a hub. Why is this so, and what must happen before the switch
    5·1 answer
  • Who is the first computer programmer​
    14·2 answers
  • When a user problem cannot be solved by the help desk at the first level of resolution, the problem is ___________ to the second
    7·1 answer
  • Fifteen years ago, everyone didn't have a cell phone. Anyone developing an app would not have found many users. Today, the exist
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!