forked from Akash-manna/getting-started-with-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.py
More file actions
38 lines (37 loc) · 1.14 KB
/
check.py
File metadata and controls
38 lines (37 loc) · 1.14 KB
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
#7. Write a Python Program to read a input from the user and then check whether the given character is an alphabet, number or a special character. If it is an alphabet, convert in to UPPERCASE and vice-versa.
import string
a = input("Enter the String: ")
def is_number(s):
try:
float(s)
return True
except ValueError:
pass
try:
import unicodedata
unicodedata.numeric(s)
return True
except (TypeError, ValueError):
pass
return False
x = is_number(a)
y = a.isupper()
z = ord(a)
if x:
print("The String "+a+" is a Number")
else:
if (z>=0 and z<=47):
print(a+" is a Special Character!")
elif (z>=58 and z<=64):
print(a+" is a Special Character!")
elif(z>=91 and z<=96):
print(a+" is a Special Character!")
elif(z>=123 and z<=126):
print(a+" is a Special Character!")
else:
if y:
print("The String "+a+"is in UPPERCASE")
print ("The lowercase is "+a.lower())
else:
print("The String is in lowercase")
print ("The UPPERCASE is "+a.upper())