1+2

1+1
1+2

"""
Explanation: Tutorial Brief
This tutorial is an introduction to Python 3. This should give you the set of pythonic skills that you will need to proceed with this tutorial series.
If you don't have the Jupyter installed, shame on you. No just kidding you can follow this tutorial using an online jupyter service:
https://try.jupyter.org/
Cell Input and Output
End of explanation
"""


print(1+2)

"""
Explanation: The print function
Notice: print is a function in Python 3. You should use parentheses around your parameter.
End of explanation
"""


a = 4
b = 1.5
c = 121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212
d = 1j
e = 1/3
f = True

a+b

a*c

(b+d)*a

a+f

type(1.5)

"""
Explanation: Variables
There are many variable types in Python 3. Here is a list of the most common types:
Numerical Types:

bool (Boolean)
int (Integer/Long)
float
complex

Notice: In Python 3 integer represents integer and long. Because there is no more long data type, you will not get L at the end of long integers.
End of explanation
"""


my_name = "Roshan"
print(my_name)

my_list = [1,2,3,4,5]
my_list

my_list + [6]

my_list

my_list += [6,7,8]
my_list

my_list.append(9)
my_list

my_tuple = (1,2,3)
my_tuple

my_tuple + (4,5,6)

my_dict = {"name":"Roshan", "credit":100}
my_dict

my_dict["name"]

my_dict["level"] = 4
my_dict

my_dict.values()

my_dict.keys()

"""
Explanation: Other Value Types:

str (String)
list (Ordered Array)
tuple (Ordered Immutable Array)
dict (Unordered list of keys and values)
End of explanation
"""


len(my_list)

"""
Explanation: Selecting / Slicing
Use len function to measure the length of a list.
End of explanation
"""


my_list[0]

"""
Explanation: To access a single value in a list use this syntax:
python
list_name[index]
End of explanation
"""


my_list[1:2]

my_list[:3]

my_list[3:]

"""
Explanation: To select multiple value from a list use this syntax:
python
index[start:end:step]
End of explanation
"""


my_list[-1]

my_list[-2]

"""
Explanation: Notice: negative index selected from the end of the list
End of explanation
"""


my_list[-2:]

my_list[:-2]

my_list[3:-1]

"""
Explanation: You can use negative indexing in selecting multiple values.
End of explanation
"""


my_list[::2]

my_list[3::2]

my_list[::-1]

"""
Explanation: The third location in the index is the step. If the step is negative the the list is returned in descending order.
End of explanation
"""


my_name

my_name[0]

"""
Explanation: Working with Strings
You can select from a string like a list suing this syntax:
python
my_string[star:end:step]
End of explanation
"""


my_name[:2]

"""
Explanation: Notice: You can also use negative indexing.
End of explanation
"""


# Sorted by most spoken languages in order
divide_by_zero = {"zho":"你不能除以零",
                  "eng":"You cannot divide by zero",
                  "esp":"No se puede dividir por cero",
                  "hin":"आप शून्य से विभाजित नहीं किया जा सकता \u2248",
                  "arb":"لا يمكن القسمة على صفر"}

print(divide_by_zero["hin"])
type(divide_by_zero["hin"])

"""
Explanation: Unicode
Notice: You can use unicode inside your string variables. Unlike Python 2, no need to use u"" to use unicode.
End of explanation
"""


first_name = "Roshan"
last_name = "Rush"
formatted_name = "%s, %s." % (last_name, first_name[0])
print(formatted_name)

"""
Explanation: String Formatting
You can use this syntax to format a string:
python
some_variable = 50
x = "Value: %s" % some_variable
print(x) # Value: 50
End of explanation
"""


print("π ≈ %.2f" % 3.14159)

"""
Explanation: Other formatters could be used to format numbers:
End of explanation
"""


homeworks = 15.75
midterm = 22
final = 51
total = homeworks + midterm + final

print("Homeworks: %.2f\nMid-term: %.2f\nFinal: %.2f\nTotal: %.2f/100" % (homeworks, midterm, final, total))

"""
Explanation: To find unicode symbols:
http://www.fileformat.info/info/unicode/char/search.htm
End of explanation
"""


url = "http://{language}.wikipedia.org/"
url = url.format(language="en")
url

"""
Explanation: Using format(*args, **kwargs) function
End of explanation
"""


1+1

4-5

"""
Explanation: Mathematics
End of explanation
"""


14/5

14//5

2*5

"""
Explanation: Notice: The default behavior of division in Python 3 is float division. To use integer division like Python 2, use //
End of explanation
"""


2**3

"""
Explanation: To raise a number to any power use down asterisk **. To represent $a^{n}$:
python
a**n
End of explanation
"""


10 % 3

"""
Explanation: To calculate the remainder (modulo operator) use %. To represent $a \mod b = r$:
python
a % b # Returns r
End of explanation
"""


import math

n=52
k=1
math.factorial(n) / (math.factorial(k) * math.factorial(n-k))

"""
Explanation: You can 
You can use the math library to access a varaity of tools for algebra and geometry. To import a library, you can use one of these syntaxes:
python
import library_name
import library_name as alias
from module_name import some_class
End of explanation
"""


for counter in [1,2,3,4]:
    print(counter)

"""
Explanation: Loops
End of explanation
"""


for counter in range(5):
    print(counter)

"""
Explanation: range
In Python 3 range is a data type that generates a list of numbers.
python
range(stop)
range(start,stop[ ,step])
Notice: In Python 2 range is a function that returns a list. In Python 3, range returns an iterable of type range. If you need to get a list you can use the list() function:
python
list(range(start,stop[, step]))
End of explanation
"""


list(range(1,10)) == list(range(1,5)) + list(range(5,10))

"""
Explanation: Notice: The list doesn't reach the stop value and stops one step before. The reason behind that is to make this syntax possible:
End of explanation
"""


for counter in range(1,5):
    print(counter)

for counter in range(2,10,2):
    print(counter)

"""
Explanation: Notice: In Python 3 use use == to check if two values are equal. To check if two values are not equal use != and don't use &lt;&gt; from Python 2 because it is not supported any more in Python 3.
End of explanation
"""


counter =1
while counter < 5:
    print(counter)
    counter += 1

"""
Explanation: While Loop
End of explanation
"""


if math.pi == 3.2:
    print("Edward J. Goodwin was right!")
else:
    print("π is irrational")

if math.sqrt(2) == (10/7):
    print("Edward J. Goodwin was right!")
elif math.sqrt(2) != (10/7):
    print("Square root of 2 is irrational")

"""
Explanation: If .. Else
End of explanation
"""


probability = 0.3

if probability >= 0.75:
    print("Sure thing")
elif probability >= 0.5:
    print("Maybe")
elif probability >= 0.25:
    print("Unusual")
else:
    print("No way")

"""
Explanation: If you like Math:
Fun story about pi where it was almost set by law to be equal to 3.2!
If you don't what is the "pi bill" you can read about it here:
http://en.wikipedia.org/wiki/Indiana_Pi_Bill
Or watch Numberphile video about it:
https://www.youtube.com/watch?v=bFNjA9LOPsg
End of explanation
"""


def get_circumference(r):
    return math.pi * r * 2

get_circumference(5)

def binomilal_coef(n,k):
    """
    This function returns the binominal coef
    
    Parameters:
    ===========
    n, k int
    
    return n!/(k!*(n-k)!)
    """
    value = math.factorial(n)/(math.factorial(k)*math.factorial(n-k))
    return value


binomilal_coef(52,2)

"""
Explanation: Functions
Functions are defined in Python using def keyword.
End of explanation
"""


