Skip to content

Commit db18c75

Browse files
committed
adding stuff
1 parent 333b448 commit db18c75

38 files changed

Lines changed: 1125 additions & 2 deletions

Sheri/Week2/Sound_timer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
def ringgg():
99
ring.play()
1010
print("ringgg!")
11-
time.sleep(10)
11+
time.sleep(30)
1212

1313

1414
def ding():
1515
bowl.play()
1616
print("Ding!")
17-
time.sleep(10)
17+
time.sleep(30)
1818

1919
while True:
2020
ding()

Sheri/Week2/unittest_fizzbuzz.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#practicing unit testing with fizz buzz
2+
3+
assert len(gen(100))== 100
4+
5+
assert gen(5) ==[1,2,3,4,5]

Sheri/Week3/1.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get
2+
# 3, 5, 6 and 9. The sum of these multiples is 23.
3+
#
4+
# Find the sum of all the multiples of 3 or 5 below 1000.
5+
6+
def find_sum():
7+
num_list = []
8+
for i in range(1, 10001):
9+
if i % 3 == 0:
10+
num_list.append(i)
11+
if i % 5 ==0:
12+
num_list.append(i)
13+
ans = 0
14+
for i in num_list:
15+
ans = ans + i
16+
return ans
17+
print(find_sum())
18+
19+
20+
# make a list of the numbers 1 - 1000
21+
# make a new list of the numbers that are multiples of 3 or 5
22+
#get the sum of all the numbers

Sheri/Week3/2.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Each new term in the Fibonacci sequence is generated by adding the previous
2+
# two terms. By starting with 1 and 2, the first 10 terms will be:
3+
#
4+
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
5+
#
6+
# By considering the terms in the Fibonacci sequence whose values do not exceed
7+
# four million, find the sum of the even-valued terms.
8+
9+
def fibGenerator():
10+
a, b = 0, 1
11+
yield 0
12+
while True:
13+
a, b = b, a + b
14+
yield a

Sheri/Week3/3.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Make function that takes a number and returns a two-dimensional list (i.e. a list of lists) of random
2+
# numbers that are between 1 and n squared. N should determine the size of the list and the limit on random.
3+
# Example: make_2d(3) should return [[n, n2, n3], [n4, n5, n6], [n7, n8, n9]] where any n is 1 <= n <= 9 (3 squared)
4+
5+
# my attampt:
6+
# import random
7+
# def two_d(n):
8+
# random_list = []
9+
# random_num = random.randrange(1, n**2)
10+
# random_list.append(random_num)
11+
# print(random_list)
12+
#
13+
# two_d(3)
14+
15+
#how it's done:
16+
17+
import random
18+
19+
def dem_2(n):
20+
outer = []
21+
for x in range(n):
22+
inner = []
23+
for y in range(n):
24+
inner.append(random.randint(1, n**2))
25+
outer.append(inner)
26+
return outer
27+
28+
print(dem_2(3))

Sheri/Week3/4.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Write a function that takes a number and prints a series of numbers that follow this pattern:
2+
#
3+
# If the number is even divide by 2
4+
# Otherwise multiply the number by 3 and add 1
5+
# Print the new number
6+
# If the number equals 1 then terminate the function
7+
8+
9+
def takea_number(n):
10+
if n ==1:
11+
print("end of program")
12+
return
13+
if n % 2 == 0:
14+
n = n/2
15+
print(n)
16+
else:
17+
n = n/3 + 1
18+
print(n)
19+
if n == 1:
20+
print ("end of program")
21+
return
22+
23+
24+
takea_number(11)

Sheri/Week3/Exercises

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit b06579bcdf861c9eaffaac8b9a0f31f784a24fe3
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# write a function that returns the factorial of a number. It does not have
2+
# to be done recursively. Remember 5! is 5*4*3*2*1
3+
4+
def factoRama(n):
5+
if n < 1:
6+
return 1
7+
else:
8+
return n * factoRama(n -1)
9+
10+
print(factoRama(5))
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Write a program to take in a first_name and a last_name and creates a username.
2+
# Concatinate the first Initial (make sure it is upper case) and the first seven
3+
# letters in the user's last name.
4+
5+
def user_name():
6+
first_name = input("What is your first name? ")
7+
last_name = input("What is you last name? ")
8+
firstlet = first_name[0]
9+
firstseven = last_name[:8]
10+
username = firstlet.upper() + firstseven.lower()
11+
print(username)
12+
username()

Sheri/Week3/Homework/balanced.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Given a string which may include opening or closing round brackets, write a function to determine
2+
# whether the string contains a balanced pair(s) of round brackets, that is there are no brackets
3+
# which are either opened & not closed, or vice versa. Opening round brackets always have to come
4+
# before closing bracket. An empty string is balanced.
5+
#
6+
# isBalanced("hi)(") == False
7+
# isBalanced("hi(hi)") == True
8+
# isBalanced("(") == False

0 commit comments

Comments
 (0)