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

PRO2

Uploaded by

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

PRO2

Uploaded by

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

import math

#ax^2+bx+c=0
a=int(input("Enter coefficient of x^2(x square)= "))
b=int(input("Enter coefficient of x= "))
c=int(input("Enter constant value= "))
d=math.sqrt((b*b)-(4*a*c))
if d>=0:
xp=(-(b)+(d))/(d)
xn=(-(b)-(d))/(d)
print("roots of given eqation are= ",xp,xn)

elif d<0:
print("Real roots does not exists ,system terminated")

###################################################################################
#################################################################
09/08/2022
def isEmpty(S): #This function will check Stack is empty or not
if len(S)==0:
return True
else:
return False
def Push(S,item): # This funtion will add new item in Stack, here setting top id
mendatory
S.append(item)
top=len(S)-1
def Pop(S): # This function is used to remove item from stack ,also perform checks
before deletion
if isEmpty(S):
return "Underflow"
else:
val=S.pop()
if len(S)==0:
top=None
else:
top=len(S)-1
return(val)
def peek(S): # This function will return the top most item from the stack
if isEmpty(S):
return "Underflow"
else:
top=len(S)-1
return S[top]
def Show(S):
if isEmpty(S):
print("Sorry, No items in stack")
else:
t=len(S)-1
print("(Top)",end=' ')
while(t>=0):
print(S[t],"<=",end=' ')
t-=1
print()
S=[1,2,3,4,5,6,7,8,9,0]
isEmpty(S)
Push(S,1)
Pop(S)
peek(S)
Show(S)
###################################################################################
#################################################################
def Sort_Tuple(tup):
lst=len(tup)
for i in range(0,lst):
for j in range(0,lst-i-1):
if (tup[j][1]> tup[j+1][1]):
temp=tup[j]
tup[j]=tup[j+1]
tup[j+1]=temp
return tup
tup=[('aharm',16),("sumit",80),("babli",10)]
print(Sort_Tuple(tup))

You might also like