Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your program is to have a main() function which controls the program by calling the appropriate functions. Create two lists from 1 to 10

Your program is to have a main() function which controls the program by calling the appropriate functions. CSC1019 Intro to Programming (Python) Kenneth W. Riddle generateList() - receives as a parameter the number

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 list 1[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. How many numbers per list: 5. 8 10 4 List 1:7 1 List 2: 2 7 10 8 Added List: 3 15 20 14 Multiplied List: 2 56 100 48 20 >>> | 9 5 The first column is the prompt column. Do not hardcode these in the print statement, but pass them into the displayList() function as a parameter. Function Description 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. CSC1019 Intro to Programming (Python) Kenneth W. Riddle 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. multiplyLists() - 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: getNumber() generateList() Main() addLists() multiplyLists() displayList() 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 list 1[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. How many numbers per list: 5. 8 10 4 List 1:7 1 List 2: 2 7 10 8 Added List: 3 15 20 14 Multiplied List: 2 56 100 48 20 >>> | 9 5 The first column is the prompt column. Do not hardcode these in the print statement, but pass them into the displayList() function as a parameter. Function Description 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. CSC1019 Intro to Programming (Python) Kenneth W. Riddle 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. multiplyLists() - 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: getNumber() generateList() Main() addLists() multiplyLists() displayList()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Python version 38 import random def getNumber Function that ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Auditing a risk based approach to conducting a quality audit

Authors: Karla Johnstone, Audrey Gramling, Larry Rittenberg

9th edition

9781133939160, 1133939155, 1133939163, 978-1133939153

More Books

Students also viewed these Programming questions

Question

Where do I give in to my bad habit?

Answered: 1 week ago

Question

Define line and staff authority

Answered: 1 week ago

Question

Define the process of communication

Answered: 1 week ago

Question

Explain the importance of effective communication

Answered: 1 week ago

Question

* What is the importance of soil testing in civil engineering?

Answered: 1 week ago