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 generator function 
Python :: python diferente de 
Python :: get all commands discord.py 
Python :: get coordinates of an image from a pdf python 
Python :: how to check python version in script 
Python :: list addition within a list comprehension 
Python :: how to open py file without console 
Python :: encapsulation in python 
Python :: python check if value in string 
Python :: import pyx file 
Python :: pandas change string column to datetime 
Python :: quick sort algorithm in python 
Python :: pickle dump example 
Python :: Python Program to Shuffle Deck of Cards 
Python :: python get element by index 
Python :: python binary tree search 
Python :: image data generator tensorflow 
Python :: matplotlib tick label position left and right x axis 
Python :: create a flask app 
Python :: golang get started 
Python :: Python DateTime Time Class Example 
Python :: relative frequency histogram python 
Python :: Uninstalling/removing a package is very easy with pip: 
Python :: python different types of loops 
Python :: Tree: Postorder Traversal 
Python :: how to step or only print every two element of list python 
Python :: exception handling in tkinter 
Python :: insert function in list 
Python :: how to add array and array in python 
Python :: upper python python.org 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =