-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.py
More file actions
70 lines (50 loc) · 1.3 KB
/
Copy path3.py
File metadata and controls
70 lines (50 loc) · 1.3 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
N = int(input("Enter a num: "))
a, b = 0, 1
for i in range(N):
c = a + b
a = b
b = c
N = int(input("Enter a num: "))
a, b = 0, 1
for i in range(N):
print(a)
c = a + b
a = b
b = c
num = int(input("Enter a num: "))
product = 1
while num > 0:
digit = num % 10
product *= digit
num //= 10
print(f"The product of all digits is {product}.")
num = int(input("Enter a num: "))
ls_digit = 0
while num > 0:
digit = num % 10
if digit > ls_digit:
ls_digit = digit
num //= 10
print(f"The largest digit is {ls_digit}.")
lst = ["Ram", "Shashi", "Adhi", "Shiv"]
print("original lst =", lst)
lst.append("ankit")
lst.append("sharan")
print("modified lst (append)=", lst)
lst.insert(1, "gammanna")
print("modified lst (insert)=", lst)
lst.remove("ankit")
print("modified lst (remove)=", lst)
#lst.remove("ramesh") #ValueError: list.remove(x): x not in list
#print("modified lst =", lst)
print("modified lst (remove)=", lst)
#lst.remove("ramesh")
#print("modified lst (remove)=", lst)
lst.pop()
print("modified lst (pop)=", lst)
lst.pop(1)
print("modified lst (pop)=", lst)
del lst[1]
print("modified lst (del)=", lst)
#del lst
#print("after del lst", lst) #NameError: name 'lst' is not defined.