-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselective-import.py
31 lines (26 loc) · 1.01 KB
/
selective-import.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'''
Selective import
100xp
General imports, like import math, make all functionality from the math package available to you.
However, if you decide to only use a specific part of a package, you can always make your import
more selective:
from math import pi
Let's say the Moon's orbit around planet Earth is a perfect circle, with a radius r (in km) that
is defined in the script.
Instructions
-Perform a selective import from the math package where you only import the radians function.
-Calculate the distance travelled by the Moon over 12 degrees of its orbit. Assign the result
to dist. You can calculate this as r * phi, where r is the radius and phi is the angle in radians.
To convert an angle in degrees to an angle in radians, use the radians() function, which you just
imported.
-Print out dist.
'''
# Definition of radius
r = 192500
# Import radians function of math package
from math import radians
# Travel distance of Moon over 12 degrees. Store in dist.
phi = radians(12)
dist = r * phi
# Print out dist
print(dist)