-
Notifications
You must be signed in to change notification settings - Fork 0
/
04092004.py
74 lines (62 loc) · 1.06 KB
/
04092004.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
### print num from 1 to 10
# for i in range(10):
# print(i+1)
# i = 1
# while i <= 10:
# print(i)
# i += 1
### sum of numbers from 1 to 10
# sum = 0
# for i in range(10):
# sum = sum + i+1
# print(sum)
# sum = 0
# i = 1
# while i <= 10:
# sum = sum + i
# i += 1
# print(sum)
### print all elements in a list
# a = ["yash", 'raj', 12]
# for i in a:
# print(i)
# i=0
# while i < len(a):
# print(a[i])
# i += 1
### find factorial
# n = 5
# f = 1
# for i in range(1, n+1):
# f = f * i
# print(f)
# i = 1
# while i <= n:
# f = f * i
# i += 1
# print(f)
### count the number of digits in an integer
# n = 10545
# n_str = str(n)
# print(len(n_str))
# for i in range(len(n_str)+1):
# if i == len(n_str):
# print(i)
# break
# i = 0
# while i < len(n_str):
# i += 1
# print(i)
### maximum value in a list
# a = [3, 5, 1, 8, 2, 7]
# max = a[0]
# for i in a:
# if i >= max:
# max = i
# print(max)
# i = 0
# while i < len(a):
# if a[i] >= max:
# max = a[i]
# i += 1
# print(max)