1+ for i in range (10 ):
2+ print (i ,end = ' ' )
3+ print ()
4+ '''
5+ Output:
6+ 0 1 2 3 4 5 6 7 8 9
7+ '''
8+
9+ for i in range (10 , 0 , - 1 ):
10+ print (i , end = ' ' )
11+ print ()
12+ '''
13+ Output:
14+ 10 9 8 7 6 5 4 3 2 1
15+ '''
16+
17+ for i in reversed (range (10 )):
18+ print (i , end = ' ' )
19+ print ()
20+ '''
21+ Output:
22+ 9 8 7 6 5 4 3 2 1 0
23+ '''
24+
25+ i = 10
26+ while i != 0 :
27+ print (i , end = ' ' )
28+ i -= 1
29+ print ()
30+ '''
31+ Output:
32+ 10 9 8 7 6 5 4 3 2 1
33+ '''
34+
35+
36+ # 1 + 2 + 3 + ....... + n
37+ ### for loop
38+ n = int (input ())
39+ sm = 0
40+ for i in range (1 , n + 1 ):
41+ sm += i
42+
43+ print (sm )
44+ '''
45+ Input:
46+ 100
47+
48+ Output:
49+ 5050
50+ '''
51+
52+ ### while loop
53+ n = int (input ())
54+ i = 0
55+ sm = 0
56+ while i <= n :
57+ sm += i
58+ i += 1
59+ print (sm )
60+
61+
62+ # Counts how many 2 divides 100
63+ x = 100
64+ cnt = 0
65+ while x % 2 == 0 :
66+ x = x // 2
67+ cnt += 1
68+ print (cnt )
69+ '''
70+ Output:
71+ 2
72+ '''
73+
74+ #### Finds out the highest number which is power of 2 and less than 1000
75+ x = 1
76+ # if multiplying by 2 does not exceed 1000, multiply
77+ while x * 2 < 1000 :
78+ x *= 2
79+ print (x )
80+
81+
82+ #### prints odd numbers 1 to 10
83+ for i in range (1 , 10 + 1 ):
84+ if i % 2 == 0 : continue
85+ print (i , end = ' ' )
86+ print ()
87+
88+ ### Print only 1,2,3
89+ for i in range (1 , 11 ):
90+ if i > 3 :
91+ break
92+ print (i , end = ' ' )
93+ print ()
94+
95+
96+
97+ ##### 1 + (1+2) + (1+2+3) + .... + (1+2+3+..+n)
98+ n = int (input ())
99+ sm = 0
100+ for i in range (1 , n + 1 ):
101+ for j in range (1 , i ):
102+ sm += j
103+ print (sm )
104+
105+
106+ ### Simple function for problem solving
107+
108+ def Main (): # user define function
109+ n = int (input ())
110+ # now we will calculate the factorial of a number
111+ fact = 1
112+ for i in range (1 , n + 1 ):
113+ fact *= i
114+
115+ print (fact )
116+
117+
118+ if __name__ == '__main__' : # python3 'main' function
119+ Main () # call the user define function 'Main()'
120+
121+ ###########
122+
123+ ### EOF
124+
125+ while True :
126+ try :
127+ a = input ()
128+ print (a )
129+ except EOFError :
130+ break
131+
132+
133+
134+
135+
136+ '''
137+ ** You are now able to solve following online-judge problems.
138+ ------------------------------------------------------------
139+ (1) URI Online Judge | 1103 Alarm Clock
140+ (2) Timus | 1083. Factorials!!!
141+ (3) Timus | 1209. 1, 10, 100, 1000...
142+ (4) URI Online Judge | 1161 Factorial Sum
143+ (5) URI Online Judge | 1059 Even Numbers
144+ (6) HackerRank | Loops
145+ (7) Spoj | TEST - Life, the Universe, and Everything
146+ (8) CodeChef | Life, the Universe, and Everything
147+ (9) CodeChef | N different palindromes
148+ (10) UVa | 10055 Hashmat the Brave Warrior
149+ '''
0 commit comments