A = 5
a = a t 1
print (a)
A = 5 a → L F
a = a t 1
print (a)
A = 5 a 55T
a = a t I↳ 1-67
print (a)
a = 5
a = A t l # c a l l e d i n c remen t
a = a - I # ca l l ed decrement
I Print a l l numbers from O t o 10 i n o rde r.
I Print a l l numbers from O t o 10 i n o rde r.
A - O
wh i l e a s - 1 0 :
print (a)a - a t l
I Print a l l numbers from O t o 10 i n o rde r.
A - O
wh i l e a s - 1 0 :
print (a)a - a - 1 1
While t h e condition a ⇐ 1 0 i s t r u e ,e x e c u t e t h e i n d e n t e d b l o c k .
I Print a l l numbers from O t o 10 i n o rde r.
A - O
wh i l e a s - 1 0 :
print (a)a - a - 1 1
While t h e condition a ⇐ 1 0 i s t r u e ,e x e c u t e t h e i n d e n t e d b l o c k .
I f t h e condit ion a s - 1 0 i s fa l s e ,e x i t t h e wh i t e loop a n d continuee x e c u t i o n f rom t h e n e x t statement
a s 0.
wh i l e a s = 1 0 :
print (a)
a s 0.
wh i l e a c e l o :
print (a)
Infinite loop. because t h e condit ion
9 < = 1 0 i s always t r u e .
Q : pa in t t h e f i r s t 1 0 fibonacci n umb e r s .
Q : pa in t t h e f i r s t 1 0 fibonacci n umb e r s .
O t o L 2 3 5 8 1 3 2 1 3 4
Xo = O
X s = I
X i = X i - i t X i - 2 f o r a l l i z 2 .
a = 0
print ( a )
b = 1
print (b)
# print 8 m o r e n umb e r s
A = 0
print ( a )
b = 1
print (b)
# print 8 m o r e n umb e r s
i = 3
Whi le
a = 0
print ( a )
b = 1
print (b)
# print 8 m o r e n umb e r s
i = 3
Whi le i < = 1 0 :
print ( a t b )
A = 0
print ( a )
b = 1
print (b)
# print 8 m o r e n umb e r s
i = 3
Whi le i < = 1 0 :
print ( a t b )temp = a
a = b
b = tempt b
A - O
print ( a )
b - 1
print (b)
# print 8 m o r e n umb e r s
e-= 3
Whi le i < = 1 0 :
print ( a t b ) # a a - b
temp-a b ← a t ba = b
b = tempt b
A - O
print ( a )
b - 1
print (b)
# print 8 m o r e n umb e r s
e-= 3
Whi le i < = 1 0 :
print ( a t b ) # a - btemp-a b ← a t ba = b
b = tempt bi = i t I
Cs: Ta k e a n u m b e r x . F o r each l e i s a , printi " t " o n l i n e i .
For example: s e e 4*
* to* to t o
t o t o t o t o
Cs: Ta k e a n u m b e r x . F o r each l e i s a , printi " t " o n l i n e i .
For example: s e e 4*
* && & &
& & & t o
N e s t e d W h i l e loop
s e = i n t (inputu)i = 1
w h i l e i i s l e s s t h a n equal t o a
print i * ' s o n l i n e e-
x = i n t (inputu)i = 1
W h i l e i ⇐ s e e .
print i * ' s o n l i n e e-
s e = i n t (inputu)i = I
w h i l e i s e e :
j = 1w h i l e j ⇐ i :
s e = i n t (inputu)i = 1
w h i l e i ⇐ a :
j = L
w h i l e j < = e i :
print ( " & " , e n d -" " )
j = j H
s e = i n t (inputu)i = 1
w h i l e e' s e - o .
j = L
w h i l e j < = e i :
print ( " & " , e n d -" " )
P.rintfj.FIe-= i t '
s e = i n t (inputu)i = 1
W h i l e e' s e - o .
j = L
w h i l e j a - e . . . }%§in¥§.
print ( " & " , e n d -" " )
Printtjjtie-= i t '
Cs: Ta k e a n u m b e r e . F o r each l e i s a , print" t a " o n l i n e i a s s h o w n b e l o w
For example: s e e 5
- - - - t o ← 1 s t a t e
- - - * * * ← 3 s t a r
- - * * * * * ← 5 s t a r
- * * * * * * t o ← 7 s t a r
* * * * t o * * * * ← g s t a r
Cs: Ta k e a n u m b e r x . F o r each l e i s a , print" t a " o n l i n e i a s s h o w n b e l o w
For example: s e e 5
- - - - t o- - - * * *
- - * * * * *
- * * * * * * t o
* * * * * * * * *
s e = i n t (inputu)i = 1
W h i l e e' s e - o .
j = L
w h i l e j < = e i :
print ( " t o " , e n d -" " )
prints'jJtli - i t '
s e = i n t (inputu)i = 1
W h i l e i ⇐ a :
j = L
p r in t - s p a c e s
pr in t - s t a r s
pr int C )i - i t l
x = i n t (inputu)i = 1
W h i l e e' s e - o .
j = L
p r in t a - i s p ace spr in t Q i - 1 s t a r s
pr int C )e- = i t
s e = i n t (inputu)i = 1
w h i l e e' s e - o .
j = Lw h i l e ja-e-ei:
print (" "sends"")
j - j e t
p r in t Q i - 1 s t a r s
pr int C )e-= ' e t l
s e = i n t (inputu)i = 1
W h i l e e' s e - o .
j = Lw h i l e j a - a - i :
paint (" "sends"")
j = 1J-j-11
w h i l e j ⇐ 2 - i - l :- print ( " e " , ends"")Printtijjtl.i - i t l
Dec ima l t o Binary.
7 6 4 = 7×102+6×10' t 4×100
Dec ima l t o Binary.
7 6 4 = 7×102+6×101 t 4×100
Any n a t u r a l n u m b e r c a n b e represented usingt h e following 1 0 digits0 I 2 3 4 5 6 7 8 9
Dec ima l t o Binary.
7 6 4 = 7×102+6×101 t 4×100
Any na t u r a l n u m b e r c a n b e represented usingt h e following 1 0 digits0 I 2 3 4 5 6 7 8 9
B a s e 1 0 o r d e c i m a l
Dec ima l t o Binary.
Any na t u r a l n u m b e r c a n b e represented usingt h e following 2 digits0 I
B a s e 2 o r Binary
Dec ima l t o Binary.9 = 1 0 0 1 = 1×23+0×22 t 0×2 ' t 1×20
Any na t u r a l n u m b e r c a n b e represented usingt h e following 2 digits0 I
B a s e 2 o r Binary
Dec ima l t o Binary.C o n v e r t a n u m b e r f rom dec ima l t o binary.
Inpu t : 8
Output a 1 0 0 0
Dec ima l t o Binary.C o n v e r t a n u m b e r f rom dec ima l t o binary.
I f n u m i s d i v i s i b l e by 10 , w h a t i s i t su n i t digit i n d e c i m a l ?
Dec ima l t o Binary.C o n v e r t a n u m b e r f rom dec ima l t o binary.
I f n u m i s d i v i s i b l e by 10 , w h a t i s i t su n i t digit i n d e c i m a l ?
A = O
Dec ima l t o Binary.C o n v e r t a n u m b e r f rom dec ima l t o binary.
I f n u m % 10 = a , w h a t i s t h e u n i t s digitsof n u m in d e c i m a l ?
Dec ima l t o Binary.C o n v e r t a n u m b e r f rom dec ima l t o binary.
I f n u m % 10 = a , w h a t i s t h e u n i t s digitsof n u m in d e c i m a l ?
A = a
Dec ima l t o Binary.C o n v e r t a n u m b e r f rom dec ima l t o binary.
7 6 5
T Tonami.1 0
Dec ima l t o Binary.C o n v e r t a n u m b e r f rom dec ima l t o binary.
7 6 5
T Tonami.1 0 .(num1/10) 1 1 0
Dec ima l t o Binary.C o n v e r t a n u m b e r f rom dec ima l t o binary.
7 6 5
T Tonami.1 0
- I| (num1110) 1 1 0
drum 110/1101%10
Dec ima l t o Binary.C o n v e r t a n u m b e r f rom dec ima l t o binary.
7 = l I I = 1×22 t 1×2' t 1×20
Dec ima l t o Binary.C o n v e r t a n u m b e r f rom dec ima l t o binary.
F = - I 1 I
Tn u m - 1 . 2
Dec ima l t o Binary.C o n v e r t a n u m b e r f rom dec ima l t o binary.
F = - I 1 I^ ^ T/ (nutmeg,.znum%2Knum12/12/12
Dec ima l t o Binary.C o n v e r t a n u m b e r f rom dec ima l t o binary.n u m a intlenputo)binary = " "
w h i l e m u m > O :
Dec ima l t o Binary.C o n v e r t a n u m b e r f rom dec ima l t o binary.n u m = intlenputo)binary = " "
w h i l e m u m > 0 :
l a s tDigit = n u m - 1 . 2
n u m = i n t (numb)
Dec ima l t o Binary.C o n v e r t a n u m b e r f rom dec ima l t o binary.n u m a intlenputo)binary = " "
w h i l e m u m > 0 :
l a s tDigit = n u m - 1 . 2
n u m = i n t (numb)
binary = binary t s t r l l a s t Digit)
Dec ima l t o Binary.C o n v e r t a n u m b e r f rom dec ima l t o binary.n u m = intlenputo)binary = " "
w h i l e m u m > 0 :
l a s tDigit = n u m - 1 . 2
n u m = i n t (numb)
binary = binary t strllastDigit)
print (binary C::-D)