Easy Python programs

Print the ASCII value of Characters

charr =(input("Enter a charcater"))
print("The ASCII value of '" + charr + "' is", ord(charr))

Find the roots of quadratic equation

import cmath

a = int(input("Enter the value of a "))
b = int(input("Enter the value of b "))
c = int(input("Enter the value of c "))

# calculating the discriminant
d = (b**2) - (4*a*c)

# finding solutions
sol1 = (-b-cmath.sqrt(d))/(2*a)
sol2 = (-b+cmath.sqrt(d))/(2*a)

print('The solution are {0} and {1}'.format(sol1,sol2))

Leave a comment

Create a website or blog at WordPress.com

Up ↑

Design a site like this with WordPress.com
Get started