-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcourse2-assess-4-1.py
75 lines (63 loc) · 1.06 KB
/
course2-assess-4-1.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
#Assessment: More about Iteration
#Qn1
def sublist(x):
n = 0
list = []
while(n<len(x)):
if x[n] == 5:
break
list.append(x[n])
n = n + 1
return list
#Qn2
def check_nums(x):
n = 0
list = []
while(n<len(x)):
if x[n] == 7:
break
list.append(x[n])
n = n + 1
return list
#Qn3
def sublist(x):
n = 0
list = []
while(n<len(x)):
if x[n] == "STOP":
break
list.append(x[n])
n = n + 1
return list
#Qn4
def stop_at_z(x):
n = 0
list = []
while(n<len(x)):
if x[n] == "z":
break
list.append(x[n])
n = n + 1
return list
#Qn5
sum1 = 0
lst = [65, 78, 21, 33]
for x in lst:
sum1 = sum1 + x
sum2 = 0
n = 0
while(n<len(lst)):
sum2 = sum2 + lst[n]
n = n + 1
if sum2 == sum1:
print("True")
#Qn6
def beginning(x):
n = 0
list = []
while(n<len(x)):
if x[n] == "bye":
break
list.append(x[n])
n = n + 1
return list[:10]