Advertisement
fevzi02

ПЗ - 2. Задание 10.

Oct 25th, 2021
984
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. import random
  2. class Coin:
  3.     def __init__(self):
  4.         self.tossing = int(input("= "))
  5.         self.orel = 0
  6.         self.reshka = 0
  7.     def once(self):
  8.         if random.randint(0, 1):
  9.             return "Орёл"
  10.         else:
  11.             return "Решка"      #1 орел \\\  0 решка
  12.     def multiple_times(self):
  13.         for i in range(self.tossing):
  14.             if random.randint(0, 1) == 1:   #если орел
  15.                 self.orel += 1
  16.             else:
  17.                 self.reshka += 1
  18.         return ("Орёл : " + str(self.orel/self.tossing),"Решка : " + str(self.reshka/self.tossing))
  19. c1 = Coin()
  20. print(c1.once())
  21. print(c1.multiple_times())
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement