EXERCISES Create a 3D array named book with K pages, each page with M lines and each line containing N columns where user inputs values for K, M and N. The array is of type int and fill the array with random integers between 5 and 55. Display the initial contents of the array, page by page, for each page the columns on each row appear on a line (i.e. each row on its own line). Mark the beginning of the pages by showing page index. Sort the pages of the book in ascending order based on the sum of all the integers on that page. Any sorting algorithm is ok. Display pages after sorting. Free the memory taken up by the array. Having meaningful functions is a must. Such as, MakeBook, FillBookWith RandomValues, DisplayBook, GetPageSum, Sort, CleanBook... Globals and static variables are NOT allowed.

Answers

Answer 1

The code uses the NumPy library to create and manipulate the 3D array. It defines several functions to perform the required tasks: make_book to create the array, fill_book_with_random_values to fill it with random values, display_book to print the contents of the book, get_page_sum to calculate the sum of integers on a page, sort_book to sort the pages based on their sums, and clean_book to release the memory.

```python

import numpy as np

def make_book(K, M, N):

   book = np.zeros((K, M, N), dtype=int)

   return book

def fill_book_with_random_values(book):

   for i in range(book.shape[0]):

       book[i] = np.random.randint(5, 56, size=(book.shape[1], book.shape[2]))

def display_book(book):

   for i in range(book.shape[0]):

       print("Page", i+1)

       for row in book[i]:

           print(*row)

       print()

def get_page_sum(page):

   return np.sum(page)

def sort_book(book):

   page_sums = np.array([get_page_sum(page) for page in book])

   sorted_indices = np.argsort(page_sums)

   sorted_book = book[sorted_indices]

   return sorted_book

def clean_book(book):

   del book

# User inputs

K = int(input("Enter the number of pages: "))

M = int(input("Enter the number of lines per page: "))

N = int(input("Enter the number of columns per line: "))

# Create book

book = make_book(K, M, N)

# Fill book with random values

fill_book_with_random_values(book)

# Display initial contents of the book

print("Initial contents of the book:")

display_book(book)

# Sort the pages of the book based on the sum of integers on each page

sorted_book = sort_book(book)

# Display pages after sorting

print("Pages after sorting based on the sum of integers:")

display_book(sorted_book)

# Clean up the memory

clean_book(book)

``

The user is prompted to enter the dimensions of the book, and then the program generates random integers between 5 and 55 to fill the array. It displays the initial contents of the book, sorted the pages based on their sums, and displays the sorted pages. Finally, it cleans up the memory by deleting the book object.

To know more about NumPy library, click here: brainly.com/question/24744204

#SPJ11


Related Questions

Reggie is having trouble signing into his email account at work. He picks up the phone to call someone in IT, and then checks the phone list to see who to call. Which IT area should Reggie call

Answers

The IT area that Reggie should call is called; Information Security

What are the functions of an Information Technology Department?

The IT department that Reggie should call is called Information Security department.

This is because Information security protects sensitive information from unauthorized activities such as inspection, modification, recording, and any disruption or destruction.

The aim of this department is to make sure that the safety and privacy of critical data such as customer account details, financial data or intellectual property are safe.

Read more about information technology at; https://brainly.com/question/25920220

which term is defined as an interrelated and harmonized collection of components and methods that transform inputs into​ outputs?

Answers

The term that is defined as an interrelated and harmonized collection of components and methods that transform inputs into​ outputs is known as a system.

What is Transformation in computers?

In computers, transformation may be defined as a type of process through which any activity or group of activities takes one or more inputs, transforms and adds value to them, and provides outputs for customers or clients.

According to the context of this question, a system within a set of computers must perform a sequential function in order to interrelate and harmonize the collection of components and methods that transform inputs into​ outputs.

Therefore, the term that is defined as an interrelated and harmonized collection of components and methods that transform inputs into​ outputs is known as a system.

To learn more about the Computer systems, refer to the link:

https://brainly.com/question/22946942

#SPJ1

To improve readability, what color background should I use
with dark purple text.

Answers

Answer:

umm probably white or any light color

Explanation:

cuz if you put similar colors whether color or the darkness it will be hard to read cuz its similar. ofc if you do a dark color for text you can use a much lighter shade of that color

how is an inventory of activities different from an inventory of objects?

Answers

The inventory of activities different from an inventory of objects because inventory of activities involves a record of business routine activities , while inventory of objects allows identification and recovery of an object.

What is inventory of activities and an inventory of objects

The inventory of activities entail the record of business routine activities, this could be last purchase of supplies.

The inventory of objects  on the other hand is about identification and recovery of an object and with this Inventories are detailed.

Learn more about inventory at;

https://brainly.com/question/25818989

.............. 1010111 needs to be transferred w.ith odd parity and the answer is
A. 01010111
B.11010111
C.10101110
D.10101111

Answers

Answer:

A. 01010111

Explanation:

This is because in odd parity, the number on the far left (the 8th number) would always be a 0

A! your answer is A- 01010111

which tool is used to terminate cables into a 66-block

Answers

Answer: Circuit pairs are connected to the block with a punch-down tool by terminating the tip wire on the leftmost slot of one row and ring wire on the leftmost slot of the row beneath the mating tip wire.

ASAP

There are two competing scientific theories that try to explain the illusion of animation. Which of these answers is NOT one of the competing theories?


Persistence of Vision


Image-permanence


Phi Phenomenon


The first who answers correct will get brainlest and those that are incorrected will be marked with a red flag.

Answers

It’s image-permanence. Hope that helps

Use the drop-down menus to describe the customize ribbon dialog box.
this section lists the different tabs on the ribbon.
this component helps the user reorder tabs along the ribbon.
this section lists commands to be added to or removed from the ribbon

Answers

Answer:

1. Customize the ribbon

2. This component helps the user reorder tabs along the ribbon

3. This section lists commands to be added to or removed from the ribbon

Explanation:

just got it right on edge

A ribbon tab is a group of commands that is present in word, excel, and PowerPoint. The customize the ribbon box lists the different tabs.

What is a ribbon box?

A ribbon box is an element present in the programs that include the toolbars and set of other commands clubbed together. The ribbon can be customized by following certain instructions.

The customize the ribbon section includes the lists tabs present on the ribbon, the tabs can be reordered in the ribbon by the Move up/ Move down button. The extra commands can be deleted or added by the choose command option.

Therefore, ribbons are customizable.

Learn more about ribbon box here:

https://brainly.com/question/8838379

#SPJ2

(Simple computation) The formula for computing the discriminant of a quadratic equation ax^2 + bx + c = 0 is b^2 – 4ac. Write a program that computes the discriminant for the equation 3x^2 + 4x + 5 = 0. Class Name: Exercise01_01Extra

Answers

bjj is a transformation of f and the significance of those places in your neighbourhood which are named after famous personalities and prepare a chart or table on

How to draw an animation in edhesive?

Answers

I use Edhesive for coding, but i'm pretty sure you need to g0ogle that one :/

Hope this helps <3 :)

Which two of the following skills are important for a meteorologist?
A) ability to create charts
B) customer service
C) critical thinking
D) troubleshooting
E) creativity

Answers

answer: a and d! have a good day:)

Assignment: Keep the answers short and precise (3-4 sentences). You might not find all the answers in lecture or book. Googling the unknown terms will be very useful. 1. (True/False. Explain) Longer the duration of the loan, higher the interest rate, 2. (True/False. Explain) higher the risk of the loan, lower the interest rate. 3. (True/False. Explain) $1 today is worth more than $1 tomorrow. 4. What is Initial Public Offering (IPO)? Can you buy one from another investor? 5. What is crowdfunding? 6. Differentiate public and private goods with example. 7. What is free rider problem? What kind of goods are exposed to it? 8. Explain rational ignorance. 9. What kind of resources are subject to common pool problem? 10. Define externalities. Provide some examples of negative and positive externalities.

Answers

Negative externalities include pollution while positive externalities include education.

1. False. Generally, longer the duration of the loan, lower the interest rate. 2. False. Higher the risk of the loan, higher the interest rate. 3. True. Because of inflation, money loses its value over time. 4. An Initial Public Offering (IPO) is a process in which a private company offers shares of its stocks to the public for the first time. No, you can't buy one from another investor. 5. Crowdfunding is a method of raising funds from a large number of people, typically via the internet. 6. Public goods are non-excludable and non-rivalrous while private goods are excludable and rivalrous. National defense is an example of a public good while food is an example of a private good. 7. Free rider problem occurs when people benefit from a public good without contributing towards its costs. Public goods are exposed to this problem. 8. Rational ignorance is a situation in which people choose not to invest time and effort in learning about a subject because the cost of doing so outweighs the benefits. 9. Common pool resources such as fisheries and forests are subject to the common pool problem. 10. Externalities refer to the positive or negative impacts of an economic activity on parties that are not directly involved.

Learn more about externalities here :-

https://brainly.com/question/24233609

#SPJ11

You are researching the Holocaust for a school paper and have located several Web sites for information.In three to five sentences, describe the method you would use to determine whether each Web site is a suitable source of information for your paper.

Answers

I suggest the following methods to determine whether a website is a suitable source of information for a school paper on the Holocaust:

The Method

Check the credibility of the website by examining the author's qualifications, credentials, and institutional affiliation.

Evaluate the accuracy of the information by comparing it with other reliable sources on the same topic.

Check the currency of the information by looking at the date of publication or last update. Avoid using outdated information.

Analyze the objectivity of the website by checking for any bias or slant towards a particular perspective or ideology.

Lastly, check the website's domain name and extension to verify its origin, as some domains may have questionable reputations.

Read more about sources here:

https://brainly.com/question/25578076
#SPJ1

Because of the novel Corona virus, the government of Ghana has tripled the salary of frontline workers. Write a Qbasic program to triple the worker’s salary.

Answers

QBasic program to triple worker's salary: INPUT salary, new Salary = salary * 3, PRINT new Salary.

Certainly! Here's a QBasic program to triple a worker's salary:

CLS

INPUT "Enter the worker's salary: ", salary

new Salary = salary * 3

PRINT "The tripled salary is: "; newSalary

END

In this program, the worker's salary is taken as input from the user. Then, the salary is multiplied by 3 to calculate the tripled salary, which is stored in the variable new Salary. Finally, the tripled salary is displayed on the screen using the PRINT statement. Prompt the user to enter the current salary of the worker using the INPUT statement. Assign the entered value to a variable, let's say salary. Calculate the new salary by multiplying the current salary by 3, and store the result in a new variable, let's say new Salary. Use the PRINT statement to display the new salary to the user.

Learn more about Qbasic program here:

https://brainly.com/question/20727977?

#SPJ11

Which folder typically does not contain any messages by default?

Inbox
Sent Items
Deleted Items
RSS Feeds

Answers

Answer: RSS Feeds

Explanation:

The folder that typically contains messages by default are the inbox, sent Items and the deleted Items. It should be noted, that the RSS feed, does not contain any messages by default.

Really Simple Syndication feed is referred to as an online file which has the information regarding the content that is published by a site. It enables users have access to the updates that have been made in a website in such a way that it'll be in a readable format.

En la 4ta revolución industrial se caracteriza con 3 procesos de aprendizaje o criterios, los cuales son:

Answers

Explanation:

-Uso de herramientas digitales

-La inteligencia artificial

-El análisis de datos para formar personas altamente competitivas

The best way to handle a problem is to ______.
a.
wait for someone to notice the problem
b.
avoid the problem so you don’t get blamed
c.
take care of the problem as soon as someone asks you
d.
take care of the problem as soon as you notice it

Answers

Answer:

D. take care of the problem ad soon as you notice it

Different countries in the world have launched their own navigation system why​

Answers

Answer:

China, the European Union, Japan and Russia have their own global or regional navigation systems to rival GPS

Answer: The reason other countries made their own id because they don't trust the U.S the U.S gps listens to you talk and tracks you.

Explanation: Please give brainlist.

Hope this helps!!!!

Main function of Ubuntu

Answers

Answer:

Ubuntu includes thousands of pieces of software, starting with the Linux kernel version 5.4 and GNOME 3.28, and covering every standard desktop application from word processing and spreadsheet applications to internet access applications, web server software, email software, programming languages and tools

Explanation:

Answer:

Explanation:

It is a free OS

You are installing a single 802.11g wireless network. The office space is large enough that you need three WAPs. What channels should you configure the WAPs on to avoid communication issues

Answers

Answer: 1, 6, 11

Explanation:

To avoid communication issues based on the space of the environment the channels that should be configured should be done within an interval of 5. So it should be taken as 1, then the next 6 and finally 11. These helps to avoid communication issues.

Answer:

You should configure it on Nicki Minaj

Explanation:

write a function called almostaddition that takes two int arguments. the first argument should not require an argument label. the function should add the two arguments together, subtract 2, then print the result. call the function and observe the printout.

Answers

It serves as an example of how to define and call functions in Python, as well as how to use argument labels and perform basic arithmetic operations.

Does the first argument require an argument label?

The function almostaddition takes two integer arguments and performs an operation that involves addition and subtraction. Specifically, it adds the two arguments together and then subtracts 2 from the result.

The first argument does not require an argument label, which means that it can be specified by its position in the function call rather than by its name. The second argument, however, must be labeled so that it is clear what value it represents.

Once the two arguments have been added and 2 has been subtracted, the resulting value is printed to the console. This output can then be observed by the user.

In terms of functionality, the almostaddition function is relatively simple and straightforward. It serves as an example of how to define and call functions in Python, as well as how to use argument labels and perform basic arithmetic operations.

Learn more about Argument labels

brainly.com/question/13741104

#SPJ11

In Python: Write a program to input 6 numbers. After each number is input, print the smallest of the numbers entered so far.

Sample Run:
Enter a number: 9
Smallest: 9
Enter a number: 4
Smallest: 4
Enter a number: 10
Smallest: 4
Enter a number: 5
Smallest: 4
Enter a number: 3
Smallest: 3
Enter a number: 6
Smallest: 3

Answers

Answer:

python

Explanation:

list_of_numbers = []
count = 0
while count < 6:
   added_number = int(input("Enter a number: "))
   list_of_numbers.append(added_number)
   list_of_numbers.sort()
   print(f"Smallest: {list_of_numbers[0]}")
   count += 1

does trend in computing important for organization management?explain​

Answers

Answer:

Yes

Explanation:

Trend analysis can improve your business by helping you identify areas with your organisation that are doing well, as well as areas that are not doing well. In this way it provides valuable evidence to help inform better decision making around your longer-term strategy as well as ways to futureproof your business.

What do you think are the importance of learning the components of motherboard?

Answers

Answer:

A motherboard, also known as the "main board," is the central circuit hub that allows connection between all components attached to the computer.

Explanation:

In general, mainframe or server production programs and data are adequately protected against unauthorized access. Certain utility software may, however, have privileged access to software and data. To compensate for the risk of unauthorized use of privileged software, IT management can:______________

a. Keep sensitive programs and data on an isolated machine.

b. Restrict privileged access to test versions of applications.

c. Prevent privileged software from being installed on the mainframe.

d. Limit the use of privileged software

Answers

Answer:

a. Keep sensitive programs and data on an isolated machine.

Explanation: In general, mainframe or server production programs and data are adequately protected against unauthorized access. Certain utility software may, however, have privileged access to software and data. To compensate for the risk of unauthorized use of privileged software, IT management can:______________

Multiprotocol label switching (mpls)-compatible network routers utilize label tags instead of which other element of a data packet?

Answers

Multi-protocol label switching (mpls)-compatible network routers utilize title tags rather than which another part of a data packet the Internet protocol (IP) address.

What is an Internet protocol (IP) address?An IP address, or Internet Protocol address, is a string of digits that places any device on a network. Computers use IP lectures to communicate with each other both over the internet as well as on other networks.Active IP orations are assigned by the network using the Dynamic Host Configuration Protocol (DHCP).DHCP is the most frequently used technology for allotting lessons.An IP oration is a special oration that recognizes a device on the internet or a regional network. IP stands for "Internet Protocol," which is the set of rules controlling the format of data sent via the internet or regional network.

To learn more about Internet Protocol, refer to:

https://brainly.com/question/5334519

#SPJ4

An electric spreadsheet can perform all of the following tasks, except
A. Display information visually
B. Calculate data accurately
C. Plan worksheet objectives
D. Recalculate updated information

Answers

Answer:

C. Plan worksheet objectives

Explanation:

which validatesummary enum value can you use to display model-level validation messages, not property-level messages?

Answers

The validatesummary enum value that you can use to display model-level validation messages, not property-level messages is ModelOnly. The correct option is c.

What is model-level validation?

Model validation is the process of comparing model outputs to independent real-world observations to assess their quantitative and qualitative correspondence with reality.

The primary processes for gauging and ensuring accountability in numerical models are model verification and validation.

The process of determining whether a model implementation adequately describes the developer's conceptual description of the prototype and its remedy is known as verification.

ModelOnly is the validatesummary enum value that can be used to display model-level validation messages rather than property-level validation messages.

Thus, the correct option is c.

For more details regarding model validation, visit:

https://brainly.com/question/14300048

#SPJ1

Your question seems incomplete, the missing options are:

a. None

b. All

c. ModelOnly

d. NoProperty

create a list that displays the title of each book and the name and phone number of the contact at the publisher’s office for reordering each book

Answers

A list that displays the title of each book and the name and phone number of the contact at the publisher’s office for reordering each book is:

SELECT b.Title, p.ContactName, p.PhoneNumber

FROM Books b

JOIN Publishers p ON b.PublisherID = p.PublisherID;

To create a list displaying the title of each book and the contact information of the publisher's office for reordering, the given SQL query performs an inner join between the "Books" and "Publishers" tables. It retrieves the columns "Title" from the "Books" table and "ContactName" and "PhoneNumber" from the "Publishers" table.

The query connects the two tables using the common "PublisherID" column, ensuring that only the books with matching publisher IDs are included in the result. By specifying the desired columns in the SELECT statement, the query fetches the book titles along with the corresponding contact names and phone numbers from the publisher's office.

Executing this SQL query on a database or dataset that contains the necessary tables and columns will produce the desired list, providing the book titles and the relevant contact information for reordering from the publisher's office.

Learn more about inner join:

https://brainly.com/question/31670829

#SPJ11

hris has received an email that was entirely written using capitalization. He needs to paste this text into another document but also ensure that the capitalization is removed.

What should Chris do?

Answers

He should un caps lock it
Other Questions
Which claim has Paine refuted?A. The American colonies should join Britain in any future war against France because the colonists are of English descent.B. Britain should govern the American colonies because the colonists are of English descent.C. France should govern the American colonies instead of Britain because the British king is a descendant of a Frenchman.D. The American colonies should not trade with France because of the ongoing war between France and Britain. What is the expression for 0.5(16-m) HELPPPP PLEASEEEEEEEE!!!!!!! which graph represents the line of best fit for the scatter plot?? what are the four main institutions responsible for determining economic policy in the eu? IF U KNOW SPANISH REALLY WELL PLEASE HELP ME ASASP I WILL GIVE BRAINLEST HURRY. Members of the student government are planning a movie night on campus. They have asked a random sample of students which of four movies the student would prefer. Here are the results Movie A- 31 students, Movie B- 27 students, Movie C- 34 students, Movie D- 28 students. There are 900 students total on campus. Based on the above information, how many students on campus would we expect to prefer Movie C? Round your answer to the nearest whole number. Do not round any intermediate calculations Why was the Ganges plain a good region for settlement? How do I use the word run to make a transitive and intransitive sentence How can we write the domain and range for a function that is not piece-wise such as y=x? has anyone here read the book series "warriors"? Using PEP or PrEP can reduce the chances of becoming infected for a person exposed to HIV.TRUE OR FALSE just launched a firm in the restaurant supply industry. on the day the company was launched, andy issued a press release, indicating that the vice president of brinker international, a highly respected casual restaurant company, had agreed to serve on his board of directors. andy knows that such a high quality appointment will send an important message to his potential clientele. this phenomenon is referred to as: Which strategy is effective at reducing illness? frequent handwashingavoiding the sunmonitoring blood pressurereducing sugar consumption What measurable properties of a gas does Boyle's Law relate? a) Pressure, Volume, Temperature and Mass b) Pressure and Volume c. Volume and Temperature d. Pressure and Temperature What do you picture when you hear the word drugs? And what do you picture when you hear the terms illegal drugs and legal drugs? 29/33>33 Write a logical follow-up to these sentences, using the verbs below in the pass compos.se disputer se rencontrer s'entendre s'amuse se rendrese depecher se retrouver se rappeler s'asseoirMODELEMme Dumas est monte dans le bus fatigueElle s'est assise dans le bus.1. Danid a voulu voir un film la sance de minuit.2. Mes amis ont beaucoup i au parc d'attractions.3. La profet moi, nous avons t d'accord sur le projet.Maman, tu as encore retrouv Mme Perrin au centre commercial.5. Jamila et Erica n'ont pas t d'accord dans la cour de l'cole Reseller Markets: consist of intermediaries, such as wholesalers and retailers, which buy finished goods and resell them for profit.Reseller markets do not change the physical characteristics of the products they handle. Except for items producers sell directly to consumers, all products sold to consumer markets are first sold to reseller products.Wholesalers purchase products for resale to retailers, other wholesalers, producers, governments, and institutions.Resellers consider demand for a product to determine in what quantity and at what prices the product can be resold. Retailers assess the amount of space required to handle a product relative to its potential profit,Resellers also take into account the ease of placing orders and the availability of technical assistance and training programs from products. A doctor administers a drug to a 34-kg patient, using a dosage formula of 55mg/kg/day. Assume that the drug is available in a 200 mg per 5 mL suspension or in 300 mg tablets. a. How many tablets should a 34-kg patient take every four hours? b. The suspension with a drop factor of 10 gtt/mL delivers the drug intravenously to the patient over a twelve-hour period, i.e the patient receives the daily dose over a 12 hour period. What infusion rate should be used in units of gtt/hr? Created as a member of another class object and is created and destroyed when the object of which it is a member is created and destroyed.