-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment4.py
More file actions
65 lines (45 loc) · 1.36 KB
/
Assignment4.py
File metadata and controls
65 lines (45 loc) · 1.36 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
#Assignment 4
#Q1
import sys
"""import random
n = int(input("Enter the value of n"))
l=[]
for i in range(0,n):
l.append(random.randint(1,n))
s= sum(l)
print(f"The sum of elements is {s}, the avg is {s/n}")
print(l)"""
#Q2
"""def rotate(a,b,c):
t=tuple()
t=t+(c,a,b)
return t
a="Doug"
b=22
c=1984
a,b,c=rotate(a,b,c)
print(f" first call a= {a} b={b} c={c}")
a,b,c=rotate(a,b,c)
print(f" second call a= {a} b={b} c={c}")
a,b,c=rotate(a,b,c)
print(f" third call a= {a} b={b} c={c}")"""
l=[]
while(True):
option = input("Enter c/C for create d/D for display i/I for insert del/Del for delete and (exit) for exit")
match(option.lower()):
case "c":
n = int(input("Enter the value of n"))
for i in range(0,n):
l.append(int(input("Enter number")))
case "d":
print(l)
case "i":
ele = int(input("Enter the element"))
ind = int(input("Enter the position"))
l.insert(ind,ele)
case "del":
#ele = int(input("Enter the element"))
ind = int(input("Enter the position"))
del l[ind]
case "exit":
sys.exit(0)