<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Python Functions and Classes
Sometimes you need to define your own functions to work with custom data or solve some problems. A function can be defined with a prefix def. A class is like an umbrella that can contains many data types and functions, it is defined by class prefix.
<a href="https
Step1:  Class
Class is a blueprint defining the charactaristics and behaviors of an object. 
python
class MyClass
Step2:  This is a basic class definition, the age and salary are needed when creating this object. The new class can be invoked like this
Step3:  The __init__ initilaze the variables stored in the class. When they are called inside the class, we should add a self. in front of the variable. The out(Self) method are arbitary functions that can be used by calling Yourclass.yourfunction(). The input to the functions can be added after the self input.
Python Conditionals And Loops
The for statement
The for statement reads
for xxx in yyyy
Step4:  The While statement
The While statement reads
while CONDITIONAL
Step5:  Performance
Step6:  <img src="images/numba-blue-horizontal-rgb.svg" alt="numba" style="width
Step7:  Examples
<ASSISTANT_TASK:>
Python Code:
def hello(a,b):
    return a+b
# Lazy definition of function
hello(1,1)
hello('a','b')
Explanation: Python Functions and Classes
Sometimes you need to define your own functions to work with custom data or solve some problems. A function can be defined with a prefix def. A class is like an umbrella that can contains many data types and functions, it is defined by class prefix.
<a href="https://colab.research.google.com/github/ryan-leung/PHYS4650_Python_Tutorial/blob/master/notebooks/05-Python-Functions-Class.ipynb"><img align="right" src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open in Colab" title="Open and Execute in Google Colaboratory">
</a>
Functions
End of explanation
class Person:
    def __init__(self,age,salary):
        self.age = age
        self.salary = salary
    def out(self):
        print(self.age)
        print(self.salary)
Explanation: Class
Class is a blueprint defining the charactaristics and behaviors of an object. 
python
class MyClass:
    ...
    ...
For a simple class, one shall define an instance
python
__init__()
to handle variable when it created. Let's try the following example:
End of explanation
a = Person(30,10000)
a.out()
Explanation: This is a basic class definition, the age and salary are needed when creating this object. The new class can be invoked like this:
End of explanation
# make a list
students = ['boy', 'boy', 'girl', 'boy', 'girl', 'girl', 'boy', 'boy', 'girl', 'girl', 'boy', 'boy']
boys = 0; girls = 0
for s in students:
    if s == 'boy':
        boys = boys +1
    else:
        girls+=1
        
print("boys:", boys)
print("girls:", girls)
Explanation: The __init__ initilaze the variables stored in the class. When they are called inside the class, we should add a self. in front of the variable. The out(Self) method are arbitary functions that can be used by calling Yourclass.yourfunction(). The input to the functions can be added after the self input.
Python Conditionals And Loops
The for statement
The for statement reads
for xxx in yyyy:
yyyy shall be an iteratable, i.e. tuple or list or sth that can be iterate. After this line, user should add an indentation at the start of next line, either by space or tab.
Conditionals
A conditional statement is a programming concept that describes whether a region of code runs based on if a condition is true or false. The keywords involved in conditional statements are if, and optionally elif and else.
End of explanation
def int_sum(n):
    s=0; i=1
    while i < n:
        s += i*i
        i += 1
    return s
int_sum(1000)
Explanation: The While statement
The While statement reads
while CONDITIONAL:
CONDITIONAL is a conditional statement, like i &lt; 100 or a boolean variable. After this line, user should add an indentation at the start of next line, either by space or tab.
End of explanation
%timeit int_sum(100000)
Explanation: Performance
End of explanation
import numba 
@numba.njit
def int_sum_nb(n):
    s=0; i=1
    while i < n:
        s += i*i
        i += 1
    return s
int_sum_nb(1000)
%timeit int_sum_nb(100000)
Explanation: <img src="images/numba-blue-horizontal-rgb.svg" alt="numba" style="width: 600px;"/>
<img src="images/numba_features.png" alt="numba" style="width: 600px;"/>
Numba translates Python functions to optimized machine code at runtime using the LLVM compiler library. Your functions will be translated to c-code during declarations. To install numba, 
python
pip install numba
End of explanation
import random
def monte_carlo_pi(n):
    acc = 0
    for i in range(n):
        x = random.random()
        y = random.random()
        if (x**2 + y**2) < 1.0:
            acc += 1
    return 4.0 * acc / n
monte_carlo_pi(1000000)
%timeit monte_carlo_pi(1000000)
@numba.njit
def monte_carlo_pi_nb(n):
    acc = 0
    for i in range(n):
        x = random.random()
        y = random.random()
        if (x**2 + y**2) < 1.0:
            acc += 1
    return 4.0 * acc / n
monte_carlo_pi_nb(1000000)
%timeit monte_carlo_pi_nb(1000000)
@numba.njit
def monte_carlo_pi_nbmt(n):
    acc = 0
    for i in numba.prange(n):
        x = random.random()
        y = random.random()
        if (x**2 + y**2) < 1.0:
            acc += 1
    return 4.0 * acc / n
monte_carlo_pi_nbmt(1000000)
%timeit monte_carlo_pi_nbmt(1000000)
Explanation: Examples
End of explanation
<END_TASK>