Write a python program that takes two arrays a and b and prints the dot product.
Example::
Code:
def dotProduct(arr1,arr2): # dotproduct function
if
arr1==[]:
#condition for arr1 is empty
return arr2
elif arr2 ==
[]: #condition for arr2
is empty
return arr1
elif arr1 ==[] and arr2 ==[]:
#condition for arr1,arr2 are empty
return []
else:
list = [[x,y] for x in
arr1 for y in arr2] #dot product of arrays.
return list #return from
fuction.
a = ['apple' , 'banana' , 'carrot', 'turtle', 'zebra']
b = ['red', 'blue', 'green']
emp1 = []
emp2 = []
print(dotProduct(a,b))
#fucntion call with arrays
print(dotProduct(a,emp2)) #fucntion call with one
empty array
print(dotProduct(emp1,b))
print(dotProduct(emp1,emp2)) #fucntion call with both empty
array
Code Image:

Output Image:

Write a python program that takes two arrays a and b and prints the dot product....
Write a program which takes 2 arrays of 10 integers each, a and b. c is another array with 20 integers. The program should put into c the appending of b to a, the first 10 integers of c from array a, the latter 10 from b. Then the program should display the array c, then find and display the Minimum value of the array c.
Language C Code Write a program that takes two integer arrays (A and B) and sums them together (element wise). A third array to accept the result should be passed in as the output argument. Assume the arrays are all the same size. The argument N is the size of the arrays. Your code should provide a function with the following signature: void array Addition (int A[], int B[], int N, int output[]) { } Your code must also provide...
Given two 2-dimensional arrays, A and B, calculate the three arrays: A + B, A*B and A*B-1 . That is to say find the sum of the two arrays, the outer-product of the two arrays and the outer-product of A times B inverse. You can use the procedure illustrated on the web site: https://www.thecrazyprogrammer.com/2017/02/c-c-program-find-inverse-matrix.html (Links to an external site.) make the arrays 3X3, choose any values you wish make sure the determinant of B is not zero, if so change...
Question 3. Write a program that contains the following functions a) A function that takes in as input the amount a person has to pay to buy a house, and the monthly payments made. Your function should display how much has been payed and how much is left to pay every month until the mortgage has been payed (Ignore interest and the like) b) A function that takes in as input the color of a car, and returns the number...
DATA PROGRAMMING: PYTHON Be sure to use sys.argv NOT input. Write a program and create a function called inch2cm that takes one number in inches as a parameter, converts it to the centimeters and prints the result. The program output is shown below. Input: 14 Output: 14 inches = 35.56 centimeter Write a program and create the following functions: shapes(): takes the shape name and a number as parameters, and calls the proper function to calculate the area. areaCircle(): take...
I need to compose a program in python that takes two floats a and b from the command line and prints out one per line, the square of the larger a or b. Thank you in advance!
Write a program (python) that multiplies two hard-coded numbers, then prints the individual numbers out and prints their product out, all on separate lines. You can choose the two numbers that are multiplied together. Make a copy of previous exercise then modify it to print output exactly like this, rather than just the numbers on separate lines: 10 x 7 = 70 Do this using the string.format() function discussed in the lecture.
Hi, can you help me add these requirements in my Turtle python program. The program is supposed to run an Olympics skating game. The program is below the requirements. Thanks Requirements -Your race will be random generated so each time there is a possibility that a different winner. -Have a countdown of “READY” “SET” “GO” appear on the screen and then the turtles take off. -Have the program tell the winner[s]. -Award Medals. -User may guess who will win. -Allow...
Write a program that reads in two hexadecimal numbers from a file, hex.dat, and prints out the sum of the two numbers in hexadecimal. (As noted in class, first do this without using a file and by reading using the cin > > command) From Wikipedia: "In mathematics and computer science, hexadecimal (also base 16, or hex) is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0-9 to...
Statement Write a program that takes two upper case letters as input and prints its position number in alphabet sequence, [A, B, C, .... X, Y, Z, AA, AB, AC, AD .... AX, AY, AZ, ... ZX, ZY, ZZ] Sample input 1 AA Sample output 1 (26 * 1) + 1 = 127 Sample input 2 AB Sample output 2 (26 * 2) + 2 = 28 Sample input 3 KE Sample output 3 (26 * 11) + 5 =...