Need done in python, picture of the homework question is provided. Answer any ONE (highlight your choice) of the following two problems: Problem A Write a function definition which has two parameters,...


Need done in python, picture of the homework question is provided.



Answer any
ONE
(highlight your choice) of the following two problems:




Problem A



Write a function definition which has two parameters, both lists. The function is supposed to return the “product” of the two parameters.  The result which is returned is a new list whose elements are the products of corresponding elements from each list. If the lists are not the same size, return an empty list. Assume the elements are numeric.  Use ONE return statement.  This function does no input or output.



Example:  times_list( [2, 4, 5],  [3, 4, 9]) returns [6, 16, 45].


Example:  times_list( [3, 15],  [1, 2, 3]) returns [ ]

















Problem B



Write a program that plays a number-guessing game with the user. The program first generates a random number in the range 1 through 50, inclusive. The user then enters a guess.  If the user matches the random number, the game is over, and shows how many guesses it took.   If the number the user entered is less than the random number, the program says “Too low”. Otherwise, if the user input is greater than the random number, the program says “Too high”.  The program keeps a count of how many guesses the user takes to correctly guess the number and reports it at the end of the game.




Sample run:


What's your guess?  30


Too high


What's your guess?  15


Too low


What's your guess?  22


Too high


What's your guess?  18


Too high


What's your guess?  17


Game Over


It took you 5 guesses.




ANS:


Answer any ONE (highlight your choice) of the following two problems:<br>Problem A<br>Write a function definition which has two parameters, both lists. The function is supposed to return the<br>

Extracted text: Answer any ONE (highlight your choice) of the following two problems: Problem A Write a function definition which has two parameters, both lists. The function is supposed to return the "product" of the two parameters. The result which is returned is a new list whose elements are the products of corresponding elements from each list. If the lists are not the same size, return an empty list. Assume the elements are numeric. Use ONE return statement. This function does no input or output. Example: times.Jist(12, 4, 5], [3, 4, 9]) returns [6, 16, 45]. Example: times list [3, 15], [1, 2, 3]) returns [] Problem B Write a program that plays a number-guessing game with the user. The program first generates a random number in the range 1 through 50, inclusive. The user then enters a guess. If the user matches the random number, the game is over, and shows how many guesses it took. If the number the user entered is less than the random number, the program says "Too low". Otherwise, if the user input is greater than the random number, the program says "Too high". The program keeps a count of how many guesses the user takes to correctly guess the number and reports it at the end of the game. Sample run: What's your guess? 30 Too high 4 What's your guess? 15 Too low What's your guess? 22 Too high What's your guess? 18 Too high What's your guess? 17 Game Over It took you 5 guesses. ANS:
Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here