Advertisement
Wojtekd

Zadanie1

Mar 9th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.90 KB | None | 0 0
  1. # zad 10
  2.  
  3. syn_ojciec = {
  4. "Zeus":"Kronos",
  5. "Hades":"Kronos",
  6. "Posejdon":"Kronos",
  7. "Apollo":"Zeus",
  8. "Ares":"Zeus",
  9. "Agenor":"Posejdon",
  10. "Dionizos":"Zeus",
  11. "Hermes":"Zeus",
  12. "Hefajstos":"Zeus",
  13. "Eros":"Ares",
  14. "Fobos":"Ares",
  15. "Kadmos":"Agenor",
  16. "Kronos":"Uranos",
  17. "Japet":"Kronos",
  18. "Atlas":"Japet",
  19. "Prometeusz":"Japet",
  20. "Hyperion":"Uranos",
  21. "Helios":"Hyperion",
  22. "Epafos":"Zeus"}
  23.  
  24. MENU = """
  25. z - zakoncz
  26. pb - pokaż bogów
  27. po - pokaż ojca
  28. pd - pokaż dziadka
  29. us - usun pare
  30. """
  31.  
  32. while (True):
  33.     print("Wybierz opcję:")
  34.     print(MENU)
  35.     odp = input("Twój wybór: ")
  36.     if odp == "z":
  37.         print("koniec")
  38.         break
  39.     elif odp == "pb":
  40.         '''
  41.        i = 0
  42.        for x in syn_ojciec:
  43.            print(x,end=' ')
  44.            i += 1
  45.            if i % 5 == 0:
  46.                print()
  47.        '''
  48.         for indeks, klucz in enumerate(syn_ojciec):
  49.             print(klucz, end=' ')
  50.             if indeks % 5 == 4:
  51.                 print()              
  52.     elif odp == 'po':
  53.         syn = input("Podaj imie boga, ktorego imie ojca chcesz uzyskac: ").title()
  54.         if syn in syn_ojciec:
  55.             print("ojcem boga {0} jest {1}".format(syn, syn_ojciec[syn]))
  56.         else:
  57.             print("nic nie wiem o takim bogu")
  58.     elif odp == 'pd':
  59.         wnuk = input("podaj imie wnuka, ktorego imie dziadka chcesz uzyskac: ").title()
  60.         if wnuk in syn_ojciec:
  61.             ojciec = syn_ojciec[wnuk]
  62.             if ojciec in syn_ojciec:
  63.                 print("Dziadkiem boga {0}, jest {1}".format(wnuk,syn_ojciec[ojciec]))
  64.             else:
  65.                 print("brak dziadka dla {0}".format(wnuk))
  66.     elif odp == "us":
  67.         syn = input("Podaj imie boga, ktorego pare chcesz usunac: ").title()
  68.         if syn in syn_ojciec:
  69.             syn_ojciec.pop(syn)
  70.         else
  71.             print("nie ma takiego boga")
  72.     else:
  73.         print("błędny wybór")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement