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

FOR PYTHON Write a PYTHON program that contains a list holding the names of four

ID: 3800292 • Letter: F

Question

FOR PYTHON

Write a PYTHON program that contains a list holding the names of four USA presidents. Use any presidents you wish. Then, run aloop that adds four more presidents to the list. Call another function with the list as its sole argument. This second function should sort the list and then loop through the list to print each president's name on its own line.

SAMPLE OUTPUT

Enter the name of another president Jefferson

Enter the name of another president Truman

Enter the name of another president Obama

Enter the name of another president Eisenhower

Here is the presidents list, sorted

Eisenhower

Jefferson

Kennedy

Lincoln

Obama

Truman

Washington

Explanation / Answer

def create_presidents(no_presidents=4): presidents = [] for _ in range(no_presidents): presidents.append(input("Enter a name: ")) # More presidents for _ in range(no_presidents): presidents.append(input("Enter another name: ")) presidents.sort() return presidents def print_presidents(presidents): for president in presidents: print(president) if __name__ == "__main__": no_presidents = 4 presidents = create_presidents(no_presidents) print_presidents(presidents)