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 binary tree 
Python :: Replace the string with NAN value 
Python :: python how to check if first character in string is number 
Python :: select 2 cols from dataframe python pandas 
Python :: how to sum certain columns row wise in python 
Python :: strings are immutable in python 
Python :: axes color python 
Python :: create new dataframe from existing dataframe pandas 
Python :: python sorted dictionary multiple keys 
Python :: shebang python 
Python :: django signup view 
Python :: keys in python 
Python :: python loop list from last to first 
Python :: get the name of a file using os 
Python :: python try except raise error 
Python :: python replace char in string 
Python :: seaborn countplot 
Python :: python set cwd to script directory 
Python :: python fillna with mode 
Python :: how to resize tkinter window 
Python :: python proxy scraper 
Python :: how to append list to list in python 
Python :: django content type 
Python :: templateDoesNotExist Django 
Python :: find all files containing a string in python with glob module 
Python :: python split string every character 
Python :: python tips and tricks 
Python :: check object type python 
Python :: urllib3 python 
Python :: opencv invert image 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =