Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PYTHON PROGRAMMING HELP PLEASE Objectives: To practice writing, planning, defining, calling functions, and using Python sequence, decision, repetition statements and lists. Description: For this
PYTHON PROGRAMMING HELP PLEASE Objectives: To practice writing, planning, defining, calling functions, and using Python sequence, decision, repetition statements and lists. Description: For this project, you will be writing several functions that manipulates lists. You cannot use global variables, nor advanced techniques, like list comprehensives. ASSIGNMENT: **PROGRAM MUST BE WRITTEN OFF CONCEPTS FROM CHAPTERS 1 - 7 ONLY** PYTHON Haywood Community College Chapter 3 Decision Structures and Boolean Logic Starting Out with Python, 5e Tony Gaddis Chapter 4 Repetition Structures Chapter 5 Functions Chapter 6 Files and Exceptions PPearson Chapter 1 Introduction to Computers and Programming Chapter 2 Input, Processing, and Output Chapter 7 Lists and Tuples Your program is to have a main() function which controls the program by calling the appropriate functions. Create two lists from 1 to 10 values. Each value should be a random number generated value from 1 to 10. Create a function to generate these lists. This function will have to be called twice from main(). Once for each list. The number of elements per list is to be input by the user and be from 1 to 10, so pass that value into the generate list function as a parameter. Do not allow 0 or negative input for the number of elements. Write two more functions, one to add the two lists of corresponding indexed values together and one to multiple the two lists of corresponding indexed values and store the results in a new list and return the new list. For adding, you take list1[0] and add it to list2[0], add list1[1] and list2[2] and so on for the number of elements in the list. For multiplying, take list1[0] and multiply it times list2[0] and so on for each element in the list and store this value in a new list and return that list. Create a displayList() function to display the four lists. Pass in a reference to the list which needs to be printed. Do this for all four lists. Format your output in aligned columns using the format specifier command. The first column is the prompt column. Do not hardcode these in the How many numbers per list: 5. List 1: 1 8 10 List 2: 2 7 10 8 4 print statement, but Added List: Multiplied List: 3 15 20 14 9 2 56 100 48 20 pass them into the displayList() function Function Description as a parameter. main()-controls the program and contains the logic. Calls all the other functions. getNumber() - has no parameters and gets input from the user on the number of elements in each list. Return that value to main. generateList() - receives as a parameter the number of elements per list and generates that many random values between 1 and 10 adding them to a list and returns that list to main. This function will be called twice in your program. addLists() - receives as a parameter the two lists and add corresponding index elements together and stores the added values in a new list. It returns that list to main. multiply Lists() - receives as a parameter the two lists and multiplies corresponding index elements together and stores the resulting values in a new list. It returns that list to main. displayList() - receives as a parameter a prompt and a list. The prompt is first printed and then the list of values. In the sample run, List 1: is a prompt as are all the items below it. The list of values need to be aligned. Do not print if list1 or list2 are empty. This function will be called four times by your program, once for each line being printed. Here is a VTOC of the program: Main() getNumber() generateList() addLists() multiplyLists() displayList()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started