From 79afdb789b847dce366e9c10b77857e3aadce8bd Mon Sep 17 00:00:00 2001 From: Kim Voros Date: Mon, 21 Jan 2019 14:26:51 -0800 Subject: [PATCH 1/3] First commit --- KimVoros-A02/ReadMe.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 KimVoros-A02/ReadMe.txt diff --git a/KimVoros-A02/ReadMe.txt b/KimVoros-A02/ReadMe.txt new file mode 100644 index 0000000..c595f69 --- /dev/null +++ b/KimVoros-A02/ReadMe.txt @@ -0,0 +1 @@ +This is the directory I will use to save my files for Assignment 2. \ No newline at end of file From 5ec11f0cebb8a66ed8b3b065a833992711ce69bd Mon Sep 17 00:00:00 2001 From: Kim Voros Date: Mon, 21 Jan 2019 14:39:17 -0800 Subject: [PATCH 2/3] Exercise 1 and 2 complete --- KimVoros-A02/FizzBuzz.py | 45 ++++++++++++++++++++++++++++++ KimVoros-A02/GridPrinterParts.zip | Bin 0 -> 1477 bytes 2 files changed, 45 insertions(+) create mode 100644 KimVoros-A02/FizzBuzz.py create mode 100644 KimVoros-A02/GridPrinterParts.zip diff --git a/KimVoros-A02/FizzBuzz.py b/KimVoros-A02/FizzBuzz.py new file mode 100644 index 0000000..d8c7f23 --- /dev/null +++ b/KimVoros-A02/FizzBuzz.py @@ -0,0 +1,45 @@ +#------------------------------------# +# Title: FizzBuzz +# Desc: This program writes "fiz for multiples of 3 and buzz for multiples of 5 +# Change Log: (Who, When, What) +# Kim Voros, 1/21/2019, Wrote program +# ------------------------------------# + +# Write a program that prints the numbers from 1 to 100 inclusive. +# But for multiples of three print “Fizz” instead of the number. +# For the multiples of five print “Buzz” instead of the number. +# For numbers which are multiples of both three and five print “FizzBuzz” instead. + +# -- Data --# + +#Create variable containers for 3, 5 and counter, set to 0 + +cal3 = 0 +cal5 = 0 +couter = 0 + + +# -- Processing --# + +#write function to count 0 - 100 and print results + +def cal(): + # create range statement that increases by 1 + for cal in range(101): + cal = cal +# calculate remainders + cal3 = cal % 3 + cal5 = cal % 5 +# print results + if cal3 == 0 and cal5 != 0: + print('fiz') + elif cal5 != 0 and cal5 == 0: + print('buzz') + elif cal3 == 0 and cal5 == 0: + print('fizzbuzz') + else: + print('cal = {},'.format(cal) ) + +cal() + + diff --git a/KimVoros-A02/GridPrinterParts.zip b/KimVoros-A02/GridPrinterParts.zip new file mode 100644 index 0000000000000000000000000000000000000000..1b24cd21b62fcc5003482f07f8e370aa4356951f GIT binary patch literal 1477 zcmWIWW@Zs#U|`^2_#I{Hm%iJf>MxKN$-=-O45ZzQGE)MIGV@AOivkjhN(}W1D&J1B z^*?MN&{ppKkAM9XMNVJV%*a_&y?6{#R=mhrdi_XHw)-~KY5yu})I?pG4j#DB___UE zP5*iM@|%CeCwWdxTzt4u%EoH1^Xn~~PcCSQ2W&3)-Iu*Va?9}-Iq$CsuJ>dA6!1a0 zv}(QemqPu+{LMzT4{v_s?RuM_ox^TqvpT@&!;=1rjpu%GeSNF+ZFiOE-E(YK?dflp zS8qPD+kMJQ$!Ed4FWe|R6sfnxzAWbP!uI!?3sAHqOfLTP~ENKE|%bL;A# zHSrN|06erba!viVd=l6`pAi^J*h9+*7+Pn84(8o9;MvQ5!rn%q{Z@9f$xc%TKkW<7 z3}m3@lK&sULgeim%FwDwBttP-V=)c7P@ zTjM2-=5un|{uMr`*Rj(o_MVyY^5x8rP8S2Oo)ispzaIHqIwaQMJZEGcTbqp*TX4}` zZJ!s~&u=OP<)s?6Jh~XPMd;#{r%eS1jy^qF6sUP1YJ%iMhSd*z8T#c)Pim$tKCr6WB$uLv>ux77%+`*!? zs>knqf4R2*UW&NQiQ6aTEoFD>unT_M{d#r~cl^8Q+@X8<1pS`HZn@}a&weFFcjIBk z>k^Sof6_Kv|6jA+c+;)pd*{u#qx#SH)BMmGQv|-&s=fWTG(a0R8pGA z=DA#KLjU`@NsQZ=mq=QDQR(pCbNun{$AugJH0VCt%qo}js-idlpwu1q*Fx-ff<1PG zzLz~-)!Tl}?M+iY)7KxeIgdD;{55YdOZ`5>*Phf+y1VvLXnb@L@8kCTYbWHQ;~#8H zT^{eXQ)u69Is4iV8y$XTs=j~zse4DWzs=jlTlT9iQ1j#ny=fjHH(z*3pSVw1)4z?6 z>+jU8IU}n&Y2kA9W5%rBq3X-S-{z*T$qp#pSJ&lHWVGVs!XyLN+q^4k<0Fr=H3n(> zDvGpEYZC0&n|q!^I_7T7+4QMQI;>Zfg%U*ea6BkWuVNxc;IGb&i*c4m26q}!yYjMrDBtSM$(9V75m+@yHPN6E8K);pP0M2bE2n(le} zs?6gVSC}^KTqX5*!Nuy0cXwMwzIQk$^PKs3?R1ybUb4&UG)skQR+d{_wf3o+y7en# z*t)(ck?(xUW`ynkswnL@H>*th-&wZ9oA!LDi8+vR$F)wq!; Date: Tue, 22 Jan 2019 07:48:15 -0800 Subject: [PATCH 3/3] adding all homework files --- KimVoros-A02/series_template.py | 70 +++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 KimVoros-A02/series_template.py diff --git a/KimVoros-A02/series_template.py b/KimVoros-A02/series_template.py new file mode 100644 index 0000000..2f57a84 --- /dev/null +++ b/KimVoros-A02/series_template.py @@ -0,0 +1,70 @@ +#------------------------------------# +# Title: Series +# Desc: This is the solution set for the series template +# Change Log: (Who, When, What) +# Kim Voros, 1/21/2019, Wrote program +# ------------------------------------# +""" +a template for the series assignment +""" +# Python program to display the Fibonacci sequence up to n-th term using recursive functions +def fibonacci(n): + """ compute the nth Fibonacci number """ + if n <= 1: + return n + else: + return(fibonacci(n-1) + fibonacci(n-2)) + +# Change this value for a different result +nthNumber = 10 + +# check if the number of terms is valid +if nthNumber <= 0: + print("Plese enter a positive integer") +else: + print("Fibonacci sequence:") + for i in range(nthNumber): + print(fibonacci(i)) + + +def lucas(n): + """ compute the nth Lucas number """ + pass + + +def sum_series(n, n0=0, n1=1): + """ + compute the nth value of a summation series. + + :param n0=0: value of zeroth element in the series + :param n1=1: value of first element in the series + + This function should generalize the fibonacci() and the lucas(), + so that this function works for any first two numbers for a sum series. + Once generalized that way, sum_series(n, 0, 1) should be equivalent to fibonacci(n). + And sum_series(n, 2, 1) should be equivalent to lucas(n). + """ + pass + +if __name__ == "__main__": + # run some tests + assert fibonacci(0) == 0 + assert fibonacci(1) == 1 + assert fibonacci(2) == 1 + assert fibonacci(3) == 2 + assert fibonacci(4) == 3 + assert fibonacci(5) == 5 + assert fibonacci(6) == 8 + assert fibonacci(7) == 13 + + assert lucas(0) == 2 + assert lucas(1) == 1 + + assert lucas(4) == 7 + + assert sum_series(5) == fibonacci(5) + + # test if sum_series matched lucas + assert sum_series(5, 2, 1) == lucas(5) + + print("tests passed")