"""
Instructions:

+ Import the "math" package.
  Now you can access the constant "pi" with "math.pi".
  
+ Calculate the circumference of the circle and store it in C.

+ Calculate the area of the circle and store it in A.
"""
# Definition of radius
r = 0.43

# Import the math package
import math

# Calculate C
C = 2 * math.pi * r

# Calculate A
A = math.pi * ( r ** 2 )

# Build printout
print("Circumference: " + str(C))
print("\nArea: " + str(A))


"""
Explanation: Packages

Packages are a neat way to store collections of python scripts.


They are essetially are "Directory of Python scripts".


"Each script" is called a "Module".


These "modules", specify functions, methods, types.



Thousands of packages available, these include several for data science:


Numpy : package for doing "Numerical Computation",  such as "efficiently" working with "arrays".


Matplotlib : a "data visualization" package for python.


Scikit-learn : a "machine learning" package for python.



Installing Python Packages:
Not all packages come packaged with python distribution, some of them have to be downloaded and installed manually. To do this following step should be followed:


First, identify what package to use, this would be "package name", for instance (say) Numpy.


Second, install pip, a python package management system. 


Third, use the follwoing template to install desired packages:
pip_version_number install &lt; package name &gt;
for example, pip3 install numpy


Lastly, before you use the installed packages, you have to explicitly tell python about it, this is done by importing the package.


This can be done in two ways:

To import all the contents of a package: import &lt; package name &gt;
To import a specific method or module from the package: 


from &lt; package name &gt; import &lt; function, method name or type name &gt;


Now to use a package, simply use this template:

&lt; package name &gt; . &lt; func, method or type name &gt; ( object )

This could be cumbersome sometimes, hence we can shorten the former statement by using an 'alias'. Using the templet mentioned below:

import &lt; package name &gt; as &lt; desired alias &gt;

e.g. import numpy as np ( here np is an 'alias' ) then using the package like this,

&lt; alias name &gt; . &lt; func, method or type name &gt;

Note: The pythonic way of using packages is to import using method 1 discussed formerly, i.e. import &lt; package name &gt;

Exercise:
RQ1: Which of the following is a package for installation and maintenance system for Python?
Ans: pip.

RQ2: Which statement is the most common way to invoke the import machinery?
Ans: import.

RQ3: You import Numpy as foo as follows:

import numpy as foo

Which Python command that used the array() function from Numpy is valid if Numpy is imported as foo?
Ans: foo.array( object )

RQ4: You want to use Numpy's array() function. You need to decide whether to import this function as follows:

from numpy import array

or by imporitng the entire numpy package:

import numpy

Select the two correct statements about these different import methods.
Ans: 
1) The from numpy import array version will make it less clear in the code that you're using Numpy's array() function. 
2) Using import numpy will require you to use numpy.array(), making it clear that you're using a Numpy function.

Lab : Packages
Objective:



Write Python to import different packages.


Practise different ways to import packages



Exercises:
1) import package -- 100xp, status: earned.
2) Selective import -- 100xp, status: earned.
3) Different ways of importing -- 50xp, status: earned.

1. Import Package:
As a data scientist, some notions of geometry never hurt. Let's refresh some of the basics.
For a fancy clustering algorithm, you want to find the circumference $C$ and area $A$ of a circle. When the radius of the circle is r, you can calculate $C$ and $A$ as:

$C = 2πr$ and $A = πr^2$

Note: To use the constant pi, you'll need the math package.
End of explanation
"""


"""
Instructions :

    + Perform a selective import from the "math" package where,
      you only import the "radians" function.
  
    + Cal:
    
        - Distance travelled by the Moon over 12 degrees of its orbit.

        - Assign the result to "dist".
        
        - calculate this as r ∗ ϕ,
          where r is the radius and ϕ 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 if 12 degrees. Store in dist.
dist = r * radians( 12 )

# Print out dist
print("\nThe distance travelled by the moon over 12 degrees of its orbit is: " + str( dist ) + " Km" )

"""
Explanation: 2) Selective import:


General package import statement, import &lt; package name &gt;


Selective pacakge import statement,
from &lt; package name &gt; import &lt; function, method, type or constant &gt;
End of explanation
"""


