Skip to content

Kim voros #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions KimVoros-A02/FizzBuzz.py
Original file line number Diff line number Diff line change
@@ -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()


Binary file added KimVoros-A02/GridPrinterParts.zip
Binary file not shown.
1 change: 1 addition & 0 deletions KimVoros-A02/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is the directory I will use to save my files for Assignment 2.
70 changes: 70 additions & 0 deletions KimVoros-A02/series_template.py
Original file line number Diff line number Diff line change
@@ -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")