-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataPracticeTest2.py
More file actions
76 lines (62 loc) · 1.29 KB
/
DataPracticeTest2.py
File metadata and controls
76 lines (62 loc) · 1.29 KB
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
def find_the_evens(a_list):
list_of_evens = []
for i in range(len(a_list)):
if i % 2 == 0:
list_of_evens.append(a_list[i])
return list_of_evens
my_list = [1, 5, 4, 4, 2, 1, 5, 9]
find_the_evens(my_list)
def add_a_capitol(a_dict, a_state, a_city):
a_dict[a_state] = a_city
my_capitols = {"Georgia": "Atlanta", "Idaho": "Boise", "Maine": "Augusta"}
print(add_a_capitol(my_capitols, "Texas", "Austin"))
def invert_dictionary(a_dict):
new_dict = {}
for key in a_dict:
value = a_dict[key]
new_dict[value] = a_dict[key]
return new_dict
my_ords = {"A": 65, "B": 66, "C": 67, "D": 68}
my_ords = invert_dictionary(my_ords)
print(my_ords)
a = 10
b = a
a *= 2
b -= 5
print(a)
print(b)
a = ["X", "B", "R"]
b = a
a.append("Z")
b.sort()
b.append("A")
print(a[3])
print(b[4])
print()
a = {"Doe": 1, "Ray": 2, "Me": 3}
b = a
a["Fa"] = 4
b["Sew"] = 5
a["La"] = 6
b["Tea"] = 7
a["Doe"] = 8
print(a["Doe"])
print(b["Doe"])
print(a["Tea"])
print(b["La"])
print()
a = "I want"
a += " a "
b = a
b += "dog"
a += "house"
print(a)
print(b)
my_file = open("my_file.txt")
sum = 0
count = 0
for line in my_file:
sum += int(line)
count += 1
print(sum / count)
my_file.close()