Upload code
This commit is contained in:
40
IO/Coinflip.py
Executable file
40
IO/Coinflip.py
Executable file
@@ -0,0 +1,40 @@
|
||||
import random
|
||||
|
||||
|
||||
st1 = 0
|
||||
st2 = 0
|
||||
st3 = 3
|
||||
st2a = 0
|
||||
anzahl = 0
|
||||
|
||||
go = 1
|
||||
|
||||
|
||||
while go == 1:
|
||||
zahl = random.randint(1,2)
|
||||
|
||||
if st1 == st2:
|
||||
if st2a == st3:
|
||||
go = 0
|
||||
else:
|
||||
anzahl += 1
|
||||
st3 = st2
|
||||
st2 = st1
|
||||
st2a = st1
|
||||
st1 = zahl
|
||||
if zahl == 1:
|
||||
print("K")
|
||||
else:
|
||||
print("N")
|
||||
|
||||
else:
|
||||
anzahl += 1
|
||||
st3 = st2
|
||||
st2 = st1
|
||||
st2a = st1
|
||||
st1 = zahl
|
||||
if zahl == 1:
|
||||
print("K")
|
||||
else:
|
||||
print("N")
|
||||
print("Took", anzahl, "tries")
|
||||
Reference in New Issue
Block a user