Output:
Q3) for the following array, repeat the first element twice, the second element three times, and the third element four times (9, 3) then use tile method to get this shape (9, 6) of the array
arr = np.random.randn(3,3)
Q4) Write a Python program to create a lambda function that adds 15 to a given number passed in as an argument, also create a lambda function that multiplies argument x with argument y and print the result
import nyumpy as np
# Lambda function to add 15 to a given number
add_fifteen = lambda num: num + 15
# Lambda function to multiply two numbers
multiply = lambda x, y: x * y
# Example usage
num = 5
result = add_fifteen(num)
print("Adding 15 to", num, "gives", result)
x = 3
y = 7
result = multiply(x, y)
print("Multiplying", x, "and", y, "gives", result)
Q5) Write a Python program to create a function that takes one argument, and that argument will be multiplied with an unknown given number
Double the number of 15 = 30 Triple the number of 15 = 45 Quadruple the number of 15 = 60 Quintuple the number 15 = 75
def multiply_with_unknown(num):
unknown_num = 5 # The unknown given number
return num * unknown_num
# Example usage
num = 15
double = multiply_with_unknown(num)
triple = multiply_with_unknown(num) * 1.5
quadruple = multiply_with_unknown(num) * 2
quintuple = multiply_with_unknown(num) * 2.5
print("Double the number of", num, "=", double)
print("Triple the number of", num, "=", triple)
print("Quadruple the number of", num, "=", quadruple)
print("Quintuple the number of", num, "=", quintuple)
Q1) reshape the given array to 5 rows and 3 columns in Fortran order and return it to vector in C order without make copy arr = np.arange(15)
Q2) concatenate the following arrays vertically (by the rows) the split it as shown first: [[1 2 3] [4 5 6]] second: [[7 8 9]] third: [[10 11 12]] arr1 = np.array([[1, 2, 3], [4, 5, 6]]) arr2 = np.array([[7, 8, 9], [10, 11, 12]])
Output: Q3) for the following array, repeat the first element twice, the second element three times, and the third element four times (9, 3) then use tile method to get this shape (9, 6) of the array arr = np.random.randn(3,3)
Q4) Write a Python program to create a lambda function that adds 15 to a given number passed in as an argument, also create a lambda function that multiplies argument x with argument y and print the result
Q5) Write a Python program to create a function that takes one argument, and that argument will be multiplied with an unknown given number Double the number of 15 = 30 Triple the number of 15 = 45 Quadruple the number of 15 = 60 Quintuple the number 15 = 75