Perfect number means, the sum of the divisors or factors of a positive integer n, excluding...
Fantastic news! We've located the answer you've been seeking!
Question:
Transcribed Image Text:
Perfect number means, the sum of the divisors or factors of a positive integer n, excluding n itself. If the sum is equal to n then it is a perfect number. Consider the following examples for the perfect numbers. Example: i. ii. n=9 divisors of n are: 1, 3 sum of the divisors is=1+3=4 In this case sum of the divisors is not equal to n, so n is not a perfect number. n=6 divisors of 'n are: 1,2,3 sum of the divisors is: 1+2+3=6 In this case sum of the divisors is equal to n, so n is a perfect number. Problem: Create two lists with the names xlist and ylist. Append xlist with 100 random numbers between 1 and 30 then copy all the perfect numbers from xlist to the ylist. Display the contents of xlist and ylist. It should consist of the following functions: def generateData (xlist): Appends xlist with 100 random numbers between 1 and 30. def fill_ylist (xlist, ylist): This function will pass each element of xlist to a sub function perfect Number(). If it is a perfect number then add it to ylist dynamically. def perfect Number (): Each element will be received as a number to determine whether the number is perfect. It will return True, if the number is pefect. def printOutput(): If the list is not empty, then print the list as formatted in the sample output below otherwise display "There are no elements in the list" def main (): In main (), lists are declared and functions generateData (), fill_ylist(), and printOutput() are called. Sample Output: Randoe Numbers from xlist[] = 27 10 27 9 9 10 14 12 5 22 23 29 3 7 28 12 2 20 28 9 21 24 29 22 1 3 24 7 22 17 29 27 11 6 11 23 13 25 7 10 15 17 18 16 21 5 12 12 20 19 13 5 3 23 20 27 9 18 17 17 24 21 13 4 14 4 22 1 21 8 25 13 11 16 4 4 28 7 15 3 22 23 20 23 2 25 16 7 18 21 16 22 23 14 29 25 13 4 25 Perfect numbers from ylist are: 28 28 6 28 Randon Numbers from xlist[] = 7 17 10 26 22 9 20 21 21 22 8 26 17 24 12 16 25 24 11 9 14 19 13 21 17 12 7 24 18 20 22 20 24 23 18 23 18 15 17 19 12 16 22 14 26 25 24 15 13 18 16 8 25 11 22 26 17 17 25 26 22 21 23 14 20 8 7 12 16 9 12 9 25 11 25 12 7 19 10 26 19 20 13 14 19 15 13 15 18 23 19 10 24 19 25 19 9 22 21 18 Perfect numbers from ylist are: No elements in the list
Expert Answer:
Answer rating: 100% (QA)
import random def generateData xlist Function that generates 100 random integers between 1 30 for i View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 9780133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions

You have just been hired as an analyst to assist the manager of Heartbreak Hotel Your first assignment is to examine and report on the reservations policy in the hotel. Heartbreak Hotel routinely...

The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 14. Ivan and Irene paid the following in 2012 (all by check or can otherwise be...

What is the one greatest strength of a pluralistic society? What is the one greatest weakness? Do these characteristics work for or against business?

a. Why should managers be interested in reducing the average age of their inventories if possible? b. Give an example of a company whose liquidity might be more appropriately measured by the quick...

Mention the key principles of TQM.

Calculate the pH of a 0.010 M sodium nitrite solution.

In an Adecco Staffing survey of 1,000 adults in the United States, 140 (or 14%) said that salary was the most important feature of their job. The sample proportion of 0.14 cannot be a good estimate...

It is your first six months at your new job as an HR assistant at Groceries for You, a home delivery grocery service. When you ask the HR director, Chang, about performance evaluations, he just rolls...

Today is September 16, Year 2. You, CPA, work for Garcia & Garcia LLP, a mediumsized firm located in Montreal. Jules Garcia calls you into his office. "CPA, I have a very special engagement for you....

We still are recovering from the real estate bubble burst of 2008/09. The bubble created all kinds of new issues that many new home buyers (and refinanciers) have to face. After your review of the...

A solution is prepared by dissolving 1 mol each of Cu(NO 3 ) 2 , Ni(NO 3 ) 2 , and AgNO 3 in 1 L of water. Using only data from Appendix 2B, identify the metals (if any) that, when added to these...

(a) The potential of the cell Zn(s)Zn 2+ (aq, ?)Pb 2+ (aq, 0.10 mol L 1 )Pb(s) is 10.661 V. What is the molar concentration of Zn 2+ ions? (b) Write an equation showing how the Zn 2+ ion...

A fuel cell in which hydrogen reacts with nitrogen instead of oxygen is proposed. (a) Write the chemical equation for the reaction in water, which produces aqueous ammonia. (b) What would be the...

Suppose that 25.0 mL of a solution of Ag + ions of unknown concentration is titrated with 0.015 m KI(aq) at 25C. A silver electrode is immersed in this solution, and its potential is measured...

A technical handbook contains tables of thermodynamic quantities for common reactions. If you want to know whether a certain cell reaction has a positive standard potential, which of the following...

At January 1, 2021, Caf Med leased restaurant equipment from Crescent Corporation under a nineyear lease agreement. The lease agreement specifies annual payments of $26,000 beginning January 1,...

When the concentration of a strong acid is not substantially higher than 1.0 107 M, the ionization of water must be taken into account in the calculation of the solution's pH. (a) Derive an...

The area of a hexagon can be computed using the following formula (s is the length of a side): Write a program that prompts the user to enter the side of a hexagon and displays its area. Here is a...

Implement the preorder method in BST using a stack instead of recursion. Write a test program that prompts the user to enter 10 integers, stores them in a BST, and invokes the preorder method to...

Revise Listing 8.3, FindNearestPoints.java, to display all closest pairs of points with the same minimum distance. Here is a sample run: Listing Enter the number of points: 8Enter Enter 8 points: 0...

Effective fraudfighters usually put most of their time and effort into minimizing the pressures for fraud perpetrators to commit fraud. (True/False)

Good controls will often increase opportunities for individuals to commit fraud within an organization. (True/False)

Managements example or modeling is of little importance to the control environment. (True/False)
Question Categories