From 73ea895a8aef5564b046f85f8aafff2a1750e4f9 Mon Sep 17 00:00:00 2001 From: Rib Date: Sat, 8 Apr 2017 14:39:56 -0500 Subject: [PATCH 1/3] added algorithms folder --- rib_ribble/algorithms/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 rib_ribble/algorithms/.keep diff --git a/rib_ribble/algorithms/.keep b/rib_ribble/algorithms/.keep new file mode 100644 index 0000000..e69de29 From e55854d2e4c65c9439f4cb2c4f8ca94c4f61f9fd Mon Sep 17 00:00:00 2001 From: Rib Date: Sat, 8 Apr 2017 17:13:13 -0500 Subject: [PATCH 2/3] added coin_toss --- rib_ribble/assignments/python_fun/coin_toss.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 rib_ribble/assignments/python_fun/coin_toss.py 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 From a7717b673f7624350d3899d122f19e27c1673cdd Mon Sep 17 00:00:00 2001 From: Rib Date: Sat, 8 Apr 2017 18:53:52 -0500 Subject: [PATCH 3/3] added stars --- rib_ribble/assignments/python_fun/stars.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 rib_ribble/assignments/python_fun/stars.py 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)