Logical Question ( DS140523 ) - 09-06-2023

1. Write a program for below expectations for numbers from 1 - 100

Sample Input :
20
Expected Output :
Twenty

Sample Input :
78
Expected Output:
Seventy Eight

2. Write a program to form pattern of your name.

For eg. Below pattern is of name RAJ

*****
*    *
*    *
*****
*   *
*    *
*    *
*    *

   *
 *   *
*    *
******
*    *
*    *
*    *
*    *

  ****
    *
    *
    *
*   *
*   *
*   *
 ***
2 Likes

@bharatiyadav14
Very nice :+1:

1 Like
dict1 = {0:"",1:'One',2:'Two',3:'Three',4:'Four',5:'Five',6:'Six',7:'Seven',8:'Eight',9:'Nine',10:'Ten',
         11:'Eleven',12:'Tweleve',13:'Thirteen',14:'Fourteen',15:'Fifteen',16:'Sixteen',17:'Seventeen',
         18:'Eighteen',19:'Nineteen',100:'Hundred'}
dict2 = {1:"",2:'Twenty',3:'Thirty',4:'Fourty',5:'Fifty',6:'Sixty',7:'Seventy',8:'Eighty',9:'Ninety'}
num = int(input("Enter the number ranging from 1-100 : "))
if 1<=num<=19:
    print(dict1.get(num))
if 20<=num<=99:
    mod = num%10
    tens = dict1.get(mod)
    num = num // 10
    hundreds = dict2.get(num)
    print(hundreds +" "+ tens)
if num == 100:
    print(dict1.get(num))
#Y

for i in range(5):
    for j in range(5):
        if i==j:
            print('*',end = '')
        else:
            print(' ',end = '')
    for k in range(7,12):
        if i+k == 11:
            print('*',end = '')
        else:
            print(" ",end = '')
    print()
    
for i in range(5):
    print(4*' ','*')
print()

#O

print(4*' ',2*'*')
print(2*' ','*',' ',' *')
print(1*' ','*',4*' ','*')
for i in range(2):
    print(' ','*',4*' ','*')
print(1*' ','*',4*' ','*')
print(2*' ','* ',' ','*')
print(4*' ',2*'*')
print()

# G

print(4*' ',6*"*")
print(' ','*',6*' ','*')
for i in range(3):
    print('*',9*'')
print('*',2*' ',7*'*')
for i in range(3):
    print('*',2*' ','*',3*' ','*')
print(' ',3*'*',4*' ','*')
print()

# E

print(10*'*')
for i in range(3):
    print("*")
print(7*'*')
for i in range(3):
    print("*")
print(10*'*')
print()

# S

print(' ',9*'*')
for i in range(2):
    print("*")
print(' ',8*'*')
for i in range(2):
    print(9*' ','*')
print(9*'*')
print()

# H

for i in range(4):
    print('*',8*' ','*')
print(12*'*')
for i in range(4):
    print('*',8*' ','*')
print()

# B

print(10*'*')
for i in range(3):
    print('*',8*' ','*')
print(10*'*')
for i in range(3):
    print('*',8*' ','*')
print(10*'*')
print()

# H

for i in range(4):
    print('*',8*' ','*')
print(12*'*')
for i in range(4):
    print('*',8*' ','*')
print()

# A

print(4*' ',2*'*')
print(2*' ','*',' ',' *')
print(1*' ','*',4*' ','*')
for i in range(2):
    print(' ','*',4*' ','*')
print(1*' ',8*'*')
for i in range(4):
    print(' ','*',4*' ','*')
print()

# R

print(2*' ',4*'*')
print(1*' ','*',2*' ',' *')
print(1*' ','*',4*' ','*')
for i in range(2):
    print(' ','*',4*' ','*')
print(1*' ',6*'*')
print(1*' ','*',2*' ',' *')
for i in range(3):
    print(' ','*',4*' ','*')
print()

# D

print(' ',5*'*')
print(1*' ','*',2*' ',' *')
print(1*' ','*',4*' ','*')
for i in range(2):
    print(' ','*',4*' ',' *')
for i in range(4):
    print(' ','*',5*' ','*')
for i in range(2):
    print(' ','*',4*' ',' *')
print(1*' ','*',2*' ',' *')
print(' ',5*'*')
print()

# W

print(' *',19*' ','*')
print(' ','*',17*' ','*')
print(2*' ','*',15*' ','*')
print(3*' ','*',6*' ','*',4*' ','*')
print(4*' ','*',4*' ','*  *',' ','*')
print(5*' ','* ',' ','*    *',' *')
print(7*' ','*',7*' ','*')
print()

# A

print(4*' ',2*'*')
print(2*' ','*',' ',' *')
print(1*' ','*',4*' ','*')
for i in range(2):
    print(' ','*',4*' ','*')
print(1*' ',8*'*')
for i in range(4):
    print(' ','*',4*' ','*')
print()

# J


print(11*'*')
for i in range(5):
    print(5*' ','*')
print('*',3*' ','*')
print(' ','*',' ','*')
print(3*' ','*')
1 Like