Question: practice program problems using python; (1) assign the listnwith 20 random integers between 0 and 100; (2) sort the list by customizing your own comparison

practice program problems using python;

  1. (1) assign the listnwith 20 random integers between 0 and 100; (2) sort the list by customizing your own comparison function (i.e., set thekeyargument) which is based on how close the number is to 50; (3) after sorting, define arecursivefunction to sum the list elements that have even indices in the list and odd element value
  2. Define a classParentand implement one property functions:prime_check()which is to check whether a number passed as parameter is prime or not (returntrueorfalse). Then define a second classChildto inherit the parent class, and implement aconstructorand one property functionsadd_prime(). In the constructor, define a class property list with 20 elements and assign withrandomintegers in range (0, 100), the add_prime() will leverage the prime_check() defined in Parent to calculate and return the sum of prime integers in the list

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!