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 0000000..1b24cd2 Binary files /dev/null and b/KimVoros-A02/GridPrinterParts.zip differ 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 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")