def total_cost(): print_header("Your total cost") counter = 0 for album in catalog: temp = album.price counter += temp print("Your total album cost is: ${:.2f}".format(counter))
def register_song(): #let the user choose an album print_albums() album_id = int(input("Please choose the album Id: ")) #find the album with that ID found = False for album in catalog: if (album.id == album_id): found = True the_album = album if (not found): print("**Error: Wrong ID. Try again") return print_header("Songs") title = input("Please provide Title: ") featured_artist = input("Please provide Featured Artist: ") song_duration = input("Please provide Song Duration: ") written_by = input("Please provide Writter: ") the_song = Song(1, title, featured_artist, song_duration, written_by) the_album.add_song(the_song) print("** Song Registered") print(f"{the_song.title} | {the_song.featured_artist}")
def print_albums(): print_header("Your current albums".title()) for album in catalog: print( f"Album ID: {album.id} | Title: {album.title.title()} | Year: {album.release_year} | Genre: {album.genre} | Artist: {album.genre} | Price: ${album.price:.2f}" )
def count_all_songs(): print_header("Your total number of songs") total_count_of_songs = 0 for album in catalog: temp = len(album.songs) total_count_of_songs += temp print("Total songs in audioMgr: {}".format(total_count_of_songs))
def main(): """ Calls all interaction between user and program, handles program and user inputs. """ wrong_letters = [] life = 5 display.print_hello() word = controller.choice_word() letter_of_word = controller.convert_word_to_list_of_letters(word) display.print_word(word) hide_word = controller.hide_word_by_user(word) time.sleep(5) while life > 0: display.print_header(life, wrong_letters, hide_word) request = inputs.get_input_number( "Please enter 1 if you want to guess the word \n or enter 2 if you want to guess a letter " ) if request == 1: guess_word = inputs.get_input_string("Please enter word: ").lower() controller.check_guessed_word(word, guess_word) return guess = controller.get_letter_from_user(wrong_letters, hide_word) list_letter_index = controller.check_letter_in_word(word, guess) print(list_letter_index) if list_letter_index == []: life -= 1 wrong_letters = controller.update_list_wrong_letters( list_letter_index, wrong_letters, guess) hide_word = controller.show_guessed_letter(list_letter_index, guess, hide_word) if controller.check_win_condition(word, hide_word): return game_over_condition(life)
def register_song(): #let the user choose an album print_albums() print("\n") album_id = validate_input("int", "Please provide the album id: ") #find the album with that id # found = False # for item in catalog: # if(album_id == item.id): # found = True # the_album = item #saving the found album # if(not found): # print("Not a valid id. Try again.") # return the_album = find_album(album_id) if (the_album == False): return #create the song print_header("Register a new Song for {}".format(the_album.title.title())) # id, title, featured_artist, length, written_by title = register_album_set("Title: ") featured_artist = register_album_set("a Featured Artist: ") length_of_track = validate_input( "int", "Please enter the length of track in seconds: ") written_by = register_album_set("the song author: ".title()) song = Song(album_id, title, featured_artist, length_of_track, written_by) #push the song to the album list the_album.add_song(song) print("\n {} was registered!".title().format(song.title))
def register_album(): global album_count print_header("Register new Album") try: # title, genre, artist, release_year, price, album_art, related_artist, record_label title = input("Please provide Title: ") genre = input("Please provide Genre: ") artist = input("Please provide Artist Name: ") release_year = int(input("Please provide Release year: ")) price = float(input("Please provide price: ")) album_art = input("Please provide Album_Art URL: ") related_artist = input("Please provide Related Artist: ") record_label = input("Please provide Record Label: ") album_count += 1 album = Album(album_count, title, genre, artist, release_year, price, album_art, related_artist, record_label) # push the album into the list catalog.append(album) print("***Album Created!") except ValueError: print("***Error : invalid number, try again!!") except: print("**Unexpected Error. try Again!")
def register_songs(): print_header("Register your songs:") # let the user choose an album for the song print_albums() album_id = int(input("Please choose the album Id: ")) # find the album with that Id found = False for album in catalog: if (album.id == album_id): found = True the_album = album if (not found): print("*Error: Incorrect Id type. Please try again.") return # create the song title = input("Please enter track name:") featured_artist = input("Please enter featured artist:") length_of_track = input("Please enter length of track:") written_by = input("Please enter artist's name:") songs = Songs(1, title, featured_artist, length_of_track, written_by) # push the song to the album list the_album.add_song(songs) print("** Song registered!")
def register_song(): # let the user choose an album print_albums() album_id = int(input("Please choose the album Id: ")) # find the album with that Id found = False for album in catalog: if (album.id == album_id): found = True the_album = album if (not found): print("** Error: Wrong Id. Try again.") return # create the song print_header("Register a new Song") title = input("Please provide a Title: ") featured_artist = input("Please provide a Title Featured Artist: ") length_of_song = input("Please provide the Length in seconds: ") written_by = input("Please provide the Song Author: ") song = Song(1, title, featured_artist, length_of_song, written_by) # push the song to the album list the_album.add_song(song) print("**Song Registered")
def delete_song(): print_catalog() id = int(input("Please select an album id ")) found = False for album in catalog: if (album.id == id): found = True print_header(f"Songs inside album: {album.title}") for song in album.songs: print( f"{song.id} | {song.title} | Length: {song.length_of_track}sec | Composed by: {song.written_by}" ) song_to_delete = int(input("Select a song from list: ")) for song in album.songs: if (song.id == song_to_delete): print("Are you sure you want to delete: ") print( f"{song.id} | {song.title} | Length: {song.length_of_track}sec | Composed by: {song.written_by}" ) delete_prompt = input("Enter [yes]/[y] or [no]/[n]: ") if (delete_prompt == "yes" or delete_prompt == "y"): print(f"Song has been deleted!") album.songs.remove(song) serialize_data() return elif (delete_prompt == "no" or delete_prompt == "n"): print("Canceled delete request") time.sleep(2) delete_song() if not found: print("Error: Wrong album id, try again!") return
def count_songs(): print_header("Total songs in the system") song_count = 0 for album in catalog: song_count += len(album.songs) song_count_array = len([al.songs for al in catalog]) print(song_count) print(f"Song count total: {song_count_array}")
def count_songs(): print_header("Your total number of songs") total = 0 for album in catalog: songs_catalog = len(album.songs) total += songs_catalog print(f"There are: {total} songs in the system")
def total(): print_header("Total $ of the catalog") total = 0 for album in catalog: total += album.price print(f"The total is ${total}")
def change_album_title(): """Change the title of an album Will ask the user to pick the index of the album Then Ask for a new input for the title """ print_header("Change album title") print_albums() album_id = validate_input("int", "Please pick the album id: ") the_album = find_album(album_id) if (the_album == False): return new_album_title = input("\nEnter new title for album: ") the_album.title = new_album_title
def register_album(): print_header("Register new album") title = input("Provide the Title: ") genre = input("Provide the Genre: ") artist = input("Provide the Artist Name: ") price = float(input("Provide the Price: ")) year = int(input("Provide the Release Year: ")) songs = [] id = 1 if (len(catalog) > 0): last = catalog[-1] id = last.id + 1 album = Album(id, title, genre, artist, price, year, songs) catalog.append(album) print(album)
def most_expensive_album(): print_header("Your most expensive album") # all_price = [] album_id = catalog[0].id most_expensive = catalog[0].price album_title = catalog[0].title for album in catalog: if (most_expensive < album.price): most_expensive = album.price album_title = album.title album_id = album.id # all_price.append(album.price) # most_expensive = max (all_price) print("Your most expensive album-{}: {} at ${:.2f}".format( album_id, album_title.title(), most_expensive))
def print_all(): print_header("print albums and songs".title()) for album in catalog: print("\nAlbum-{}: {}".format(album.id, album.title.title())) # if there are no songs in the album else print songs if (len(album.songs) == 0): print("No tracks in album: {}".format(album.title.title())) else: counter = 0 for item in album.songs: counter += 1 print( "Track: {}, Title: {}, Featured Artist: {}, length: {}s, Written By: {}" .format(counter, item.title.title(), item.featured_artist.title(), item.length_of_track, item.written_by.title()))
def register_album(): print_header("Register new Album") title = input("Please provide Title: ") genre = input("Please provide Genre: ") artist = input("Please provide Artist Name: ") release_year = int(input("Please provide Release Year: ")) price = float(input("Please provide Price: $")) album_art = input("Please provide Album Art URL: ") related_artist = input("Please provide Related Artist: ") record_label = input("Please provide Record Label: ") album = Album(title, genre, artist, release_year, price, album_art, related_artist, record_label) print(album) # push the album into the list input("Press Enter to continue...")
def print_songs(): print_catalog() id = int(input("Please select an album id ")) found = False for album in catalog: if (album.id == id): found = True print_header(f"Songs inside album: {album.title}") for song in album.songs: print( f"{song.id} | {song.title} | Length: {song.length_of_track}sec | Composed by: {song.written_by}" ) if not found: print("Error: Wrong album id, try again!") return
def register_album(): global album_count print_header("Register a new Album") # title, genre, artist, release_year, price, album_art, related_artist, record_label = 8 total title = input("Please provide Title: ") genre = input("Please provide Genre: ") artist = input("Please provide Artist Name: ") release_year = input("Please provide release_year: ") price = float(input("Please provide price: ")) album_art = input("Please provide Album Art URL:") related_artist = input("Please provide Related Artist: ") record_label = input("Please provide Record Label: ") album_count += 1 the_album = Album(album_count, title, genre, artist, release_year, price, album_art, related_artist, record_label) # push the album into the list catalog.append(the_album)
def register_song(): print_catalog() id = int(input("Please select an album id ")) found = False for album in catalog: if (album.id == id): found = True print_header(f"Add song to album: {album.title}") title = input("Provide the title: ") length = int(input("Provide length in secs ")) composer = input("Provide the composer ") id = 1 if (len(album.songs) > 0): id = album.songs[-1].id + 1 song = Song(id, title, length, composer) album.songs.append(song) return if not found: print("Error: Wrong album id, try again!")
def register_album(): print_header("Register a new Album") # title, genre, artist, release_year, price, album_art, record_label title = register_album_set("Title: ") genre = register_album_set("Genre: ") artist = register_album_set("Artist Name: ") release_year = validate_input("int", "Please enter the Release Year: ") price = validate_input("float", "Please enter price: $") album_art = register_album_set("Album Art URL: ") related_artist = register_album_set("Related Artist: ") record_label = register_album_set("Record Label: ") global album_count #import this global variable into the function album_count += 1 album = Album(album_count, title, genre, artist, release_year, price, album_art, related_artist, record_label) # print(album) # PUSH THE ALBUM INTO THE LIST catalog.append(album) print("** album created!".title())
def change_song_title(): """Change the title of a song inside an album Will ask the user to pick the index of the album Then ask for a new input for the title """ print_header("Change song title") if (print_songs() == False): print("\nWas not a valid album choice. Try again.") return global albumid track_id = validate_input("int", "Please pick the song track: ") the_album = find_album(albumid) length_of_songs = len(the_album.songs) if (length_of_songs == 0): print("\nThere are no songs title here to change") return elif (length_of_songs < track_id): print("\nThat track doesn't exist") return else: new_song_title = input("\nEnter new song title: ") the_album.songs[track_id - 1].title = new_song_title
def register_album(): global album_count print_header("Register an album: ") # id, title, genre, artist, release year, price, album_art, related_artist, record_label title = input("Please provide album title: ") genre = input("Please provide album genre: ") artist = input("Please provide album artist: ") release_year = int(input("Please provide album release year: ")) price = float(input("Please provide album price: $")) album_art = input("Please provide album art URL: ") related_artist = input("Please provide related artist: ") record_label = input("Please provide record label: ") album = Album(album_count, title, genre, artist, release_year, price, album_art, related_artist, record_label) album_count += 1 # push the album into the list (.push) catalog.append(album) print("** Album created!")
def print_albums(): print_header("Albums") for album in catalog: print( f"ID: {album.id} | Title: {album.title} | {album.artist} | {album.price}" )
def print_catalog(): print_header("Your catalog") for album in catalog: print(album)
def print_albums(): print_header("Your current albums") for album in catalog: print(f"{album.id} | {album.title} | {album.release_year}")
try: user_choice = int(input("Enter your choise (0..4):")) # make sure that user's choise is one of the item in the list assert user_choice in [0, 1, 2, 3, 4] return str(user_choice) except AssertionError: print("The choice you have entered is not in the menu!") except ValueError: print("The choice you have entered is not valid!") while True: if not check_server(): print("Server is not responding - quitting!") exit(1) print_header() print_menu() choice = read_user_choice() print(choice) if choice == '0': print("Bye!") exit(0) elif choice == '1': list_cars() elif choice == '2': add_car() elif choice == '3': delete_car() elif choice == '4': update_car()
def print_albums(): print_header("Your current albums:") for album in catalog: # for loop: for <variable> in <list> print(f"{album.id} | {album.title} | {album.release_year}")