-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
101 lines (79 loc) · 2.61 KB
/
Copy pathmain.py
File metadata and controls
101 lines (79 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
"""
Customizable Workout Playlist Generator
Generates workout playlists (simplified version without API)
"""
import random
# Sample workout songs database
WORKOUT_SONGS = {
'high_energy': [
"Eye of the Tiger - Survivor",
"Stronger - Kanye West",
"Till I Collapse - Eminem",
"Lose Yourself - Eminem",
"Can't Hold Us - Macklemore"
],
'cardio': [
"Uptown Funk - Bruno Mars",
"Shut Up and Dance - Walk the Moon",
"Don't Stop Me Now - Queen",
"Pump It - Black Eyed Peas",
"Titanium - David Guetta"
],
'strength': [
"Remember the Name - Fort Minor",
"Thunderstruck - AC/DC",
"We Will Rock You - Queen",
"Enter Sandman - Metallica",
"Gonna Fly Now - Bill Conti"
]
}
def generate_playlist(workout_type, duration=30):
"""Generate workout playlist"""
if workout_type not in WORKOUT_SONGS:
return None
songs = WORKOUT_SONGS[workout_type]
num_songs = min(duration // 3, len(songs)) # Assume 3 min per song
playlist = random.sample(songs, num_songs)
return playlist
def display_playlist(playlist, workout_type):
"""Display playlist"""
print("\n" + "="*60)
print(f" {workout_type.upper()} WORKOUT PLAYLIST")
print("="*60)
print(f"\nTotal songs: {len(playlist)}\n")
for i, song in enumerate(playlist, 1):
print(f" {i}. {song}")
print("="*60 + "\n")
def main():
"""Main function"""
print("\n" + "="*60)
print(" WORKOUT PLAYLIST GENERATOR")
print("="*60 + "\n")
try:
while True:
print("Workout types:")
print(" 1. High Energy")
print(" 2. Cardio")
print(" 3. Strength")
print(" 4. Exit")
choice = input("\nChoice: ").strip()
workout_types = {
'1': 'high_energy',
'2': 'cardio',
'3': 'strength'
}
if choice == '4':
print("\nGoodbye!")
break
if choice in workout_types:
workout_type = workout_types[choice]
duration = int(input("Workout duration (minutes): "))
playlist = generate_playlist(workout_type, duration)
if playlist:
display_playlist(playlist, workout_type)
else:
print("\nInvalid choice!")
except KeyboardInterrupt:
print("\n\nGoodbye!")
if __name__ == "__main__":
main()