Write A Python Program To Solve Quadratic Equation
Write A Python Program To Solve Quadratic Equation
Write A Python Program To Solve Quadratic Equation
import cmath
a=1
b=5
c=6
d = (b**2) - (4*a*c)
sol1 = (-b-cmath.sqrt(d))/(2*a)
sol2 = (-b+cmath.sqrt(d))/(2*a)
if __name__ == "__main__":
input = 'cat'
pattern = 'c'
replaceWith = 'b'
print (replacecwithb(input,pattern,replaceWith))
def getSum(n):
sum = 0
for digit in str(n):
sum += int(digit)
return sum
n = int(input("enter a nummber"))
print(getSum(n))
5. write a python program to count the number of zeros and negative terms
in a given set on n terms.
list1 = [10, 0, 4, 45, 66, -93, 1]
pos_count, zero_count = 0, 0
if num > 0:
pos_count += 1
elif num==0:
zero_count += 1
6. python program to find the average of numbers in a list.also find the cube
of the numbers in the list.
number_list = [5,6,8,9]
avg = sum(number_list)/len(number_list)
print("The average is ", round(avg,2))
res=[]
for i in number_list:
res.append(i*i*i)
print(res)
test_list = [ 1, 6, 3, 5, 3, 4 ]
for i in test_list:
if(i == 4) :
print ("Element Exists")
8. write a python program to check the type of triangle from the given
vertices.
Without function
print("Input lengths of the triangle sides: ")
x = int(input("x: "))
y = int(input("y: "))
z = int(input("z: "))
if x == y == z:
print("Equilateral triangle")
elif x==y or y==z or z==x:
print("isosceles triangle")
else:
print("Scalene triangle")
with function
def is_valid_triangle(a,b,c):
if a+b>=c and b+c>=a and c+a>=b:
return True
else:
return False
phonebook_directory = dict( )
n = input (" Enter number of friends you want to add with their phone
numbers”)
A=0
while A<=n:
phonebook_directory [y] = z
A=A+x
if (cmp(A,name) == 0):
g=x
if (g==0):