diff --git a/rib_ribble/algorithms/.keep b/rib_ribble/algorithms/.keep new file mode 100644 index 0000000..e69de29 diff --git a/rib_ribble/assignments/python_fun/coin_toss.py b/rib_ribble/assignments/python_fun/coin_toss.py new file mode 100644 index 0000000..43a7077 --- /dev/null +++ b/rib_ribble/assignments/python_fun/coin_toss.py @@ -0,0 +1,18 @@ +import random + +def coin_toss(): + t_count = 0 + h_count = 0 + print "Starting the program..." + for i in range(5000): + random_num = random.randint(0, 1) + if random_num == 0: + t_count += 1 + result = "tail" + else: + h_count += 1 + result = "head" + print "Attempt #" + str(i + 1) + ": Flipping a coin... It's a " + result + "! ... Got " + str(t_count) + " tail(s) so far and " + str(h_count) + " head(s) so far" + print "Ending the program, thank you!" + +coin_toss() \ No newline at end of file