Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a python program that generates all multiples of a specified integer withi

ID: 3561611 • Letter: W

Question

Write a python program that generates all multiples of a specified integer within a specified consecutive range of integers. The main function in the program should prompt the user to enter the upper and lower integers of the range and the integer for which multiples will be found. A function named show_multiples should take these three integers as arguments and use a repetition structure to display (on same line separated by a space) the multiples in descending order. The show_multiples function is called inside main. For this program, assume that the user enters range values for which multiples do exist.

Sample run:

Enter the high integer for the range 100
Enter the low integer for the range 20
Enter the integer for the multiples 15
90 75 60 45 30

I have this so far, but it does not work:

Next you have to do the following:

Modify the show_multiples function so it both counts and totals the even multiples and the odd multiples. The show_multiples function also prints the counts and sums. See sample run.

sample run:
Enter the high integer for the range 100
Enter the low integer for the range 20
Enter the integer for the multiples 15
90 75 60 45 30
3 even numbers total to 180
2 odd numbers total to 120

I cam up with this with no luck:

Lastly you have to do the following:

Modify the show_multiples function so that it creates and returns a list consisting of all of the multiples (even and odd). The show_multiples function should print only "List was created", not the multiples. Create another function namedshow_list that takes the list as its sole argument. The show_list function should output the size of the list, display all of the list elements, and output the average of the list accurate to two decimal places. See sample run.

sample run:
Enter the high integer for the range 100
Enter the low integer for the range 20
Enter the integer for the multiples 15
List was created
The list has 5 elements.
90 75 60 45 30
Average of multiples is 60.00

I don't have anything to show for this one.

Please do each of them seperatly so I can copy the solution in python 3.4.1. I will compare my work as well. Thank you in advance as I know this is a lot of work.

Explanation / Answer

def main(): #get the integers high = int(input('Enter the high integer for the range ')) low = int(input('Enter the low integer for the range ')) multi = int(input('Enter the integer for the multiples ')) #call the function multiples = show_multiples(low, high, multi) #print the multipes print(multiples) #take the arguments into the function def show_multiples(low, high, multi): #set counter counter = 0 #create list results = [] #set loop keepgoing = True while keepgoing == True: #add to counter each pass counter += 1 #math to get multiples result = multi * counter #high side stop if result >= high: keepgoing = False #cut the list and sort it results[low:high] results.sort(reverse=True) else: keepgoing = True return (result) main()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote