# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="XYXQX6MHZOCT" colab_type="text"
# # Simple data types and operators

# + id="4nrTtKWTUfj-" colab_type="code" colab={}
name = 'iPhone 5s'

# + id="FPNzkLdmUm_K" colab_type="code" outputId="f10a6d80-a23a-48a3-8a0d-0fc678e009a4" executionInfo={"status": "ok", "timestamp": 1548592800609, "user_tz": -330, "elapsed": 851, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
type(name)

# + id="mPBSQQTmUt-g" colab_type="code" outputId="48da46e9-14e3-47ff-f539-32bf5897490d" executionInfo={"status": "ok", "timestamp": 1548592818694, "user_tz": -330, "elapsed": 1024, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(name)

# + id="TM72O_cVUyWX" colab_type="code" outputId="a3b49ead-483d-438a-95b7-2ed3165cf922" executionInfo={"status": "ok", "timestamp": 1548592836559, "user_tz": -330, "elapsed": 597, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
screen_size = 4.3
type(screen_size)

# + id="IVhG8yejU20h" colab_type="code" colab={}
num_of_speakers = 1

# + id="Pdl_938QU9m6" colab_type="code" outputId="44e575b0-4cfa-4f17-b4ac-d134145b1e93" executionInfo={"status": "ok", "timestamp": 1548592874315, "user_tz": -330, "elapsed": 1028, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
type(num_of_speakers)

# + id="46zyohNZU_7z" colab_type="code" outputId="9a836c53-a876-4b7a-96b6-3ac07d3b8184" executionInfo={"status": "ok", "timestamp": 1548592899081, "user_tz": -330, "elapsed": 946, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print('I just bought an ' + name)

# + id="nW9PGsCFVGAB" colab_type="code" outputId="5abe133f-5cd7-49df-f8db-cf83cbf3e519" executionInfo={"status": "ok", "timestamp": 1548592939657, "user_tz": -330, "elapsed": 914, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
a = 3
b = 2
print( a * b, a / b, a + b, a - b, a ** b, a // b)

# + id="O8n1BxEUVKlJ" colab_type="code" outputId="404f0091-9ad0-44b4-8195-0c227a0a6aba" executionInfo={"status": "ok", "timestamp": 1548592962291, "user_tz": -330, "elapsed": 754, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
is_android = False
type(is_android)

# + id="SwPmpf3OVVeJ" colab_type="code" outputId="172f6973-f4fe-4077-ad5d-4984100273b5" executionInfo={"status": "ok", "timestamp": 1548592977156, "user_tz": -330, "elapsed": 993, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print (is_android == True)

# + id="LJGzx6_oVZCg" colab_type="code" outputId="b73a3f82-f13b-4915-a861-caa4d14262ac" executionInfo={"status": "ok", "timestamp": 1548592997602, "user_tz": -330, "elapsed": 787, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print (is_android == False and num_of_speakers > 1)

# + [markdown] id="ufHD4qX3ZVyn" colab_type="text"
# # Code blocks - If, For, While

# + id="sM4hQO8XVeFv" colab_type="code" outputId="b7357edd-98e7-4b01-955e-e6a3a758da70" executionInfo={"status": "ok", "timestamp": 1548593097012, "user_tz": -330, "elapsed": 835, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
if is_android == True:
  print(name + ' supports Android')
  print('Continuing to print inside the if block')
print('Printing this outside the block')

# + id="CKZaAZ0iVvT8" colab_type="code" outputId="b58193f5-3d29-4cd6-af21-5ec9dd780d1d" executionInfo={"status": "ok", "timestamp": 1548593125778, "user_tz": -330, "elapsed": 766, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 113}
for i in range(5):
  print(i, i**2)

# + id="LLeT548bV9YT" colab_type="code" colab={}
# range?

# + id="ZPFWIgcsWA82" colab_type="code" outputId="40162151-4be7-4a51-e63d-6ae45460e646" executionInfo={"status": "ok", "timestamp": 1548593220875, "user_tz": -330, "elapsed": 869, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 113}
i = 0
while i < 5:
  print(i, i**2)
  i += 1 # equivalent to i = i + 1


# + [markdown] id="h7CFofgtZcz-" colab_type="text"
# # Functions

# + id="IgaKXk0eWO-N" colab_type="code" colab={}
def print_squares(stop_val):
  for i in range(stop_val):
    print (i , i**2)


# + id="OOqb6EWZWdcy" colab_type="code" outputId="d85e9c16-01b5-4f1e-b528-6fef23c3b8c1" executionInfo={"status": "ok", "timestamp": 1548593268962, "user_tz": -330, "elapsed": 794, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 113}
print_squares(5)

# + id="dRyGB-cVWgVi" colab_type="code" outputId="6368684b-4dc9-4365-befd-85d4fb84d2d1" executionInfo={"status": "ok", "timestamp": 1548593276325, "user_tz": -330, "elapsed": 802, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 74}
print_squares(3)


# + id="mOR_I24OWiIf" colab_type="code" colab={}
def sum_of_squares(stop_val):
  sum_ = 0
  for i in range(stop_val):
    sum_ += i ** 2
  return sum_


# + id="r1XbKgBcWtKF" colab_type="code" outputId="983d8b27-79c3-4be3-cf07-8b7eeb09d537" executionInfo={"status": "ok", "timestamp": 1548593337906, "user_tz": -330, "elapsed": 796, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
sum_of_squares(5)

# + id="fGP1QkdrWxKu" colab_type="code" colab={}
sum_5 = sum_of_squares(5)


# + id="KshU4IgCW1K4" colab_type="code" colab={}
def print_squares_with_startval(stop_val, start_val = 0):
  """Prints the squares of numbers starting from start_val (inclusive) and ending with stop_val (exclusive)"""
  for i in range(start_val, stop_val):
    print (i , i**2)


# + id="0VBEHuSEXHE1" colab_type="code" outputId="ac6eaa1a-2ff8-42d7-b158-3b705b4e298c" executionInfo={"status": "ok", "timestamp": 1548593497492, "user_tz": -330, "elapsed": 855, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 74}
print_squares_with_startval(5, 2)

# + id="xtjv8eBSXJcU" colab_type="code" colab={}
# print_squares_with_startval?

# + [markdown] id="NEUT8F6QamzU" colab_type="text"
# # Lists

# + id="w0YdzytNany6" colab_type="code" colab={}
my_phone = [name, is_android, screen_size]

# + id="znFZcOHwavn5" colab_type="code" outputId="df6cd9e5-c939-405a-f37c-ccf53ea2acb7" executionInfo={"status": "ok", "timestamp": 1548594389475, "user_tz": -330, "elapsed": 810, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
type(my_phone)

# + id="s3hC7aNoax5a" colab_type="code" outputId="7616097c-e6db-4970-b39a-70680570e247" executionInfo={"status": "ok", "timestamp": 1548594395341, "user_tz": -330, "elapsed": 1015, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(my_phone)

# + id="0DEZsBFPazSA" colab_type="code" outputId="e494b9d6-cd19-4244-c12f-33585e631a8c" executionInfo={"status": "ok", "timestamp": 1548594455123, "user_tz": -330, "elapsed": 617, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
my_phone[2]

# + id="eBK65TAoa4fK" colab_type="code" outputId="7aa7830a-002b-4838-c24f-3ab33c39f1cd" executionInfo={"status": "ok", "timestamp": 1548594424917, "user_tz": -330, "elapsed": 773, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
type(my_phone[0])

# + id="R5MUjfqLa6jq" colab_type="code" outputId="d9d7c414-03b5-4aa3-9816-3dd300781c4d" executionInfo={"status": "ok", "timestamp": 1548594461058, "user_tz": -330, "elapsed": 856, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
my_phone[1:3]

# + id="DJxUga5Ka-WG" colab_type="code" outputId="9154234f-17d7-453e-db51-055b5db5eaf6" executionInfo={"status": "ok", "timestamp": 1548594480989, "user_tz": -330, "elapsed": 709, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
my_dads_phone = my_phone
print(my_dads_phone)

# + id="2MG34sObbIQU" colab_type="code" colab={}
my_phone[2] = 4

# + id="Z3YndaQWbNyh" colab_type="code" outputId="66be1623-f473-4cf9-e31b-634867cbefb7" executionInfo={"status": "ok", "timestamp": 1548594509540, "user_tz": -330, "elapsed": 900, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(my_phone)

# + id="Ro-yczbAbPLx" colab_type="code" outputId="a88cc62a-98b2-48ca-a250-cd2fdcb7480e" executionInfo={"status": "ok", "timestamp": 1548594520017, "user_tz": -330, "elapsed": 745, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(my_dads_phone)

# + id="jZX5xgGQbRxl" colab_type="code" colab={}
my_dads_phone = list(my_phone)
# my_dads_phone = my_phone[:]

# + id="hLeiUELGbfnR" colab_type="code" colab={}
my_phone[2] = 4.3

# + id="NcnLRx74bhvn" colab_type="code" outputId="00d918a4-99d0-4d67-f1b5-ed711bf55fd4" executionInfo={"status": "ok", "timestamp": 1548594595401, "user_tz": -330, "elapsed": 802, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 55}
print(my_phone)
print(my_dads_phone)

# + id="K1yoXlp-bkLK" colab_type="code" outputId="85940ded-c42c-4e58-cb66-49ad1b6fac3c" executionInfo={"status": "ok", "timestamp": 1548594609122, "user_tz": -330, "elapsed": 722, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
len(my_phone)

# + id="V3NvYANKbnh_" colab_type="code" colab={}
# len?

# + id="GqBPaAS5bpw6" colab_type="code" colab={}
my_phone.append('3G')

# + id="0LY0vJlFbv61" colab_type="code" outputId="73166b8e-b4d3-43e5-b452-0a04df59c582" executionInfo={"status": "ok", "timestamp": 1548594647684, "user_tz": -330, "elapsed": 1039, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(my_phone)

# + id="ELv3B2lcbw4K" colab_type="code" outputId="6140b184-cd46-468f-cc2f-a82e47a81a9a" executionInfo={"status": "ok", "timestamp": 1548594654748, "user_tz": -330, "elapsed": 783, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
len(my_phone)

# + id="QZlmh30mbyqn" colab_type="code" colab={}
iphone5s_some_prefs = ['single_sim', 35000]

# + id="kKuLGThFb6I8" colab_type="code" colab={}
my_phone = my_phone + iphone5s_some_prefs

# + id="0Lx0f606b_FY" colab_type="code" outputId="bdcf9064-0e38-4236-be01-09872c6009fe" executionInfo={"status": "ok", "timestamp": 1548594711469, "user_tz": -330, "elapsed": 767, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(my_phone)

# + id="6zNovNkZcAhG" colab_type="code" outputId="456f995b-bc9a-4222-ce8d-cae16c81be62" executionInfo={"status": "ok", "timestamp": 1548594751987, "user_tz": -330, "elapsed": 734, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 132}
for data in my_phone:
  print(data)

# + id="gJ2vgUV3cKaH" colab_type="code" outputId="01d49454-6ddb-44db-da8c-35716045eae9" executionInfo={"status": "ok", "timestamp": 1548594765758, "user_tz": -330, "elapsed": 950, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
range(5)

# + id="HD8Dv1vWcNty" colab_type="code" outputId="5915aab7-2a9f-4c22-9127-fd0b9a71422b" executionInfo={"status": "ok", "timestamp": 1548594778079, "user_tz": -330, "elapsed": 773, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(list(range(5)))

# + id="9mX05ylFcQxE" colab_type="code" outputId="2a512390-30ac-4fe5-b99d-8f448f45dc8c" executionInfo={"status": "ok", "timestamp": 1548594810851, "user_tz": -330, "elapsed": 757, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
a = list(range(5))
print(a)

# + id="uqKrTubAcYxd" colab_type="code" colab={}
b = list(map(lambda x: x**2, a))

# + id="ApS_bIJGck9c" colab_type="code" outputId="9c2473b6-6145-4552-8f06-3e8fffc2a32a" executionInfo={"status": "ok", "timestamp": 1548594864759, "user_tz": -330, "elapsed": 756, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(b)

# + id="553AMMo9cl8L" colab_type="code" outputId="78b640ff-9f48-414a-8632-e02299bf62f7" executionInfo={"status": "ok", "timestamp": 1548594921956, "user_tz": -330, "elapsed": 742, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
c = list(filter(lambda x: x % 2 == 0, b))
print(c)

# + id="yNMVIPhGcz54" colab_type="code" outputId="61934484-a438-45a5-ea4d-45eb41b26aa7" executionInfo={"status": "ok", "timestamp": 1548596498885, "user_tz": -330, "elapsed": 581, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 55}
print(my_phone)
type(my_phone)

# + [markdown] id="iXIryw_wkSep" colab_type="text"
# # Tuples, Sets, and Dicts

# + id="zTEUhr5ii07E" colab_type="code" outputId="cc05532c-ff21-4331-d56f-39d1c5d4674b" executionInfo={"status": "ok", "timestamp": 1548596535024, "user_tz": -330, "elapsed": 731, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 55}
my_phone_tuple = ('iPhone 5s', False, 4.3)
print(my_phone_tuple)
type(my_phone_tuple)

# + id="DiFafO6Ti9uB" colab_type="code" outputId="a3cfc002-0c86-4001-c443-e7ec86bd1e37" executionInfo={"status": "ok", "timestamp": 1548596558444, "user_tz": -330, "elapsed": 614, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
my_phone_tuple[0:2]

# + id="Cv0N8__3jCGl" colab_type="code" outputId="0bef0735-7268-42d4-f847-3cd9709e8445" executionInfo={"status": "ok", "timestamp": 1548596567561, "user_tz": -330, "elapsed": 803, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 74}
for data in my_phone_tuple:
  print(data)

# + id="3ReasIC9jFps" colab_type="code" outputId="8fec570d-d632-4a5a-8062-3135a8c5d529" executionInfo={"status": "error", "timestamp": 1548596578000, "user_tz": -330, "elapsed": 743, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 179}
my_phone_tuple[2] = 4

# + id="Mrmaol0YjINt" colab_type="code" colab={}
import time

# + id="qnnhdMQFjZz9" colab_type="code" outputId="4de5982a-09a3-41c6-ec4f-d39f58673c01" executionInfo={"status": "ok", "timestamp": 1548596669194, "user_tz": -330, "elapsed": 736, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
tic = time.time()
print(tic)

# + id="caZRUKqcjeeR" colab_type="code" colab={}
# time.time?

# + id="evmSlFJPjf2N" colab_type="code" outputId="2c238780-35dd-4d13-f7be-3e26966abe41" executionInfo={"status": "ok", "timestamp": 1548596716965, "user_tz": -330, "elapsed": 735, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
tic = time.time()
# do something that takes some time that is to be measured
toc = time.time()
print('Elapsed time in seconds', toc - tic)

# + id="j-4qqt9ejqIq" colab_type="code" outputId="f9bf09d0-5b53-4beb-b16e-bce5a4b793c7" executionInfo={"status": "ok", "timestamp": 1548596834656, "user_tz": -330, "elapsed": 1172, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
my_list = list(range(1000000))
tic = time.time()
my_list_squared = map(lambda i: i**2, my_list)
toc = time.time()
print('Elapsed time in seconds', toc - tic)

# + id="6pu03oqbj5z4" colab_type="code" outputId="957df397-b163-415b-80ef-e5f23652b220" executionInfo={"status": "ok", "timestamp": 1548596838306, "user_tz": -330, "elapsed": 1081, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
my_tuple = tuple(range(1000000))
tic = time.time()
my_tuple_squared = map(lambda i: i**2, my_tuple)
toc = time.time()
print('Elapsed time in seconds', toc - tic)

# + id="RO5cewUtkDk0" colab_type="code" colab={}
my_set = set(my_phone)

# + id="tHmF19zjka0p" colab_type="code" outputId="4672cf64-d2d2-4a00-e35c-49ac06036d77" executionInfo={"status": "ok", "timestamp": 1548596922238, "user_tz": -330, "elapsed": 731, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(my_set)

# + id="zj0fCKqDkcQC" colab_type="code" colab={}
my_phone.append(4.3)

# + id="tTFDektFkhhj" colab_type="code" outputId="358aa126-efd1-48a0-b0b4-a0a61e5b4d6b" executionInfo={"status": "ok", "timestamp": 1548596947785, "user_tz": -330, "elapsed": 732, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(my_phone)

# + id="zu54Dw4skifm" colab_type="code" colab={}
my_set = set(my_phone)

# + id="dScJWQKhklqS" colab_type="code" outputId="6fb6f4f3-73a5-47d8-e784-774237789500" executionInfo={"status": "ok", "timestamp": 1548596970637, "user_tz": -330, "elapsed": 896, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(my_set)

# + id="HPag6Cr3kr_I" colab_type="code" outputId="f5c01db7-c3b8-4a32-921a-879d25653d56" executionInfo={"status": "ok", "timestamp": 1548597090900, "user_tz": -330, "elapsed": 754, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 93}
my_list = list(range(1000000))
tic = time.time()
print(98731 in my_list)
print(131591 in my_list)
print(1111111111 in my_list)
toc = time.time()
print('Elapsed time', toc - tic)

# + id="oGPTjV3xlFam" colab_type="code" outputId="cc3bc60c-1cd9-4060-b217-cbcd2e4ce673" executionInfo={"status": "ok", "timestamp": 1548597112598, "user_tz": -330, "elapsed": 1003, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 93}
my_set = set(range(1000000))
tic = time.time()
print(98731 in my_set)
print(131591 in my_set)
print(1111111111 in my_set)
toc = time.time()
print('Elapsed time', toc - tic)

# + id="f4gFVlIPlKqY" colab_type="code" colab={}
my_phone_dict = {}

# + id="rR7Wuj-plUUj" colab_type="code" outputId="aa6da9fe-aa2c-4b83-fb42-11c2f5a2399c" executionInfo={"status": "ok", "timestamp": 1548597156962, "user_tz": -330, "elapsed": 749, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
type(my_phone_dict)

# + id="6lOSqt7AlVjo" colab_type="code" colab={}
my_phone_dict['name'] = 'iPhone 5s'
my_phone_dict['isAndroid'] = False
my_phone_dict['screenSize'] = 4.3

# + id="SkH6EGBblg9V" colab_type="code" outputId="75321dc6-dba9-46b6-a2d0-66923c72e4a3" executionInfo={"status": "ok", "timestamp": 1548597210495, "user_tz": -330, "elapsed": 782, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(my_phone_dict)

# + id="T9z8HizClim9" colab_type="code" outputId="eb860244-ad37-4123-97a2-ebb00d11fab3" executionInfo={"status": "ok", "timestamp": 1548597223189, "user_tz": -330, "elapsed": 853, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
my_phone_dict['name']

# + id="7pHwVu93llst" colab_type="code" outputId="c18017da-da0f-4016-a701-19b6e0cd78ab" executionInfo={"status": "ok", "timestamp": 1548597250308, "user_tz": -330, "elapsed": 964, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(my_phone_dict.keys())

# + id="ogBrVfpHlsSc" colab_type="code" outputId="7f701b7e-e985-4ac8-dda7-30e5b33b8850" executionInfo={"status": "ok", "timestamp": 1548597264082, "user_tz": -330, "elapsed": 726, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(my_phone_dict.values())

# + id="HpK08O1alvtd" colab_type="code" outputId="39f5087a-1c86-4df2-911c-165408f05a95" executionInfo={"status": "ok", "timestamp": 1548597272980, "user_tz": -330, "elapsed": 695, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(my_phone_dict.items())

# + id="-78yQjyilx4g" colab_type="code" outputId="654a0fbe-e58c-4b2a-84fa-ab9c9b45a308" executionInfo={"status": "ok", "timestamp": 1548597305016, "user_tz": -330, "elapsed": 839, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 74}
for key in my_phone_dict.keys():
  print(key, ':', my_phone_dict[key])

# + [markdown] id="4nvsLqecoOoP" colab_type="text"
# # Python Packages

# + id="eCkZm4lxoQJB" colab_type="code" colab={}
import math

# + id="lSiEHau3oV8S" colab_type="code" outputId="f9c2160c-8b15-4a58-e197-ecde031b3685" executionInfo={"status": "ok", "timestamp": 1548732170510, "user_tz": -330, "elapsed": 803, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
a = math.sqrt(100)
print(a)

# + id="3yZAgHD1oX2H" colab_type="code" outputId="7aff1eed-83dd-44fe-e86f-6f33fad8f6a7" executionInfo={"status": "ok", "timestamp": 1548732180758, "user_tz": -330, "elapsed": 807, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
a = math.pow(100, 0.5)
print(a)

# + id="pdPODnnzoaWP" colab_type="code" outputId="c4aff6aa-073b-4b03-9060-dc69e31a67a6" executionInfo={"status": "ok", "timestamp": 1548732248934, "user_tz": -330, "elapsed": 1127, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 56}
x = 100
y = 1
for i in range(1, x):
  y *= i
print('Factorial of', x, 'is', y)

# + id="2Wc0vvPxopEH" colab_type="code" colab={}
y = math.factorial(x)

# + id="M7amwM7YoxLv" colab_type="code" colab={}
import math as m

# + id="EPPb0q4xo0yX" colab_type="code" colab={}
y = m.factorial(x)

# + id="lyMXPcaeo2Aw" colab_type="code" colab={}
from math import factorial

# + id="azItJu7Ao5bb" colab_type="code" colab={}
y = factorial(x)

# + id="5YrGXzyYo6lb" colab_type="code" outputId="624abc93-3f9b-45e5-e86a-5e0ac6d6e7a3" executionInfo={"status": "ok", "timestamp": 1548732446019, "user_tz": -330, "elapsed": 855, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 55}
vals = list(range(1, 100))
tic = time.time()
for x in vals:
  y = 1
  for i in range(1, x):
    y *= i
toc = time.time()
print('Elapsed time in secs with own function', toc - tic)

tic = time.time()
for x in vals:
  y = math.factorial(x)
toc = time.time()
print('Elapsed time in secs with own function', toc - tic)

# + id="u1CRIBPtpP7S" colab_type="code" colab={}
# !echo 'def hello():' > my_first_module.py
# !echo '    print("hello, i am living in a different file!!!")' >> my_first_module.py

# + id="3q0hPJ8IpwYX" colab_type="code" outputId="e3ee6f82-58fd-4d16-acd0-e146668b5fd3" executionInfo={"status": "ok", "timestamp": 1548732587413, "user_tz": -330, "elapsed": 2982, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 55}
# !cat my_first_module.py

# + id="6ItBO96rp1O0" colab_type="code" colab={}
import my_first_module

# + id="HAPgfIjMqEhz" colab_type="code" outputId="34e85f2f-06ee-4ea0-b05c-ff7e8b2a33bb" executionInfo={"status": "ok", "timestamp": 1548732624160, "user_tz": -330, "elapsed": 764, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
my_first_module.hello()

# + id="iiJNMrLGqGm0" colab_type="code" colab={}
from my_first_module import hello

# + id="t7idGE7-qJUV" colab_type="code" outputId="3dc41eb3-fb90-4b2f-b5bb-d8c6b8e245cf" executionInfo={"status": "ok", "timestamp": 1548732637493, "user_tz": -330, "elapsed": 763, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
hello()

# + [markdown] id="gU7QTkRy3SMz" colab_type="text"
# # File handling

# + id="_CStPzCqqJ3G" colab_type="code" outputId="7635ce87-317a-4839-a81f-6c21a5b23ef9" executionInfo={"status": "ok", "timestamp": 1548736116275, "user_tz": -330, "elapsed": 2715, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 419}
# !wget https://www.dropbox.com/s/w94odi4aq1k44lf/mobile_cleaned.csv

# + id="exNoyWvW3asG" colab_type="code" outputId="fe07f7ae-d1f3-49b2-a810-b13c32c35c69" executionInfo={"status": "ok", "timestamp": 1548736124003, "user_tz": -330, "elapsed": 3149, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
# !ls

# + id="UEjTlzPt3ceh" colab_type="code" colab={}
file = open('mobile_cleaned.csv', 'r')

# + id="K0cZlXDS3nUA" colab_type="code" colab={}
s = file.readline()

# + id="nARRi5LD3pU2" colab_type="code" outputId="ae9ea891-1355-47dd-bfe8-4c77bb35117f" executionInfo={"status": "ok", "timestamp": 1548736178272, "user_tz": -330, "elapsed": 758, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 75}
print(s)

# + id="iqGdV0ej3qTx" colab_type="code" outputId="a3f8516a-d159-44a3-83ab-63a3985bf10a" executionInfo={"status": "ok", "timestamp": 1548736219722, "user_tz": -330, "elapsed": 977, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 56}
print(s.split(','))

# + id="XWU2nyzf30Xr" colab_type="code" colab={}
file.close()

# + id="uK4w6pJs35Ey" colab_type="code" outputId="939899bd-2f50-42fb-afab-cee3f99cc591" executionInfo={"status": "error", "timestamp": 1548736243263, "user_tz": -330, "elapsed": 766, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 179}
file.readline()

# + id="AWmQKP-t36LK" colab_type="code" outputId="68821293-6a8f-440f-a620-e45ca07f45b0" executionInfo={"status": "ok", "timestamp": 1548736284478, "user_tz": -330, "elapsed": 737, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 75}
with open('mobile_cleaned.csv', 'r') as file:
  print(file.readline())

# + id="losKznsX4EPL" colab_type="code" colab={}
with open('mobile_cleaned.csv', 'r') as file:
  print(file.read())

# + id="Z7ZiqBi-4NAw" colab_type="code" colab={}
with open('mobile_cleaned.csv', 'r') as file:
  for line in file:
    for word in line.split(','):
      print(word)
    print('-------')

# + id="kaekxExq4Yme" colab_type="code" colab={}
with open('my_first_file_output.txt', 'w') as file:
  file.write('hello world from python code')


# + id="gB2XHSeU4rWN" colab_type="code" outputId="5b03fc87-d3e9-432f-b59e-c56c2a92ebb8" executionInfo={"status": "ok", "timestamp": 1548736466654, "user_tz": -330, "elapsed": 3175, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
# !cat my_first_file_output.txt

# + [markdown] id="z-G5jSNg1g2Z" colab_type="text"
# # Python Classes

# + id="ETDYzg4a1iAN" colab_type="code" colab={}
class MobilePhone:
  """This is a sample class to illustrate how Python classes work"""
  def __init__(self, name, is_android = False, screen_size = 4.3):
    self.name = name
    self.is_android = is_android
    self.screen_size = screen_size
    self.rating = -1
    
  def has_rating(self):
    return self.rating > -1


# + id="vkHApjaE1kod" colab_type="code" colab={}
new_phone = MobilePhone('iPhone 5s')

# + id="L4KjarI-1mPH" colab_type="code" outputId="693b474b-d1a7-4906-abcd-eab695e47648" executionInfo={"status": "ok", "timestamp": 1548752488694, "user_tz": -330, "elapsed": 864, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
type(new_phone)

# + id="aw6De6Fi1nmp" colab_type="code" outputId="dd8bd2fe-5f04-46bc-8a1f-5e90e35b6320" executionInfo={"status": "ok", "timestamp": 1548752776481, "user_tz": -330, "elapsed": 832, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(new_phone.name, new_phone.is_android, new_phone.screen_size)

# + id="ngQoF2tn27D3" colab_type="code" colab={}
new_phone.screen_size = 4

# + id="vPOH3OsF2-HW" colab_type="code" outputId="cfe2335b-f92e-4af7-9a05-1b6424565184" executionInfo={"status": "ok", "timestamp": 1548752870066, "user_tz": -330, "elapsed": 862, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
new_phone.has_rating()

# + id="u4_kG8F73OoA" colab_type="code" colab={}
new_phone.rating = 3.9

# + id="9uU7BylG3U5K" colab_type="code" outputId="1855b70c-1abb-41dd-dcae-e6cf097bee65" executionInfo={"status": "ok", "timestamp": 1548752900534, "user_tz": -330, "elapsed": 875, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
MobilePhone.__doc__


# + id="qNUICpHc3c2w" colab_type="code" colab={}
class iPhone(MobilePhone):
  def __init__(self, name):
    MobilePhone.__init__(self, name, False, 4)
    
  def __str__(self):
    return self.name + " " + str(self.is_android) + " " + str(self.screen_size)


# + id="6rvMwJsL3rgO" colab_type="code" colab={}
new_iphone = iPhone('iPhone 5s')

# + id="7Gj-7qNG3t-J" colab_type="code" outputId="b1c51432-8ff5-42d4-ac32-d8e1c7a3ab9a" executionInfo={"status": "ok", "timestamp": 1548752976889, "user_tz": -330, "elapsed": 725, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
new_iphone.is_android

# + id="MadGk2Po3viS" colab_type="code" outputId="1c30b731-4eb2-48ba-da97-cf759665adf2" executionInfo={"status": "ok", "timestamp": 1548753041894, "user_tz": -330, "elapsed": 736, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(new_iphone)

# + [markdown] id="0wUuGWGY67PE" colab_type="text"
# # NumPy

# + id="aUV4wAG369uu" colab_type="code" colab={}
import numpy as np

# + id="MTXAOj6O6-0_" colab_type="code" outputId="8c7614df-d4b5-45e4-87d7-6d84782e1f9b" executionInfo={"status": "ok", "timestamp": 1548753846347, "user_tz": -330, "elapsed": 751, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
X = np.array([1, 2, 3])
print(X)

# + id="cq5AQNm87DzV" colab_type="code" outputId="f59dc895-9307-4031-8571-2fa0b7f2b6d2" executionInfo={"status": "ok", "timestamp": 1548753851018, "user_tz": -330, "elapsed": 741, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
type(X)

# + id="gO4eo4BB7E8o" colab_type="code" outputId="d8845a2e-4053-472a-e0c5-677f22e6bfa3" executionInfo={"status": "ok", "timestamp": 1548753871057, "user_tz": -330, "elapsed": 736, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
l = [4, 5, 10]
X = np.asarray(l)
type(X)

# + id="OMuLgPDF7J1X" colab_type="code" outputId="9257ccbd-445a-49e8-f376-da6463b184a4" executionInfo={"status": "ok", "timestamp": 1548753879987, "user_tz": -330, "elapsed": 773, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(X)

# + id="BeIAsx0v7MAx" colab_type="code" outputId="13997bfa-9312-4d14-80e1-9c52cbb11cf3" executionInfo={"status": "ok", "timestamp": 1548753894948, "user_tz": -330, "elapsed": 802, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
X = np.asarray(l, float)
print(X)

# + id="4YvhBkW87PqC" colab_type="code" outputId="1eff147d-c6ff-4c94-95ee-5812c9ddfa69" executionInfo={"status": "ok", "timestamp": 1548753906394, "user_tz": -330, "elapsed": 745, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
X.shape

# + id="-23qSA5g7Sdt" colab_type="code" colab={}
# np.array?

# + id="j8uf0P_97YyA" colab_type="code" colab={}
X = np.array([[1, 2, 3], [4, 5, 6]])

# + id="MCAscn-A7hs8" colab_type="code" outputId="e6f9ba02-de2f-46f8-d846-2303555cf021" executionInfo={"status": "ok", "timestamp": 1548753971449, "user_tz": -330, "elapsed": 776, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 55}
print(X)

# + id="F1y0RgnH7iV6" colab_type="code" outputId="70b40af7-5afa-472e-8508-c98a5b28f2bd" executionInfo={"status": "ok", "timestamp": 1548753980401, "user_tz": -330, "elapsed": 747, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
X.shape

# + id="aM-Ag6wU7kiL" colab_type="code" outputId="4d86db7e-4566-4aa8-abf4-09c9e649df51" executionInfo={"status": "ok", "timestamp": 1548754042681, "user_tz": -330, "elapsed": 847, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
X[1, 2]

# + id="m0olUSq07wAz" colab_type="code" outputId="c5c809a6-4239-4f18-a9df-42073c927aed" executionInfo={"status": "ok", "timestamp": 1548754060584, "user_tz": -330, "elapsed": 728, "user": {"displayName": "One <NAME> Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
X[0, 0:2]

# + id="frA-UZik74GU" colab_type="code" outputId="994c32fc-db8d-4f9f-9110-34758f18bcd5" executionInfo={"status": "ok", "timestamp": 1548754072760, "user_tz": -330, "elapsed": 713, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
X[0, :]

# + id="T3MxHZSR77E4" colab_type="code" colab={}
X = np.zeros((4, 5))

# + id="D-CNl8se8ABG" colab_type="code" outputId="a86a3f0d-1334-4847-87b3-69cf1c1af338" executionInfo={"status": "ok", "timestamp": 1548754095157, "user_tz": -330, "elapsed": 755, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 93}
print(X)

# + id="Ux36ygka8Ai1" colab_type="code" colab={}
X = np.eye(4, 4)

# + id="Wbbz7nU68FIr" colab_type="code" outputId="715353dd-25f5-4c60-bc99-8312cf502ccd" executionInfo={"status": "ok", "timestamp": 1548754137333, "user_tz": -330, "elapsed": 567, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 93}
print(X)

# + id="-KvyuCVU8IJH" colab_type="code" colab={}
X = np.random.random((4, 5))

# + id="dqpmLeRx8PU0" colab_type="code" outputId="b94db2ad-5854-4298-8908-a7aa8970fe77" executionInfo={"status": "ok", "timestamp": 1548754175958, "user_tz": -330, "elapsed": 973, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 93}
print(X)

# + id="3WTNwVYE8Qp0" colab_type="code" colab={}
Z = X.T

# + id="5fuP8kc78W0T" colab_type="code" outputId="1a414026-49a1-4dfc-9852-24cd35155d59" executionInfo={"status": "ok", "timestamp": 1548754196029, "user_tz": -330, "elapsed": 625, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 113}
print(Z)

# + id="M9rIFpsl8YKE" colab_type="code" colab={}
Y = X.reshape(20, 1)

# + id="M6nBY7pd8eQ2" colab_type="code" outputId="74ca460f-6dac-489f-b708-6ab3b9b1f748" executionInfo={"status": "ok", "timestamp": 1548754221832, "user_tz": -330, "elapsed": 984, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 399}
print(Y)

# + id="S9M9AXsS8faf" colab_type="code" outputId="90015b00-19a9-4797-fba9-0e4f32669e13" executionInfo={"status": "ok", "timestamp": 1548754259035, "user_tz": -330, "elapsed": 782, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
A = np.arange(5)
print(A)

# + id="u3HrI5_98oin" colab_type="code" colab={}
B = np.arange(5)

# + id="jvLlYcMz8ruY" colab_type="code" outputId="88420ca9-fb6d-4389-88c8-6f3fc18c1ec6" executionInfo={"status": "ok", "timestamp": 1548754286980, "user_tz": -330, "elapsed": 777, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
C = A + B
D = A - B
E = A * B
print(C, D, E)

# + id="vUsGKXTe8vXp" colab_type="code" outputId="da43ab88-e193-40b2-ff44-983de0e9e132" executionInfo={"status": "ok", "timestamp": 1548754303991, "user_tz": -330, "elapsed": 726, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
print(A, A + 1)

# + id="VDohF0vp8zhz" colab_type="code" outputId="0460f2e7-d7a7-41ac-a5de-fab229cac4e9" executionInfo={"status": "ok", "timestamp": 1548754351783, "user_tz": -330, "elapsed": 875, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 93}
A = np.random.random((2, 3))
print(A)
print(A + 1)

# + id="cDyBixAq88Rq" colab_type="code" outputId="44fcfc26-1e63-490b-88e0-929c29377911" executionInfo={"status": "ok", "timestamp": 1548754396584, "user_tz": -330, "elapsed": 719, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 55}
A = np.floor(np.random.random((2, 3))*10)
print(A)

# + id="83SVLoCV9KI2" colab_type="code" outputId="52380258-4835-459c-beaf-7185c83b29d3" executionInfo={"status": "ok", "timestamp": 1548754434066, "user_tz": -330, "elapsed": 776, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
u = [1, 2, 3]
v = [-1, 0, 1]

p1 = np.inner(u, v)
print(p1)

# + id="2cTF8Dj39TRW" colab_type="code" outputId="73bc1171-e693-4863-89b1-85de6ec9e6c5" executionInfo={"status": "ok", "timestamp": 1548754453397, "user_tz": -330, "elapsed": 702, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 74}
p2 = np.outer(u, v)
print(p2)

# + id="8bvV3VLf9YAk" colab_type="code" outputId="6208b853-a6ce-4dff-e110-c3c05cb923b4" executionInfo={"status": "ok", "timestamp": 1548754497164, "user_tz": -330, "elapsed": 788, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 55}
A = np.ones((2, 3))
B = np.ones((3, 2))
np.dot(A, B)

# + id="r-1EvJHN9irJ" colab_type="code" outputId="63808838-d423-4713-926c-45dd195ea9e9" executionInfo={"status": "ok", "timestamp": 1548754514766, "user_tz": -330, "elapsed": 711, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 55}
np.dot(B.T, A.T)

# + id="6RKfdl_q9m_S" colab_type="code" outputId="1cd1cb6b-f5aa-4da1-d7b2-f323b8ca9d37" executionInfo={"status": "ok", "timestamp": 1548754525692, "user_tz": -330, "elapsed": 1028, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 55}
A = np.ones((2, 3))
print(A)

# + id="50bhOhuY9plm" colab_type="code" outputId="7ee337fb-0c2a-4364-edc1-940d805f7201" executionInfo={"status": "ok", "timestamp": 1548754530300, "user_tz": -330, "elapsed": 746, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
A.sum()

# + id="P6y9EEdY9qyD" colab_type="code" outputId="51ce949e-46e6-4798-b7bc-9cf1c11233e3" executionInfo={"status": "ok", "timestamp": 1548754551330, "user_tz": -330, "elapsed": 695, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
A.sum(axis = 0)

# + id="l87rZ2Bt9v6c" colab_type="code" outputId="8f6d35f9-5480-4150-9269-f17df9a9de2e" executionInfo={"status": "ok", "timestamp": 1548754561468, "user_tz": -330, "elapsed": 726, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
A.sum(axis = 1)

# + id="v8j0GuVC9yZM" colab_type="code" outputId="0fb6dd37-228e-4d66-aadb-605c39d1e49e" executionInfo={"status": "ok", "timestamp": 1548754567479, "user_tz": -330, "elapsed": 713, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}} colab={"base_uri": "https://localhost:8080/", "height": 36}
A.max()

# + id="K-8LkSefyrxw" colab_type="code" colab={}


# + [markdown] id="RcMuyR28zDPw" colab_type="text"
# # Plotting

# + id="F2NwFmsD0NNr" colab_type="code" colab={}
import matplotlib.pyplot as plt
import numpy as np

# + id="RXIyNRGB0Tfp" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 208} outputId="bc5312fa-b7a4-4aae-e413-317fa1980bef" executionInfo={"status": "ok", "timestamp": 1548819512425, "user_tz": -330, "elapsed": 1053, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}}
x = np.random.random((10, 1))
print(x)

# + id="q25Y0IJG0XPb" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 269} outputId="98894967-582b-4c68-c156-2def1ad87447" executionInfo={"status": "ok", "timestamp": 1548819512787, "user_tz": -330, "elapsed": 1393, "user": {"displayName": "One <NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
plt.plot(x, '*-')
plt.show()

# + id="xwwFs1JY0ZfN" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 269} outputId="b3e4c41b-2e0c-4fa9-cdc6-73169bf6edd4" executionInfo={"status": "ok", "timestamp": 1548819512790, "user_tz": -330, "elapsed": 1362, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
x = np.linspace(0, 100, 50)
y = np.power(x, 2)
plt.plot(x, y, '+')
plt.show()

# + id="0tGC0DCB01dx" colab_type="code" colab={}
import seaborn as sns

# + id="WNdO9A1F1HkN" colab_type="code" colab={}
sns.set()

# + id="usDEQ0Sm1Iu5" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 274} outputId="52bd6ccf-5da2-4523-c345-6c2416c2caed" executionInfo={"status": "ok", "timestamp": 1548819530683, "user_tz": -330, "elapsed": 867, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}}
sns.lineplot(x, y)
plt.show()

# + id="9JmBRLjl1Vc9" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 419} outputId="c33fcb01-2372-4e11-a3ab-2fcc7b91c448" executionInfo={"status": "ok", "timestamp": 1548819564640, "user_tz": -330, "elapsed": 3424, "user": {"displayName": "One Fourth Labs Student", "photoUrl": "", "userId": "07586129509304884691"}}
# !wget https://www.dropbox.com/s/w94odi4aq1k44lf/mobile_cleaned.csv

# + id="TuW2gohJ1vpH" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 36} outputId="6937a811-48d0-49e3-e646-57494b664bfb" executionInfo={"status": "ok", "timestamp": 1548819571538, "user_tz": -330, "elapsed": 2832, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
# !ls

# + id="8MTCMQFG1xeh" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 256} outputId="d9016874-33d4-42d2-b0bc-0d4d64cbf5a3" executionInfo={"status": "ok", "timestamp": 1548819596597, "user_tz": -330, "elapsed": 755, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
import pandas as pd
data = pd.read_csv('mobile_cleaned.csv')
data.head()

# + id="5tCFDbiF14HM" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 291} outputId="7cc8618d-b335-4c55-cfd1-ce10070ae456" executionInfo={"status": "ok", "timestamp": 1548819647542, "user_tz": -330, "elapsed": 787, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
ax = sns.scatterplot(x="stand_by_time", y="battery_capacity", data=data)

# + id="4kUBm6WF2Eid" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 291} outputId="6348b5a0-4714-4fb3-a5c7-4118a442f11e" executionInfo={"status": "ok", "timestamp": 1548819725783, "user_tz": -330, "elapsed": 792, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
ax = sns.scatterplot(x = "stand_by_time", y = "battery_capacity", hue="thickness", data=data)

# + id="Tjfgfhag2Xoh" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 291} outputId="7835f0e8-31eb-4a0f-a83d-53ef9de82e3a" executionInfo={"status": "ok", "timestamp": 1548819765784, "user_tz": -330, "elapsed": 746, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
ax = sns.distplot(data["stand_by_time"])

# + id="bV9DgHe12haU" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 291} outputId="cf35dd9e-1b4d-47af-b982-8add23697a74" executionInfo={"status": "ok", "timestamp": 1548819829955, "user_tz": -330, "elapsed": 845, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
ax = sns.distplot(data["stand_by_time"], kde=False, rug=True, bins = 20)

# + id="iP9zrLI92t89" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 291} outputId="89785138-36ae-4166-f6cb-067e625b4000" executionInfo={"status": "ok", "timestamp": 1548819882088, "user_tz": -330, "elapsed": 734, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
ax = sns.boxplot(x="is_liked", y="battery_capacity", data=data)

# + id="p4UoIsEY29zx" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 291} outputId="de26789b-3297-4cbd-b590-d4b2c4621be8" executionInfo={"status": "ok", "timestamp": 1548819951830, "user_tz": -330, "elapsed": 731, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
ax = sns.boxplot(x = "expandable_memory", y = "price", data=data)

# + id="syqEvEkB3O1e" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 399} outputId="58a9411f-a18f-48d7-e2e7-1b1fc0daa301" executionInfo={"status": "ok", "timestamp": 1548820004856, "user_tz": -330, "elapsed": 692, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
uniform_data = np.random.rand(10, 12)
print(uniform_data)

# + id="BcF0aSUl3bye" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 274} outputId="84062503-121c-456c-d814-07225bbd8dbf" executionInfo={"status": "ok", "timestamp": 1548820050108, "user_tz": -330, "elapsed": 837, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
ax = sns.heatmap(uniform_data, cmap="YlGnBu")

# + id="VVR75RpL3fCQ" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 227} outputId="68c9179c-2a6a-4c38-d2c7-7906f5666202" executionInfo={"status": "ok", "timestamp": 1548820091705, "user_tz": -330, "elapsed": 2876, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
# !wget https://s3.amazonaws.com/thinkific-import/153034/3f9yaVLKTyUGmlBPcSOA_logo_long.png

# + id="7-Q_iKju3wdR" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 36} outputId="9e3f3795-f802-41ec-fd27-8ab945410abc" executionInfo={"status": "ok", "timestamp": 1548820097302, "user_tz": -330, "elapsed": 3175, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
# !ls

# + id="KgkiVMM33xww" colab_type="code" colab={}
# !mv 3f9yaVLKTyUGmlBPcSOA_logo_long.png onefourthlabs.png

# + id="22iOaO2G31eE" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 36} outputId="88ab30b2-2fc2-4f16-f415-a85d37e26d3b" executionInfo={"status": "ok", "timestamp": 1548820117218, "user_tz": -330, "elapsed": 3191, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
# !ls

# + id="9Vq30WyH32ni" colab_type="code" colab={}
import matplotlib.image as mpimg

# + id="wSI9QFqL37hU" colab_type="code" colab={}
img = mpimg.imread('onefourthlabs.png')

# + id="pfmD9rIm3_B9" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 954} outputId="eaed982a-67ed-4f0d-9d32-6cfc3080c73d" executionInfo={"status": "ok", "timestamp": 1548820157379, "user_tz": -330, "elapsed": 748, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
print(img)

# + id="jw3eIxBa4BBb" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 141} outputId="3b7cfe73-0fbe-4798-d0fc-c05985d43367" executionInfo={"status": "ok", "timestamp": 1548820186277, "user_tz": -330, "elapsed": 789, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "07586129509304884691"}}
imgplot = plt.imshow(img)

# + id="KaLC_q5a4IDn" colab_type="code" colab={}


# + [markdown] id="46sl8tGg6E5n" colab_type="text"
# # Pandas

# + id="5ra4u9GU6GiY" colab_type="code" colab={}


StarcoderdataJupyterScriptsDedupFiltered