-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
35 lines (23 loc) · 675 Bytes
/
test.py
File metadata and controls
35 lines (23 loc) · 675 Bytes
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
n = 5
i = 1
f = 1
while i <= n:
f = f*i
i += 1
print(f)
shopping_list = ['bread', 'pears', 'grapes', 'cheese']
new_list = ' '.join(x for x in shopping_list if x.startswith(('b','c')))
print(new_list)
# Consider the following dictionary:
ages = {'Tom': 32,
'James': 23,
'George': 37
}
check = ['Alex', 'Adam', 'Tom', 'James', 'George']
# Iterate through the check list and print the ages of the people in the check list.
# If the name doesn't exist in the ages dict then print 'No age record found'
for x in check:
if x in ages:
print(x,':', ages[x])
else:
print(x,':','No age record found')