Advertisement
Nairo05

Huasaufgabe Lotto neu

Nov 28th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.58 KB | None | 0 0
  1. #---------------------------------------------------------
  2. #
  3. #from random import randint
  4. #Lottonumbers = [0,0,0,0,0,0]
  5. #index         0 1 2 3 4 5
  6. #
  7. #6 Random Numbers
  8. #def newLottoNumbers():
  9. #    for izahl in range(0,len(Lottonumbers)-1):
  10. #        prelotto = randint(1,49)
  11. #
  12. #        #Auf doppelte überprüfen
  13. #        if (prelotto in Lottonumbers):
  14. #            print("Doppelte zahl")
  15. #            while(True):
  16. #                newzahl = randint(1,49)
  17. #                if (prelotto != newzahl):
  18. #                    Lottonumbers[izahl] = newzahl
  19. #                    break
  20. #                else:
  21. #                    print("Schon wieder selbe Zahl")
  22. #                    return
  23. #        else:
  24. #            Lottonumbers[izahl] = prelotto
  25. #
  26. #Getter and Setter
  27. #def getLotto(accessInt):
  28. #    return Lottonumbers[accessInt]
  29. #
  30. #def setLottoNumber(accessInt, number):
  31. #    Lottonumbers[accessInt]=number
  32. #
  33. #def printLotto():
  34. #    print(Lottonumbers)
  35. #
  36. #
  37. #---------------------------------------------------------
  38.  
  39. from random import randint
  40. stats = [0]
  41.  
  42. playing = True
  43. while(playing):
  44.    
  45.     #Reset
  46.     Lottonumbers = [0,0,0,0,0,0]
  47.     tipp = [0,0,0,0,0,0]
  48.     matching = 0
  49.    
  50.     #Tipp
  51.     print("\n-------------------------------------\nTippe 6 Zahlen zwischen 1 und 49")
  52.     for i in range(0, len(Lottonumbers)):
  53.         index = i+1
  54.         tipp[i] = int(input(str(index)+". Tipp "))
  55.  
  56.     #NewLottoNumbers
  57.     for i in range(0, len(Lottonumbers)-1):
  58.         prelotto = randint(1,49)
  59.         if (prelotto in Lottonumbers):
  60.             while(True):
  61.                 newzahl = randint(1,49)
  62.                 if (prelotto != newzahl):
  63.                     Lottonumbers[i] = newzahl
  64.                     break
  65.         else:
  66.             Lottonumbers[i] = prelotto
  67.  
  68.     print("\n\nDein Tipp")
  69.     print(tipp)
  70.     print("Ziehung")
  71.     print(Lottonumbers)
  72.     print("\n")
  73.  
  74.     for i in range(6):
  75.         if(tipp[i] in Lottonumbers):
  76.             matching +=1
  77.     print("Es stimmen ", matching, "überein\n\n")
  78.  
  79.     #StatsManager
  80.     stats.append(matching)
  81.     print("Deine Statistiken")
  82.     #Stats ausschreiben
  83.     for i in range(1, len(stats)):
  84.         if(stats[i]==0):
  85.             print("Beim ",i,"ten Spiel waren ", stats[i], "richtig ( 00.00 %)")
  86.         else:
  87.             print("Beim ",i,"ten Spiel waren ", stats[i], "richtig (",round((100/6)*stats[i],2),"%)")
  88.  
  89.  
  90.     #Switch for next round
  91.     print("\n\n")
  92.     print("nochmal spielen?")
  93.     again = input("(Y/N) ")
  94.     if (again == "N"):
  95.         playing = False
  96.     else:
  97.         playing = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement