-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoopProblems.py
93 lines (76 loc) · 1.12 KB
/
LoopProblems.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
75
76
77
78
79
80
81
82
83
84
85
86
# Decimal To Binary
'''
dec = int(input('Enter a Decimal Number :'))
binary = ""
temp = dec
while dec>0:# 45
rem = dec%2
binary = str(rem)+binary
dec//=2
print("Binary of",temp,"is =",binary)
'''
# bin
#print(bin(45))
#print(bin(137))#10001001
#print(hex(140))
#print(oct(48))
# Decimal to Octal
'''
dec = int(input("Enter a number :"))
octal = ""
temp = dec
while dec>0:
rem = dec%8
octal = str(rem)+octal
dec//=8
print ("Octal value of ",temp," is :",octal)
'''
# Decimal to Hexa
'''
dec = int(input("Enter a Decimal Number :"))
temp = dec
hexa = "0123456789ABCDEF"#
ans = ""
while dec>0:
rem = dec%16
ans = hexa[rem]+ans#8C
dec//=16
print("Hexa =",ans)
'''
# Nested Loops
'''
*
* *
* * *
* * * *
'''
#
'''
for a in range(1,5):
for b in range(1,a+1):
print('*',end=' ')
print()
'''
#
'''
* * * *
* * *
* *
*
'''
#
'''
for a in range(5,1,-1):
for b in range(1,a):
print("*", end =' ')
print()
'''
#
'''
for a in range(1,5):
for b in range(4,a,-1):
print(' ',end='')
for c in range(1,a+1):
print('*',end=' ')
print()
'''