0% found this document useful (0 votes)
5 views2 pages

Python Practical

Uploaded by

kusumkumar7735
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Python Practical

Uploaded by

kusumkumar7735
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

COMPUTER SCIENCE PRACTICAL EXAM

Q2 Write a programme in python to find the roots of ,ax**2+bx+c=0

Ans print("for quadratic equation,ax**2+bx+c=0,enter the coefficents")

a=int(input("enter the value for a"))

b=int(input("enter the value for b"))

c=int(input("enter the value for c"))

if a==0:

print("value of ",a," should not be zero")

else:

discriminant=b*b-4*a*c

if discriminant>0:

root1=(-b+math.sqrt(discriminant))/(2*a)

root2=(-b-math.sqrt(discriminant))/(2*a)

print("roots are real and unequal")

print("root1=",root1,"root2=",root2,)

elif discriminant==0:

root1=(-b+math.sqrt(discriminant))/(2*a)

print("roots are real and equal")

print("root1=",root1,"root2=",root1,)

else:

print("roots are complex and imaginary")


Output:

for quadratic equation,ax**2+bx+c=0,enter the coefficents

enter the value for a3

enter the value for b6

enter the value for c9

roots are complex and imaginary

Q2 Write a program in python to create a list of nos. and count and delete all
the duplicate element from the first list and append in the second list.

Ans s1=input("enter a string")

s2=input("enter a string")

print(list(set(s1) ^ set(s2)))

Output: enter a string1,2,3,4

enter a string1,2,3,5

['5', '4']

You might also like