Answer to Question #254001 in Python for pogi

Question #254001

Using a procedural approach, write a program that prompts the user to input a number between 0 and 35. If the number is less than or equal to 9, the program should output the number; otherwise, it should output A for 10, B for 11, C for 12… and Z for 35.


1
Expert's answer
2021-10-20T14:29:58-0400
a=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','w','z']
b=[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]
def getIndex(n):
    for i in range(len(b)):
        if n==b[i]:
            return i


def getLetter(index):
    for i in range(len(a)):
        if index==i:
            return a[i]
N=int(input("Enter an integer between 0 and 35: "))
if N<=9:
    print(N)
else:
    index=getIndex(N)
    print(getLetter(index).upper())


Sample run 1



Sample run 2


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS