Question: Need help with my python homework 4. Write a function named quiz2 with three inputs input 1 is a list of lists representing an nxn
Need help with my python homework 4. Write a function named quiz2 with three inputs input 1 is a list of lists representing an nxn matrix input 2 is a list representing an nx1 matrix input 3 is a list of strings Your function should complete three tasks: a. Task 1: use the input function to ask the user for a number, then add 7 to the integer value of the input number and print the result. If the user did not put in a number that can be converted to an integer, ask them for another input b. Task 2: without using numpy or any built in matrix operation functions, multiply input 1 by input 2. You may assume that all inputs are valid and of the correct structure & size. The result should be a list of length n representing an nx1 matrix. Print out the resulting list. c. Task 3: make a dictionary with one entry per string in the input list (input 3 in your function). the keys will be "s0", "s1", "s2", ...."sn" where the number is the index of the string in the original list and the values are tuples with the original string as the first value and the number of words in the string as the second value. Your function should return the dictionary from task 3
This is what is have done so far 
def quiz2(inputl, input2, input3): while True : #while loop used to run my calculation try : #try is used to execute my Loop num = input("Enter a number: ")#num is a varible used to define a user input with string asking for number num- int(num) #used to convert my varible to integer except ValueError as e:# used when the value is not a nuber print( "You did not enter a number.")#print sting state ing you didn't post number continue#goes back to top of Loop else : #else used if number is given print (int(num+7))#prints out user input plus break#break used to break the Loop seven inputl [[ll#inputl is a variable that assings a list or matix of nxn size input2-[]#input2 is an nx1 matix #define a variable named result that takes input one and multiplys lt by input 2 printing the result result = [[sum(a*b for a,b in zip(input1-row, input2_col) for input2_col in zip(*input2)] for input1-row in input!] for r in result :#for statement used to print my result print(r)?returns new matrix input3 []sinput3 is an empty list to input strings #returnDict returns a dictionary with list postions as keys and the original item and Lenth of item as rey vaLues returnDict str(index): [item, len item)] for index, item in enumerate(input3) return(returnDict)treturn used to output dictionary
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
