''' Different ways of importing 50xp There are several ways to import packages and modules into Python. Depending on the import call, you'll have to use different Python code. Suppose you want to use the function inv(), which is in the linalg subpackage of the scipy package. You want to be able to use this function as follows: my_inv([[1,2], [3,4]]) Which import statement will you need in order to run the above code without an error? Possible Answers import scipy import scipy.linalg from scipy.linalg import my_inv from scipy.linalg import inv as my_inv ''' from scipy.linalg import inv as my_inv
There are several ways to import packages and modules into Python. Depending on the import call, you'll have to use different Python code. Suppose you want to use the function inv(), which is in the linalg subpackage of the scipy package. You want to be able to use this function as follows: my_inv([[1,2], [3,4]]) Which import statement will you need in order to run the above code without an error? Instructions Possible Answers 1)import scipy 2)import scipy.linalg 3)from scipy.linalg import my_inv 4)from scipy.linalg import inv as my_inv Answers: 4)from scipy.linalg import inv as my_inv
# -*- coding: utf-8 -*- """ Created on Thu Nov 2 17:28:08 2017 @author: Palani """ from scipy.linalg import inv as my_inv print(my_inv([[1, 2], [3, 4]]))
#[3.1] Methods (funcao de um determiado objeto) x.index(["a", "b", "c"]) x.append("z") x name="Liz" name.replace("L","l") name.capitalize() #[3.2] Packages import math math.pi from scipy.linalg import inv as my_inv my_inv([[1,2], [3,4]]) # ============================================================================= # #[4] NUMPY # ============================================================================= #[4.1] Importing numpy import numpy numpy.array([1,2,3]) import numpy as np np.array([1,2,3]) from numpy import array array([1,2,3])
# 2.10 Different ways of importing There are several ways to import packages and modules into Python. Depending on the import call, you'll have to use different Python code. Suppose you want to use the function inv(), which is in the linalg subpackage of the scipy package. You want to be able to use this function as follows: my_inv([[1,2], [3,4]]) Which import statement will you need in order to run the above code without an error? INSTRUCTIONS 50 XP Possible Answers import scipy press 1 import scipy.linalg press 2 from scipy.linalg import my_inv press 3 from scipy.linalg import inv as my_inv press 4!!!