Interview question 1:

Part 1 — Test Points/Interview Questions:

1. Interview question 1: Basic ways to import Python modules.

2. Interview question 2: Specify an alias for the imported Python module.


Part TWO — Analysis:

Basic ways to import Python modules:

  1. You can use import to import all members of a module
import math
print(math.sin(1.23))
Copy the code
  1. You can also use from… The import… Import specific or all members of a module
from math import cos,tan
print(cos(2.23))

from math import *
print(tan(1.1))
Copy the code

Interview question 2: Use as to alias modules or members of modules. Once an alias is specified, the original name cannot be used.

import math as m
print(m.sin(20))

from math import cos as c
print(c(2))
Copy the code