Skip to content

Commit c562f28

Browse files
committed
Adds: jupyter_pipline, spotifyAPI and format code
Changes committed: new file: jupyter_pipeline/1_loadData.ipynb new file: jupyter_pipeline/2_combiningDataframes.ipynb new file: jupyter_pipeline/3_cleanup_data.ipynb new file: jupyter_pipeline/cache/movies-boxoffice-dataset-cleaned.csv new file: jupyter_pipeline/cache/movies-boxoffice-dataset.csv new file: jupyter_pipeline/data/movies-2011.csv new file: jupyter_pipeline/data/movies-2012.csv new file: jupyter_pipeline/data/movies-2013.csv new file: jupyter_pipeline/data/movies-2014.csv new file: jupyter_pipeline/data/movies-2015.csv new file: jupyter_pipeline/data/movies-2016.csv new file: jupyter_pipeline/data/movies-2017.csv new file: jupyter_pipeline/data/movies-2018.csv new file: jupyter_pipeline/data/movies-2019.csv new file: jupyter_pipeline/data/movies-2020.csv new file: jupyter_pipeline/requirements.txt new file: jupyter_pipeline/server/main.py new file: jupyter_pipeline/server/run.sh new file: spotify_API/clients/spotify_client.py new file: spotify_API/convert_to_script.sh new file: spotify_API/import_client.py new file: spotify_API/notebooks/1 - Auth.ipynb new file: spotify_API/notebooks/2 - Base API client.ipynb new file: spotify_API/notebooks/3 - Use AccessToken.ipynb new file: spotify_API/notebooks/4 - Resource-Enabled Client.ipynb new file: spotify_API/notebooks/5 - Robust Query Search.ipynb new file: spotify_API/notebooks/spotify_client.ipynb new file: spotify_API/requirements.txt
1 parent b934a93 commit c562f28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+28090
-372
lines changed

Diff for: Final Capstone Project/Binary_convertor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ def binary(num):
99
num //= 2
1010

1111
rem = rem[::-1]
12-
return reduce(lambda x, y: x*10+y, rem)
12+
return reduce(lambda x, y: x * 10 + y, rem)
1313

1414

1515
def decimal(num):
1616
num = list(num)
1717
lst = []
1818
for i in range(len(num)):
19-
lst.append(int(num[i])*(2**i))
19+
lst.append(int(num[i]) * (2 ** i))
2020
return sum((lst))
2121

2222

Diff for: Final Capstone Project/City_distance.py

+14-9
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,37 @@
33

44
def distance(coord1, coord2):
55
"""
6-
This uses the formula 'haversine' to calculate the great-circle distance b/w two points - that is the shortest distance over the earth surface.
6+
This uses the formula 'haversine' to calculate the great-circle distance b/w two points - that is the shortest distance over the earth surface.
77
88
"""
99

1010
lat1, long1 = coord1
1111
lat2, long2 = coord2
1212
R = 6371
13-
a = (sin((lat2 - lat1)/2))**2 + cos(lat1) * \
14-
cos(lat2)*(sin((long2 - long1)/2))**2
15-
c = 2 * (atan2(a**0.5, (1-a)**0.5))
13+
a = (sin((lat2 - lat1) / 2)) ** 2 + cos(lat1) * cos(lat2) * (
14+
sin((long2 - long1) / 2)
15+
) ** 2
16+
c = 2 * (atan2(a ** 0.5, (1 - a) ** 0.5))
1617
d = R * c
1718
return d
1819

1920

2021
if __name__ == "__main__":
2122
print("\n\nEnter The co-ordinate of two cities : \n")
22-
latitude1, longitude1 = (float(x) for x in input(
23-
"Enter Latitude and Longitude : ").split())
24-
latitude2, longitude2 = (float(x) for x in input(
25-
"Enter Latitude and Longitude : ").split())
23+
latitude1, longitude1 = (
24+
float(x) for x in input("Enter Latitude and Longitude : ").split()
25+
)
26+
latitude2, longitude2 = (
27+
float(x) for x in input("Enter Latitude and Longitude : ").split()
28+
)
2629

2730
dist = distance((latitude1, longitude1), (latitude2, longitude2))
2831

2932
print("Choose your unit to display : ")
3033
print("The Distance between two cities : \n")
31-
print("1. Kilometers\n2. Meters\n3. Miles\n4. Inches\n5. Foot\n6. Yard\n7. Light Year\n0. Exit")
34+
print(
35+
"1. Kilometers\n2. Meters\n3. Miles\n4. Inches\n5. Foot\n6. Yard\n7. Light Year\n0. Exit"
36+
)
3237
ch = int(input("Enter your choice : "))
3338
if ch == 0:
3439
print("Thank You..!!")

Diff for: Final Capstone Project/Fibnacci_sequence.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ def fibnacci(num):
22
a, b = 0, 1
33
while num:
44
yield a
5-
a, b = b, a+b
5+
a, b = b, a + b
66
num -= 1
77

88

99
def fib_seq(num):
1010
a, b = 0, 1
1111
while True:
1212
yield a
13-
a, b = b, a+b
13+
a, b = b, a + b
1414
if num < a:
1515
break
1616

Diff for: Final Capstone Project/FindCostOfTile.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
def find_cost(cost_per_tile, w, h):
2-
'''
3-
Return the total cost of tile to cover
4-
WxH floor
5-
'''
6-
return cost_per_tile * (w*h)
2+
"""
3+
Return the total cost of tile to cover
4+
WxH floor
5+
"""
6+
return cost_per_tile * (w * h)
77

88

99
w, h = (int(x) for x in input("Enter W and H : ").split())
1010
cost_tile = float(input("Enter the cost per tile : "))
11-
print("Total cost of tile to cover WxH floor : = {:.3f}".format(
12-
find_cost(cost_tile, w, h)))
11+
print(
12+
"Total cost of tile to cover WxH floor : = {:.3f}".format(
13+
find_cost(cost_tile, w, h)
14+
)
15+
)

Diff for: Final Capstone Project/FindPI.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from math import pi
2+
23
n = int(input("Enter a number : "))
34
if n > 15 or n < 0:
45
print("Please Enter the value between 0 to 15 .!!")
56
else:
67
p = str(pi)
7-
print("PI upto {} decimal place = {}".format(n, p[:n+2]))
8+
print("PI upto {} decimal place = {}".format(n, p[: n + 2]))

Diff for: Final Capstone Project/Find_e.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
print("Please Enter the value between 0 to 15 .!!")
66
else:
77
e_val = str(e)
8-
print("e upto {} decimal place = {}".format(n, e_val[:n+2]))
8+
print("e upto {} decimal place = {}".format(n, e_val[: n + 2]))

Diff for: Final Capstone Project/Find_prime.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ def find_prime(num):
1010
primes = find_prime(n)
1111

1212
if primes == []:
13-
print(f"{n} is a prime number. The prime numbers don't have prime factors.\nThank you!!")
13+
print(
14+
f"{n} is a prime number. The prime numbers don't have prime factors.\nThank you!!"
15+
)
1416
else:
1517
print(f"Prime factors of {n} are = \n{primes} ")

Diff for: Final Capstone Project/Next_primeNumber.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def is_prime(num):
66
if num % 2 == 0:
77
return False
88

9-
for i in range(3, int(num**0.5)+1, 2):
9+
for i in range(3, int(num ** 0.5) + 1, 2):
1010
if num % i == 0:
1111
return False
1212

@@ -30,9 +30,9 @@ def prime_gen(current_prime):
3030
current_prime = 2
3131
while True:
3232

33-
answer = input('Would you like to see the next prime? (Y/N) ')
33+
answer = input("Would you like to see the next prime? (Y/N) ")
3434

35-
if answer[0].lower() == 'y':
35+
if answer[0].lower() == "y":
3636
print(current_prime)
3737
current_prime = prime_gen(current_prime)
3838

Diff for: Milestone Project 1/Advance.py

+90-45
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,103 @@
11
import os
22
import random
33

4-
theBoard = [" "]*10
5-
available =[str(num) for num in range(0,10)]
6-
players = [0,'X','O']
7-
8-
def display_board(a,b):
9-
print('Available TIC-TAC-TOE\n'+
10-
' moves\n\n '+
11-
a[7]+'|'+a[8]+'|'+a[9]+' '+b[7]+'|'+b[8]+'|'+b[9]+'\n '+
12-
'----- -----\n '+
13-
a[4]+'|'+a[5]+'|'+a[6]+' '+b[4]+'|'+b[5]+'|'+b[6]+'\n '+
14-
'----- -----\n '+
15-
a[1]+'|'+a[2]+'|'+a[3]+' '+b[1]+'|'+b[2]+'|'+b[3]+'\n')
16-
17-
'''
4+
theBoard = [" "] * 10
5+
available = [str(num) for num in range(0, 10)]
6+
players = [0, "X", "O"]
7+
8+
9+
def display_board(a, b):
10+
print(
11+
"Available TIC-TAC-TOE\n"
12+
+ " moves\n\n "
13+
+ a[7]
14+
+ "|"
15+
+ a[8]
16+
+ "|"
17+
+ a[9]
18+
+ " "
19+
+ b[7]
20+
+ "|"
21+
+ b[8]
22+
+ "|"
23+
+ b[9]
24+
+ "\n "
25+
+ "----- -----\n "
26+
+ a[4]
27+
+ "|"
28+
+ a[5]
29+
+ "|"
30+
+ a[6]
31+
+ " "
32+
+ b[4]
33+
+ "|"
34+
+ b[5]
35+
+ "|"
36+
+ b[6]
37+
+ "\n "
38+
+ "----- -----\n "
39+
+ a[1]
40+
+ "|"
41+
+ a[2]
42+
+ "|"
43+
+ a[3]
44+
+ " "
45+
+ b[1]
46+
+ "|"
47+
+ b[2]
48+
+ "|"
49+
+ b[3]
50+
+ "\n"
51+
)
52+
53+
54+
"""
1855
def display_board(a,b):
1956
print(f'Available TIC-TAC-TOE\n moves\n\n {a[7]}|{a[8]}|{a[9]} {b[7]}|{b[8]}|{b[9]}\n ----- -----\n {a[4]}|{a[5]}|{a[6]} {b[4]}|{b[5]}|{b[6]}\n ----- -----\n {a[1]}|{a[2]}|{a[3]} {b[1]}|{b[2]}|{b[3]}\n')
20-
'''
57+
"""
2158

22-
def place_marker(avail,board,marker,position):
23-
board[position] = marker
24-
avail[position] = ' '
2559

60+
def place_marker(avail, board, marker, position):
61+
board[position] = marker
62+
avail[position] = " "
2663

27-
def win_check(board,mark):
2864

29-
return ((board[7] == board[8] == board[9] == mark) or # across the top
30-
(board[4] == board[5] == board[6] == mark) or # across the middle
31-
(board[1] == board[2] == board[3] == mark) or # across the bottom
32-
(board[7] == board[4] == board[1] == mark) or # down the middle
33-
(board[8] == board[5] == board[2] == mark) or # down the middle
34-
(board[9] == board[6] == board[3] == mark) or # down the right side
35-
(board[7] == board[5] == board[3] == mark) or # diagonal
36-
(board[9] == board[5] == board[1] == mark)) # diagonal
65+
def win_check(board, mark):
3766

67+
return (
68+
(board[7] == board[8] == board[9] == mark)
69+
or (board[4] == board[5] == board[6] == mark) # across the top
70+
or (board[1] == board[2] == board[3] == mark) # across the middle
71+
or (board[7] == board[4] == board[1] == mark) # across the bottom
72+
or (board[8] == board[5] == board[2] == mark) # down the middle
73+
or (board[9] == board[6] == board[3] == mark) # down the middle
74+
or (board[7] == board[5] == board[3] == mark) # down the right side
75+
or (board[9] == board[5] == board[1] == mark) # diagonal
76+
) # diagonal
3877

3978

4079
def random_player():
4180
return random.choice((-1, 1))
4281

43-
def space_check(board,position):
44-
return board[position] == ' '
82+
83+
def space_check(board, position):
84+
return board[position] == " "
85+
4586

4687
def full_board_check(board):
47-
return ' ' not in board[1:]
88+
return " " not in board[1:]
4889

4990

50-
def player_choice(board,player):
91+
def player_choice(board, player):
5192
position = 0
5293

53-
while position not in [1,2,3,4,5,6,7,8,9] or not space_check(board, position):
94+
while position not in [1, 2, 3, 4, 5, 6, 7, 8, 9] or not space_check(
95+
board, position
96+
):
5497
try:
55-
position = int(input('Player %s, choose your next position: (1-9) '%(player)))
98+
position = int(
99+
input("Player %s, choose your next position: (1-9) " % (player))
100+
)
56101
except:
57102
print("I'm sorry, please try again.")
58103

@@ -61,7 +106,7 @@ def player_choice(board,player):
61106

62107
def replay():
63108

64-
return input('Do you want to play again? Enter Yes or No: ').lower().startswith('y')
109+
return input("Do you want to play again? Enter Yes or No: ").lower().startswith("y")
65110

66111

67112
while True:
@@ -72,30 +117,30 @@ def replay():
72117
player = players[toggle]
73118
print(f"For this round player {player} will go first")
74119

75-
game_on =True
120+
game_on = True
76121
input("Hit Enter to Continue : ")
77122
while game_on:
78-
display_board(available,theBoard)
79-
position = player_choice(theBoard,player)
80-
place_marker(available,theBoard,player,position)
123+
display_board(available, theBoard)
124+
position = player_choice(theBoard, player)
125+
place_marker(available, theBoard, player, position)
81126

82-
if win_check(theBoard,player):
83-
display_board(available,theBoard)
127+
if win_check(theBoard, player):
128+
display_board(available, theBoard)
84129
print(f"Congratulations ! player {player} wins!..")
85130
game_on = False
86131

87132
else:
88133
if full_board_check(theBoard):
89-
display_board(available,theBoard)
134+
display_board(available, theBoard)
90135
print("The game is draw ..!!")
91136
break
92137
else:
93-
toggle *=-1
138+
toggle *= -1
94139
player = players[toggle]
95140
os.system("cls")
96141

97-
theBoard = [" "]*10
98-
available = [str(num) for num in range(0,10)]
142+
theBoard = [" "] * 10
143+
available = [str(num) for num in range(0, 10)]
99144

100145
if not replay():
101-
break
146+
break

0 commit comments

Comments
 (0)