-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhw6.py
96 lines (63 loc) · 2.04 KB
/
hw6.py
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
# Name: Group 16: Hien Do, Travis Goodroad, Amber Hare
# Evergreen Login: dohie11 , gootra28, hartra06
# Computer Science Foundations
# Programming as a Way of Life
# Homework 6: create function : #Group pair Group 23
#Group Member 1 Hannah Spencer
#Group Member 2 Russ Arnold
# You may do your work by editing this file, or by typing code at the
# command line and copying it into the appropriate part of this file when
# you are done. When you are done, running this file should compute and
# print the answers to all the problems.
###
### Problem 3
### Recognizing Types
Good morning!
['pink', 'yellow', 'green', 'red', 'purple', 'blue', 'orange']
{'Karen': 22, 'Bob': 20, 'Lucy': 21, 'Adam': 21}
[{'January': 1, 'December': 12}, {'January 1st': 'New Years', 'December 25th': 'Christmas'}]
# This is just create a list in dictionary
###
### Problem 4
### Identifying Values With an Index
antelope penguin bear
# for problem for the index values starts at zoo(index value).
# for zoo2 its not possible because zoo2 has only 1 item in the list therefore index is only len = 0
###
### Problem 5: An Index Within an Index
###
#code:
candy = {"sour patch kids":22, "sour gummy worms": 10, "m&ms": 13, "snickers": 1, "laffy taffy": 5}
value_list = candy.values()
for i in range(0, len(value_list)):
print value_list[i]
#answer:
10
5
13
1
22
###
### Problem 6: Using a For Loop With a Dictionary
### code fixed
drinks = {"redbull": 3, "water": 4, "fresca": 1, "pom tea": 1, "rockstar": 2}
for i in drinks:
print i
# Answers: For this problem 6, we just use the "for loop" to pull items out
water
fresca
rockstar
redbull
pom tea
###
### Problem 7: Understanding and Using Assert
###
# This problem use to verify the columns or rows match or not
# For example:
assert 1 == 0
# this does not verify that it matches. Therefore this program will stop right here.
assert x == x
#this verify that it match therefore the program will continue to excute other codes.
###
### Collaboration: Travis Goodroad, Amber Hare. ( Group 16)
###