Perfect number means, the sum of the divisors or factors of a positive integer n, excluding...
Fantastic news! We've Found the answer you've been seeking!
Question:
![](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2023/09/64fc2c5ae4fd4_1694248006879.jpg)
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 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 generateDataxlist Function that generates 100 random integers between 1 30 for i i... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Stan, a trained and licensed plumber, carelessly installed a steam heater in George's restaurant, and, as a result, George was seriously burned when a heater pipe exploded. Sylvie, a qualified...
-
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 1-4. Ivan and Irene paid the following in 2012 (all by check or can otherwise be...
-
All administrative laws are criminal laws and enforceable as such even though they are not part of the Criminal Code. True False
-
A plant manager is interested in developing a quality-control pro-gram for an assembly line that produces light bulbs. To do so, the manager considers the quality of the products that come from the...
-
Exercise 41 of Chapter 6 looked at a sample of 35 vehicles to examine the relationship between gas mileage and engine displacement. The full data set holds data on 1211 cars. How well did our sample...
-
Life insurance. You might sell insurance to a 21-year-old friend. The probability that a man aged 21 will die in the next year is about 0.0015. You decide to charge $250 for a policy that will pay...
-
A study reported in the Journal of Small Business Management concluded that self-employed individuals do not experience higher job satisfaction than individuals who are not self-employed. In this...
-
8. One option when seeking referrals from current clients is to ask for their advice. Which steps do you need to follow to pursue this option? Ask, Act, Compliment Compliment, Ask, Act Compliment,...
-
In Exercise 3.108 on page 215, we see that the home team was victorious in 70 games out of a sample of 120 games in the FA premier league, a football (soccer) league in Great Britain. We wish to...
-
Per capita healthcare spending was $10,345 in 2016, and is predicted to be $11,897 by the end of 2017. Will real spending increase? In order to express spending in inflation-adjusted terms you will...
-
In this scenario you are the Manager of a Home and Community Care organization in Victoria. Your organization provides oversees support services for individuals in their homes. The individuals that...
-
find the wind speed and direction for the following parcels. Important note: To determine the arc tangent using the Google calculator, click the box marked "Inv" so that it is a light gray instead of...
-
As consumers we're connected to an instant feed or live updates, breaking news, and messages. We believe that when we post something on social media, we will get instant feedback from friends. What...
-
Describe the process for screening candidates for ethics. Outline which job candidate factors are illegal to consider when hiring. Explain how to obtain accurate behavior information from resumes,...
-
In relation to Operation management, sustainability and supply chain management explain the following terms; What is the overall objective of scheduling? What is JIT? What is a Lean producer? Discuss...
-
E5.8 (LO 3, 4), AP Service All That Blooms provides environmentally friendly lawn services for Compute break-even point in units homeowners. Its operating costs are as follows. and sales....
-
I frequently use NY Times and CNN and am aware of Fox News but I never use it. I visit these sites, NY Times and CNN, a few times a week whenever I have to research something or see something on...
-
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: 8-Enter Enter 8 points: 0...
-
The International Licensing Industry Merchandisers Association (LIMA; www.licensing.org) is an organization with offices worldwide. It supports merchandise licensing through education, networking,...
-
Suppose you are an international entrepreneur and want to open your own franchise somewhere in Europe. You decide to conduct research to identify the most promising franchise and learn how to become...
-
What are the advantages and disadvantages of licensing? LO.1
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App