Advertisement
AntonioVillanueva

Ejercicio 8.8 Python Crash Cours

Jan 18th, 2019
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.55 KB | None | 0 0
  1. #!/usr/bin/env pytho
  2. diccionario_principal={}
  3.  
  4. def make_albun(artista,albun,tracks=0):
  5.     diccionario={'artista':artista ,'albun':albun,'tracks':tracks}
  6.     return diccionario
  7.    
  8. pos=0
  9.  
  10. while True :
  11.     nombre=input ("Nombre :")
  12.     if nombre=='q':
  13.         break
  14.     albun=input ("Albun :")
  15.     if albun=='q':
  16.         break  
  17.     tracks=input ("Track :")
  18.     if tracks=='q':
  19.         break
  20.     tracks =int (tracks)
  21.    
  22. #Crea un diccionario de diccionarios
  23.     diccionario_principal[str(pos)]=make_albun(nombre,albun,tracks)
  24.     pos+=1
  25.  
  26. print (diccionario_principal)
  27.  
  28. """Pag 146 8-7. Album: Write a function called make_album() that builds a dictionary
  29. describing a music album. The function should take in an artist name and an
  30. album title, and it should return a dictionary containing these two pieces of
  31. information. Use the function to make three dictionaries representing different
  32. albums. Print each return value to show that the dictionaries are storing the
  33. album information correctly.
  34.  
  35. Add an optional parameter to make_album() that allows you to store the
  36. number of tracks on an album. If the calling line includes a value for the num-
  37. ber of tracks, add that value to the album’s dictionary. Make at least one new
  38. function call that includes the number of tracks on an album.
  39.  
  40. 8-8. User Albums: Start with your program from Exercise 8-7. Write a while
  41. loop that allows users to enter an album’s artist and title. Once you have that
  42. information, call make_album() with the user’s input and print the dictionary
  43. that’s created. Be sure to include a quit value in the while loop."""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement