Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

quadratic formula python

from cmath import sqrt as c_sqrt
from math import sqrt as m_sqrt
import tkinter as tk

# creates and runs an instance of the window
window = tk.Tk()

#makes the size of the widow
window.geometry("600x400")

#sets a title for the screen
window.title("intercode")

# creating a new label and adding a text to the window
new_label=tk.Label(window,text='enter a,b,c quadratic formula
')
new_label.pack()

#creates a entrybox to add words to window
entry_label1=tk.Entry(window)
entry_label1.pack()

entry_label2=tk.Entry(window)
entry_label2.pack()

entry_label3=tk.Entry(window)
entry_label3.pack()
# defines results as string var
results= tk.StringVar(window)



#creating a results label
result_lable=tk.Label(window,textvariable=results)
result_lable.pack()



def callbackfunct():
    a =entry_label1.get()
    b =entry_label2.get()
    c =entry_label3.get()
    try:
        a= float(a)
        b= float(b)
        c= float(c)

    except ValueError:
        results.set("
Enter number.")


    if (b**2-4*a*c) < 0:
        minus = (-b-c_sqrt(b**2-4*a*c))/(2*a)
        plus = (-b+c_sqrt(b**2-4*a*c))/(2*a)
    else:
        minus = (-b-m_sqrt(b**2-4*a*c))/(2*a)
        plus = (-b+m_sqrt(b**2-4*a*c))/(2*a)
        
    # deletes the text in the text box
    entry_label1.delete(0,tk.END)
    entry_label2.delete(0,tk.END)
    entry_label3.delete(0,tk.END)

    var = (f"'B+'   {plus} , 'B-'   {minus}")
    results.set(var)
# creating a button with a command
buttonez = tk.Button(text="Submit", command=callbackfunct)
buttonez.pack()

window.mainloop()
Comment

Python Program to Solve Quadratic Equation

roots = ( -b + sqrt(b ^ 2 - 4 * a *c) ) / (2 * a)   , ( -b - sqrt(b ^ 2 - 4 * a *c) ) / (2 * a)
Comment

python code for quadratic equation

from math import sqrt

def quadratic(a, b, c):
    x1 = -b / (2*a)
    x2 = sqrt(b**2 - 4*a*c) / (2*a)
    return (x1 + x2), (x1 - x2)
Comment

quadratic equation python

print ("ax2 + bx + c = 0")
a = float(input("a: "))
b = float(input("b: "))
c = float(input("c: "))
delta = (b**2) - (4*a*c)
answers = []
numerator = [-b + delta**0.5, -b - delta**0.5]

denominator= 2 * a

for i in range(2):
    ans = numerator[i] / denominator
    answers.append(ans)
print (answers)
Comment

python basic programs quadratic equation

(-b ± (b ** 2 - 4 * a * c) ** 0.5) / (2 * a)
Comment

python basic programs quadratic equation

ax2 + bx + c = 0, where
a, b and c are real numbers and
a ≠ 0
Comment

quadratic equations in python

def square(n):
  num=n
  newnum=n*n
  return newnum
  
Comment

PREVIOUS NEXT
Code Example
Python :: python using type and name advanced 
Python :: python file operation 
Python :: python two list into dictinaray 
Python :: Using iterable unpacking operator * With unique values 
Python :: python Pyramid Patterns half 
Python :: if else ifadesi 
Python :: tkinter window not responding during progress bar 
Python :: list box tkinter 
Python :: networkx - unique combinations of paths 
Python :: get random bright hex color python 
Python :: arabic text recognition from pdf using python 
Python :: python define propery by null 
Python :: is dictreader scoped in python 
Python :: how to write statements in python 
Python :: why mentioning user agent in request library 
Python :: how to convert csv columns to text python 
Python :: fredo illos 
Python :: removing an item from a list and adding it to another list python 
Python :: how to element into the first index python 
Python :: Syntax Closing a File in python 
Python :: Python Modifying Global Variable From Inside the Function 
Python :: flask make_response render_template 
Python :: plotly two y axis bar chart grouped 
Python :: lol infinite print in python 
Python :: to remove whitspace in string 
Python :: cv2 jupyter notebook matplotlib inverted colors fix 
Python :: how to select the three highest entries within a category in pandas 
Python :: for t in range(t) python 
Python :: why does my function print none 
Python :: call static method from another static method python 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =