In Python
Calculator Write a program that allows the user to enter two numbers and then adds, subtracts, divides or multiplies them when the user clicks on the appropriate button. Make sure you have a Quit button. Modification and requirements”:
_____Window title should be your name Calculate self.main_window.title("?????")
_____Labels - change the attributes of the color, font, size and bold the answerExample self.label = tkinter.Label(self.main_window, \ text='?????????!', font=(" should Arial", 12, "bold"), fg="blue", bg="pink")Tip: choose a color from the website: colors: http://wiki.tcl.tk/37701
_____Modify Buttons to to have color
_____Put a style to your 4 math buttons and the Quit button: https://www.tutorialspoint.com/python/tk_relief.htm
_____Modify Entry labels to be right aligned (tip: justify=RIGHT)
_____Use the padx and pady to have widgets line up. Ex. self.num1_entry.pack(side='left',padx=5,pady=5) _____Add a quit button that has code to qui
//program to allows user to enter two numbers and then adds, subtracts, divides or multiplies them when the user clicks on the appropriate button//
//Python Code follows as for given question//
from tkinter import *
import math
class Calculator(Frame):
def __init__(self):
self.window = Tk()
self.window.title("Calculator")
# create two labels
self.l1 = Label(self.window,text="First Number")
self.l2 = Label(self.window,text="Second Number")
# to enter the text
self.e1 = Entry(self.window, justify='right')
self.e2 = Entry(self.window, justify='right')
# set the elements in a grid view
self.l1.grid(row=0,sticky=E)
self.l2.grid(row=1,sticky=E)
self.e1.grid(row=0,column=2)
self.e2.grid(row=1,column=2)
self.button_add = Button(self.window, text=" + ",font=(" should Arial", 12, "bold"), fg="blue", bg="pink", command = self.add)
self.button_sub = Button(self.window, text=" - ",font=(" should Arial", 12, "bold"), fg="blue", bg="pink", command = self.sub)
self.button_mul = Button(self.window, text=" * ",font=(" should Arial", 12, "bold"), fg="blue", bg="pink", command = self.mul)
self.button_delete = Button(self.window, text=" Quit ",font=(" should Arial", 12, "bold"), fg="blue", bg="pink", command = self.quit)
self.button_add.grid(row=5,column=1)
self.button_sub.grid(row=5,column=2)
self.button_mul.grid(row=6,column=1)
self.button_delete.grid(row=6,column=2)
self.label_result = Label(self.window,text="Result")
self.entry_result = Entry(self.window)
self.label_result.grid(row=14,sticky=E)
self.entry_result.grid(row=14,column=2)
# to run the window loop infinitely
self.window.mainloop();
def add(self):
# get the two numbers in the entry field
# convert them into float
a = float(self.e1.get())
b = float(self.e2.get())
ans = a + b
# clear the previous contents of e1 and e2
self.e1.delete(0, END)
self.e2.delete(0, END)
self.entry_result.delete(0, END)
# set the miles value in entry_result
self.entry_result.insert(0, str(ans))
def sub(self):
# get the two numbers in the entry field
# convert them into float
a = float(self.e1.get())
b = float(self.e2.get())
ans = a - b
# clear the previous contents of e1 and e2
self.e1.delete(0, END)
self.e2.delete(0, END)
self.entry_result.delete(0, END)
# set the miles value in entry_result
self.entry_result.insert(0, str(ans))
def mul(self):
# get the two numbers in the entry field
# convert them into float
a = float(self.e1.get())
b = float(self.e2.get())
ans = a * b
# clear the previous contents of e1 and e2
self.e1.delete(0, END)
self.e2.delete(0, END)
self.entry_result.delete(0, END)
# set the miles value in entry_result
self.entry_result.insert(0, str(ans))
def quit(self):
# close the app using destroy() function
self.window.destroy()
ob = Calculator()
Sample Output:
-------------------------------------------------------------------------------------------------
%%%%%%%%%%%%%%% Give Me Positive Rating Please%%%%%%%%%%%%%
In Python Calculator Write a program that allows the user to enter two numbers and then...
in Python: Write a program that allows the user to enter a number between 1-5 and returns an animal fact based on what the user entered. The program should 1. Continue to run until the user enters “quit” to terminate the program, and 2. Validate the user’s input (the only acceptable input is 1, 2, 3, 4, 5 or “quit”). You can use the following animal facts: An octopus is a highly intelligent invertebrate and a master of disguise. Elephants...
USING PYTHON *Write a program, in which the user enters two numbers, then divides the first number by the second, and prints the result to two decimal places. *Make sure that that the inputs are floats (with exception handling using the ValueError). *Make sure that there is no divide by zero error (with exception handling). *Then have a plain exception: That handles any other error. -Thank you in advance for your assistance-
PYTHON PROGRAMMING LANGUAGE (NEEDED ASAP) Using a structured approach to writing the program: This section will guide you in starting the program in a methodical way. The program will display a window with GUI widgets that are associated with particular functions: Employee Payroll O X -- - - - - - - - - - - Show Payroll Find Employee by Name Highest Lowest Find Employee by Amount Write Output to Fie Cancel - -------- ------------- Notice that some of...