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 diff --git a/rib_ribble/assignments/python_fun/stars.py b/rib_ribble/assignments/python_fun/stars.py new file mode 100644 index 0000000..ec68ef0 --- /dev/null +++ b/rib_ribble/assignments/python_fun/stars.py @@ -0,0 +1,20 @@ +def draw_stars(list): + for i in range(len(list)): + print "* " * list[i] + +# test_list = [4,6,1,3,5,7,25] +# draw_stars(test_list) + + +def draw_stars2(list): + for i in range(len(list)): + if type(list[i]) == int: + print "*" * list[i] + elif type(list[i]) == str: + print list[i][0].lower() * len(list[i]) + + + + +test_list = [4, "Tom", 1, "Michael", 5, 7, "Jimmy Smith"] +draw_stars2(test_list)