Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fa4d087
forked repo and submitting previous work
dcastrowa Jan 20, 2019
e340325
adding readme file
dcastrowa Jan 20, 2019
3b20123
adding a new file
dcastrowa Jan 20, 2019
5c92bcc
assignment 2 submission
dcastrowa Jan 23, 2019
476a53f
Add slicing file
dcastrowa Jan 26, 2019
36522ef
Add slicing functions
dcastrowa Jan 26, 2019
d3d9c05
Add new list lab file and series 1
dcastrowa Jan 26, 2019
20f02a6
Add series 2 and some of series 3
dcastrowa Jan 27, 2019
558eef4
Add series 3 and complete file
dcastrowa Jan 29, 2019
c2bec76
Complete series 4
dcastrowa Jan 29, 2019
b145179
Complete series 4 final
dcastrowa Jan 29, 2019
42bc382
Complete string format lab
dcastrowa Jan 29, 2019
d1bf4fb
Create file and thank_yu function
dcastrowa Jan 29, 2019
74cf137
Complete mailroom assignment
dcastrowa Jan 30, 2019
6276ed9
Add dictionary 1 and dictionary 2
dcastrowa Feb 3, 2019
3a7db66
Complete dictionary lab
dcastrowa Feb 3, 2019
e8fd619
Create file lab
dcastrowa Feb 3, 2019
1561c47
Complete trigrams file
dcastrowa Feb 3, 2019
506680e
Complete mail room part 2
dcastrowa Feb 3, 2019
2d2e02f
Add files needed
dcastrowa Feb 3, 2019
0e9b17b
reorganize homework repos and complete exception ex
dcastrowa Feb 9, 2019
6c33859
Adjsut error eexception for mailroom part 3
dcastrowa Feb 10, 2019
1dc5566
Revise mail room part 3
dcastrowa Feb 10, 2019
d08b16c
Merge branch 'master' of https://github.com/rootrUW/Python210-W19
dcastrowa Feb 14, 2019
790c4f0
Adjust get_report() and create display_report()
dcastrowa Feb 16, 2019
a0da59b
Create list_of_donors()
dcastrowa Feb 16, 2019
58634b3
Create test_add_donation() to test_mailroom.py
dcastrowa Feb 16, 2019
1d44582
Complete and update mailroom part 4 and mailroom test
dcastrowa Feb 17, 2019
1d6f5e1
Update folders
dcastrowa Feb 18, 2019
7237b76
Complete step 1 of tutorial
dcastrowa Feb 23, 2019
fba6086
Start Step 3 of tutorial
dcastrowa Feb 24, 2019
a444d0d
Add one line tag subclass and title subclass
dcastrowa Feb 24, 2019
492758b
Comlete step 3 run_html and OneLineTag.append not implemented err
dcastrowa Feb 26, 2019
2c93603
Complete html render assignement
dcastrowa Feb 27, 2019
676e58a
Add runnable scripts
dcastrowa Mar 10, 2019
bae4447
Compelete final project
dcastrowa Mar 15, 2019
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
8 changes: 8 additions & 0 deletions students/DanielCastro/DanielCastro-A01/diff21.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def diff21(n):
if n > 21:
return abs(n - 21) * 2
else:
return abs(21 - n)


diff21(34)
5 changes: 5 additions & 0 deletions students/DanielCastro/DanielCastro-A01/makes10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def parrot_trouble(talking, hour):
return talking & (hour < 7 or hour > 20)


parrot_trouble(False, 3)
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
def monkey_trouble(a_smile, b_smile):
return a_smile == b_smile


monkey_trouble(True, False)
5 changes: 5 additions & 0 deletions students/DanielCastro/DanielCastro-A01/parrot_trouble.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def parrot_trouble(talking, hour):
return talking & (hour < 7 or hour > 20)


parrot_trouble(True, 4)
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ def sum_double(a, b):
return (a + b) * 2
else:
return a + b


sum_double(2, 10)
1 change: 1 addition & 0 deletions students/DanielCastro/DanielCastro-A01/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print('This is my test file')
29 changes: 29 additions & 0 deletions students/DanielCastro/DanielCastro-A02/fizz_buzz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Title: FizzBuzz
# Change Log: (Who,When,What)
# dcastrowa, 01-20190-19, created file


# ----------- Data ------------ #


numbers = list(range(1, 100))


# --------- Processing --------- #


def fizz_buzz(num):
if number % 3 == 0 and number % 5 == 0:
print('FizzBuzz')
elif number % 3 == 0:
print('Fizz')
elif number % 5 == 0:
print('Buzz')
else:
print(number)

# ----- Presentation ----- #


for number in numbers:
fizz_buzz(number)
2 changes: 2 additions & 0 deletions students/DanielCastro/DanielCastro-A02/front_times.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def front_times(str, n):
return str[:3] * n
43 changes: 43 additions & 0 deletions students/DanielCastro/DanielCastro-A02/grid_printer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Title: FizzBuzz
# Change Log: (Who,When,What)
# dcastrowa, 01-20190-19, created file


# ----------- Data ------------ #


plus = '+ '
dash = '- '
space = ' '
col = '| '

# --------- Processing --------- #


def print_grid(n):
multi_dash = dash * n
line = plus + multi_dash
full_line = line * 2 + plus
column_lines = col + space * n
full_col_line = column_lines * 2 + '|'
print(full_line)
print((full_col_line + '\n') * n, end=full_line)
print('\n' + (full_col_line + '\n') * n, end=full_line)
print()


def print_grid2(n, n2):
multi_dash = dash * n2
line = plus + multi_dash
full_line = (line * n) + '+'
column_lines = col + space * n2
full_col_line = column_lines * n + '|'
full_row = (full_col_line + '\n') * n2
all_boxes = full_line + '\n' + full_row
print(all_boxes * n, end=full_line)

# ----- Presentation ----- #



print_grid2(5, 4)
53 changes: 53 additions & 0 deletions students/DanielCastro/DanielCastro-A02/series.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Title: Series
# Change Log: (Who,When,What)
# dcastrowa, 01-2019-19, created file

# -----Data----- #


numbers = list(range(8))

# ------Processing----- #


def fibonacci(n):
if n <= 1:
return n
else:
return fibonacci(n - 1) + fibonacci(n - 2)


def lucas(n):
if n == 0:
return 2
elif n == 1:
return 1
else:
return lucas(n - 1) + lucas(n - 2)


def sum_series(n, n2=0, n3=1):
if n == 0:
return n2
elif n == 1:
return n3
else:
return sum_series(n - 1, n2, n3) + sum_series(n - 2, n2, n3)


# -----Presentation----- #


for number in numbers:
answer = fibonacci(number)
print(answer)
print()
for number in numbers:
answer = lucas(number)
print(answer)
print()
for number in numbers:
answer = sum_series(number)
print(answer)


Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
def string_times(str, n):
return str * n
return str * n

61 changes: 61 additions & 0 deletions students/DanielCastro/DanielCastro-A03/list_lab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# !/usr/bin/env python3

# ------------------------------------------------ #
# Title: List Lab
# Change Log: (Who,What,When)
# dcastrowa, created and completed file, 01/28/19
# ------------------------------------------------ #

fruits = ['Apples', 'Pears', 'Oranges', 'Peaches']

print('SERIES 1')
print('=' * 40)
print(fruits)
new_fruit = input('Add your favorite fruit: ')
fruits.append(new_fruit.capitalize())
print(fruits)
choose_fruit = int(input('Pick a number 1 through {}: '.format(len(fruits))))
print('You chose {}: {}'.format(choose_fruit, fruits[choose_fruit - 1]))
fruits = [input('Add another fruit: ')] + fruits
print(fruits)
fruits.insert(0, input('Add another fruit: '))
print(fruits)
for fruit in fruits:
if fruit[0] == 'P':
print(fruit)
print('=' * 40)

print('SERIES 2')
print('=' * 40)
print(fruits)
fruits.pop(-1)
print(fruits)
remove_fruit = input('Delete a fruit: ')
fruits.remove(remove_fruit.capitalize())
print(fruits)
print('=' * 40)

print('SERIES 3')
print('=' * 40)
for fruit in fruits:
answer = input('Do you like {}? '.format(fruit.lower()))
while answer != 'yes' or 'no':
if answer == 'yes':
pass
elif answer == 'no':
fruits.remove(fruit)
else:
answer = input('Choose "yes" or "no" ')
break
print(fruits)
print('=' * 40)

print('SERIES 4')
print('=' * 40)
new_fruits = []
for fruit in fruits:
new_fruit = fruit[::-1]
new_fruits.append(new_fruit)
print('Original list: \n{}'.format(fruits))
print('New list: \n{}'.format(new_fruits))
print('=' * 40)
90 changes: 90 additions & 0 deletions students/DanielCastro/DanielCastro-A03/mailroom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env python3

# ------------------------------------------------ #
# Title: String Format Lab
# Change Log: (Who,What,When)
# dcastrowa, created file, 01/28/19
# dcastrowa, completed file, 01/29/19
# ------------------------------------------------ #

# It should have a data structure that holds a list of your donors and a history of the amounts
# they have donated. This structure should be populated at first with at least five donors, with
# between 1 and 3 donations each. You can store that data structure in the global namespace.
# The script should prompt the user (you) to choose from a menu of 3 actions: “Send a Thank You”,
# “Create a Report” or “quit”.

import sys

# Create list of donors
donor1 = ['Bobs Burger', 400.50, 250.46]
donor2 = ['Peter Griffin', 865.23, 910.06, 454.25]
donor3 = ['Charlie Brown', 420.45, 250.67]
donor4 = ['Scooby Doo', 2000.60, 500.84]
donor5 = ['Luke Skywalker', 340.55, 67.89, 900.00]
donor_db = [donor1, donor2, donor3, donor4, donor5]
names = []
donation1 = []
donation2 = []
donation3 = []

for donor in donor_db:
try:
names.append(donor[0])
donation1.append(donor[1])
donation2.append(donor[2])
donation3.append(donor[3])
except IndexError:
pass

prompt_msg = '\n'.join(('Enter a # option:',
'1 -- Send a Thank you',
'2 -- Create a Report',
'3 -- quit',
''))
format_line = ('=' * 75)


def thank_you():
while True:
response = input('Enter "list" or donor full name: ')
if response == 'list':
print('DONORS: ')
format_line
for donors in donor_db:
print(donors[0])
elif response in names:
donation_amount = float(input('Enter donation amount: $'))
for name in donor_db:
if response == name[0]:
name.append(donation_amount)
elif response not in names:
donor_db.append([response.title()])
donation_amount = float(input('Enter donation amount: $'))
donor_db[-1].append(donation_amount)
print('Thank you, {} for donating ${:.2f}'.format(donor_db[-1][0], donor_db[-1][1]))
break


def report():
print('{:<25}{:<25}{:<25}{:<25}'.format('Donor', 'Average', 'Num of Gifts', 'Total'))
print('=' * 100)
for name in donor_db:
print('{:<25}${:<25.2f}{:<25}${:<25}'.format(name[0], sum(name[1:])/len(name[1:]), len(name[1:]), sum(name[1:])))


def main():
while True:
response = input(prompt_msg)
if response == '1':
thank_you()
elif response == '2':
report()
elif response == '3':
input('Press enter to quit.')
break
else:
print('Not an option. Choose 1-3')


if __name__ == '__main__':
main()
58 changes: 58 additions & 0 deletions students/DanielCastro/DanielCastro-A03/slicing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Title: Slicing
# Change log: (Who,When, What)
# dcastrowa, 01/26/19, created slicing file with functions

my_string = 'do stuff with this string'
my_tuple = (2, 5, 56, 23, 45, 4, 72, 34, 25, 12, 39)


def exchange_first_last(sequence): # with the first and last items exchanged.
try:
first = sequence[-1],
middle = sequence[1:-1]
last = sequence[0],
return first + middle + last
except TypeError:
first = sequence[-1]
middle = sequence[1:-1]
last = sequence[0]
return first + middle + last


def every_other_item(sequence): # with every other item removed.
return sequence[::2]


def remove_four(sequence): # first 4 and last 4 items removed and then every other item in the remaining sequence.
return sequence[4:-4:2]


def reverse_sequence(sequence): # with the elements reversed (just with slicing).
return sequence[::-1]


def thirds_sequence(sequence): # with the last third, then first third, then the middle third in the new order.
thirds = int(len(sequence) / 3)
last = sequence[-thirds:]
first = sequence[:thirds]
middle = sequence[thirds:-thirds]
return last + first + middle


print('My tuple = {}'.format(my_tuple))
print('-' * 40)
exchange_test = exchange_first_last(my_tuple)
print('Exchange first and last')
print(exchange_test)
print('-' * 40)
every_other_test = every_other_item(my_tuple)
print('Every other item')
print(every_other_test)
print('-' * 40)
remove_four_test = remove_four(my_tuple)
print('Remove four first/last and print every other')
print(remove_four_test)
print('-' * 40)
thirds_test = thirds_sequence(my_tuple)
print('Thirds')
print(thirds_test)
Loading