-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChallenge
109 lines (79 loc) · 2.45 KB
/
Challenge
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Problem 1:
def Durham():
print "Durham is awesome!"
Durham()
Problem 2:
bandlist = ['Kiss', 'Aerosmith', 'ACDC', 'Led Zeppelin', 'Nickelback']
def bands():
for band in bandlist:
print "I love %s" % (band)
bands()
Problem 3:
bandlist = ['Kiss', 'Aerosmith', 'ACDC', 'Led Zeppelin', 'Nickelback']
def bands():
for band in bandlist:
if band != "Nickelback":
print "I love %s" % (band)
else:
print "I DON'T love %s" % (band)
bands()
Problem 4:
array = [34, 203, 16, 46, 34, 432, 342, 124, 33, 188, 12]
def avgArray():
for number in array:
"""I'd add all the numbers and divide the sum by the number of items in the list,
but not sure how to add, divide, or count the list without googling. Tried
importing math but it had no average function and that's probably cheating anyway."""
avgArray()
Problem 5:
array = ['a', 'b', 'c', 'd', 'c', 'b', 'b', 'c', 'a', 'e', 'b', 'e']
def frequency():
for letter in array:
"""count the number of occurrences of each letter"""
"""store those values in a variable for each letter"""
"""compare the values and assign to most or leastFrequent variables"
print "The most frequent item is: " + mostFrequent
print "The least frequent item is: " + leastFrequent
frequency()
"""I think this uses way too many variables but not sure how to do it cleaner."""
Problem 6:
arrayOne = ['a', 'b', 'c', 'a', 'a', 'b', 'd']
arrayTwo = ['a', 'b', 'b', 'a', 'e', 'c', 'c', 'g']
"""Not sure without research. If I had solved problem 5, I'd probably try to use that
counting logic to create a new list of the overlaps and then print that list."""
Problem 7:
"""I worked on this for way too long because I thought was close but couldn't get it
quite right."""
cost = input("How much would you like to withdraw?")
def breakdown():
hundreds = 0
fifties = 0
twenties = 0
tens = 0
fives = 0
ones = 0
while cost >= 100:
cost - 100
hundreds += 1
elif cost >= 50:
cost - 50
fifties += 1
elif cost >= 20:
cost - 20
twenties += 1
elif cost >= 10:
cost - 10
tens += 1
elif cost >= 5:
cost - 5
fives += 1
else:
cost - 1
ones += 1
print "100s: %s" % (hundreds)
print "50s: %s" % (fifties)
print "20s: %s" % (twenties)
print "10s: %s" % (tens)
print "5s: %s" % (fives)
print "1s:%s " % (ones)
breakdown()