0

wap

WAP to check if a given number is a digit or a small case alphabet or a capital case alphabet or a space or any other special symbol. ''' import math a = input() b = int(a) if(a>='A' and a<='Z'): print(a," is an uppercase letter") elif (a>='a' and a<='z'): print(a," is a lowercase letter") elif (a==" "): print(a," is a space") elif (b == -math.inf) & (b == math.inf): print(b, "is a digit") else: print("special case") how to write?

7th Nov 2021, 6:52 AM
Abdul Rahman Rayeen
Abdul Rahman Rayeen - avatar
2 Respostas
+ 5
Abdul Rahman Rayeen As per the suggestion of Per Bratthammar , see if this little code will help you. https://code.sololearn.com/cR8q6PcSDb0A/?ref=app PS: A digit in coding is a text character that looks like a number
7th Nov 2021, 8:05 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
# Hi! One way is to use: >>> print(ord('A'), ord('Z')) 65 90 # and >>> print(ord('a'), ord('z')) 97 122 # Where 65 and 90 are the ASCII-code for 'A' and 'Z', and 90 and 122 are # the ASCII-code for 'a' and 'z'. Just find the limits for the different categories. # So: >>> c = "N" >>> if 65 <= ord(c) <= 90: . . . print("Uppercase!") . . . Uppercase! # etc.
7th Nov 2021, 7:56 AM
Per Bratthammar
Per Bratthammar - avatar