Question: I am working on a project and cannot use global variables in python. Do I have global variables and if so how can I change

I am working on a project and cannot use global variables in python. Do I have global variables and if so how can I change my code so I do not have them?This is my code:

import math

#print welcome statement print("Welcome to Quadratic Solver for f(x)=ax**2+bx+c")

#skip a line print( )

#ask user to input a,b, and c values a=float(input("Enter Value for A :")) b=float(input("Enter Value for B :")) c=float(input("Enter Value for C :"))

#skip a line print ( )

#Define the function def my_quad_equation(a,b,c): if a!=1 or b!=1: return "f(x)=%.1fx**2+%.1fx+%.1f"%(a,b,c) if a==1 and b==1: return "f(x)=x**2+x+%.1f"%(c)

#return quadratic expression print("Equation is:", my_quad_equation(a,b,c))

#skip a line print ( )

#wait for user to continue temp=input(" Press Enter to Continue...") # wait

#define a function def evaluate_quad_equation(a,b,c,x): return a*(x**2)+b*(x)+c

#define x and ask user for x x= float(input("Enter Value for x: "))

#Display the function print("f(3.0)=%.1f"%evaluate_quad_equation(a,b,c,x))

#wait for user to continue temp=input(" Press Enter to Continue...") # wait

#Define new function def getminimumormaximum(): #calculate maximum or minimum values minval=-b/(2*a) maxval=b/(2*a) #display calculated value if a>0: print("f(x) has a minimum at xO= %f with the value f(xO)=" % (minval), evaluate_quad_equation(a,b,c,minval)) elif a<0: print ("f(x) has a maximum xo= %f with the value f(xo)=" % (maxval), evaluate_quad_equation(a,b,c,maxval))

getminimumormaximum()

print( )

#wait for user to continue temp=input(" press enter to continue...") # wait #find solutions #define function def compute_discriminant(): #display what we are solving for print("solving f(x) =0") d as variable of print("discriminant is %.1f" %(d)) soltions using quadratic equation if>0: x1=((-b+math.sqrt(d))/(2*a)) x2=((-b-math.sqrt(d))/(2*a)) print("Two solutions: ",(x1,x2)) elif d==0: x3=(-b)/(2*a) print("One solution: ",(x3)) else: print("No Real Solutions")

#call the functuon compute_discriminant()

#skip a line print( )

#print closing statement print("Thanks for Using Quadratic Solver!, come back soon")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!