-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexam.py
More file actions
63 lines (49 loc) · 1017 Bytes
/
exam.py
File metadata and controls
63 lines (49 loc) · 1017 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
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
'''s = 'purplebanana'
i = 0
while (i < len(s)):
print(s[i])
i = i+1
#7
filename = open('test.txt')
r = filename.readline()
print(len(r))
#8
def checkfl():
s2 = 'banana'
print(s2)
for i in range(len(s2)):
if s2[0] == s2[-1]:
print('True')
return True
else:
print('false')
return False
checkfl()
#9
s3= 'parrot'
def key_lookup(s3, r):
i = 0
if 'r' in s3:
print('yes')
key = key_lookup(s3, r)
print(key)
#10
t = [1,2,3,5]
def middle(t):
return t[1:-1]
print(middle(t))
#5: Write a function that takes a letter and a string and returns True if the letter is in the given string, returns False otherwise
def charLookup(s, 'a'):
charLookup('hello', 'l')
'''
t = [1,2,3,5]
j = 0
def cumsum(t):
print(f'original list: {t}')
count = 0
for i in range(len(t)):
count += t[i]
print (f'i: {i}. t[i]: {t[i]}, count: {count}')
t[i] = count
print(f'new list: {t}')
cumsum(t)