2. (10 points) a. Define a class Parent and implement one property function: three_power() which takes an integer argume

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

2. (10 points) a. Define a class Parent and implement one property function: three_power() which takes an integer argume

Post by answerhappygod »

2 10 Points A Define A Class Parent And Implement One Property Function Three Power Which Takes An Integer Argume 1
2 10 Points A Define A Class Parent And Implement One Property Function Three Power Which Takes An Integer Argume 1 (40.29 KiB) Viewed 37 times
2. (10 points) a. Define a class Parent and implement one property function: three_power() which takes an integer argument and check whether the argument is integer power of 3 (e.g., 1 is 3°, 3 is 3¹, 9 is 3²2, 27 is 3³, 81 is 3¹). b. Define a second class Child to inherit Parent, and implement the following two property functions for Child: (1) add_three power() which is a recursive function taking a parameter of a list of integers (e.g., a defined in the program). The function will calculate and return the sum of all numbers in the list that are integer power of 3; (2) list_GCD() which takes two list arguments a and b as shown in the program, and use the built-in map function to calculate the greatest common divisor (GCD) of each pair of the elements in the two lists (e.g., GCD of 3 and 2, GCD of 6 and 4, GCD of 9 and 18, GCD of 16 and 68, etc.) Note: you can either define the GCD function by yourself or use the built-in GCD function in math module. import math import random a= [3, 6, 9, 16, 32, 57, 64, 81, 100] b=[2, 4, 18, 68, 48, 80, 120, 876, 1256]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply