SingleCharacter = input("Enter a character:",)
Character = ord(SingleCharacter)
# ord --> Convert a string to ASCII value
if Character > 0 and Character <= 31:
print("ASCII value", Character," is a control character")
elif Character >= 48 and Character <= 57:
print("ASCII value", Character," is a character is a digit")
elif Character >= 65 and Character <= 90:
print("ASCII value", Character," is a uppercase letter")
elif Character >= 97 and Character <= 122:
print("ASCII value", Character," is a lowercase letter")
else:
print("ASCII value", Character," is a Symbol")
Solve Problems by Coding Solutions - A Complete solution for python programming
To find the distance between two points, given by the coordinates (x1, y1) and (x2, y2) by Pythagorean theorem using functions
def pt(x1,y1,x2,y2):
x=x2-x1
y=y2-y1
x=x**2
y=y**2
d=(x+y)**(0.5)
return d
x1=int(raw_input('Enter the coordinate x1: '))
x2=int(raw_input('Enter the coordinate x2: '))
y1=int(raw_input('Enter the coordinate y1: '))
y2=int(raw_input('Enter the coordinate y2: '))
k=pt(x1,y1,x2,y2)
print 'Distance between two points is : ', k
x=x2-x1
y=y2-y1
x=x**2
y=y**2
d=(x+y)**(0.5)
return d
x1=int(raw_input('Enter the coordinate x1: '))
x2=int(raw_input('Enter the coordinate x2: '))
y1=int(raw_input('Enter the coordinate y1: '))
y2=int(raw_input('Enter the coordinate y2: '))
k=pt(x1,y1,x2,y2)
print 'Distance between two points is : ', k
Subscribe to:
Posts (Atom)