1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
natta225 [31]
3 years ago
6

Python

Computers and Technology
1 answer:
marusya05 [52]3 years ago
8 0

Answer:

from tkinter import *

expression = ""

def press(num):

global expression

expression = expression + str(num)

equation.set(expression)

def equalpress():

try:

 global expression

 total = str(eval(expression))

 equation.set(total)

 expression = ""

except:

 equation.set(" error ")

 expression = ""

def clear():

global expression

expression = ""

equation.set("")

if __name__ == "__main__":

gui = Tk()

 

equation = StringVar(gui, "")

equation.set("")

gui.geometry("270x150")

expression_field = Entry(gui, textvariable=equation)

expression_field.grid(columnspan=4, ipadx=70)

buttonl = Button(gui, text=' 1', fg='black', bg='white',command=lambda: press(1), height=1, width=7)

buttonl.grid(row=2, column=0)

button2 = Button(gui, text=' 2', fg='black', bg='white',command=lambda: press(2), height=1, width=7)

button2.grid(row=2, column=1)

button3 = Button(gui, text=' 3', fg='black', bg='white',command=lambda: press(3), height=1, width=7)

button3.grid(row=2, column=2)

button4 = Button(gui, text=' 4', fg='black', bg='white',command=lambda: press(4), height=1, width=7)

button4.grid(row=3, column=0)

button5 = Button(gui, text=' 5', fg='black', bg='white',command=lambda: press(5), height=1, width=7)

button5.grid(row=3, column=1)

button6 = Button(gui, text=' 6', fg='black', bg='white',command=lambda: press(6), height=1, width=7)

button6.grid(row=3, column=2)

button7 = Button(gui, text=' 7', fg='black', bg='white',command=lambda: press(7), height=1, width=7)

button7.grid(row=4, column=0)

button8 = Button(gui, text=' 8', fg='black', bg='white',command=lambda: press(8), height=1, width=7)

button8.grid(row=4, column=1)

button9 = Button(gui, text=' 9', fg='black', bg='white',command=lambda: press(9), height=1, width=7)

button9.grid(row=4, column=2)

button0 = Button(gui, text=' 0', fg='black', bg='white',command=lambda: press(2), height=1, width=7)

button0.grid(row=5, column=0)

Add = Button(gui, text=' +', fg='black', bg='white',command=lambda: press("+"), height=1, width=7)

Add.grid(row=2, column=3)

Sub = Button(gui, text=' -', fg='black', bg='white',command=lambda: press("-"), height=1, width=7)

Sub.grid(row=3, column=3)

Div = Button(gui, text=' /', fg='black', bg='white',command=lambda: press("/"), height=1, width=7)

Div.grid(row=5, column=3)

Mul = Button(gui, text=' *', fg='black', bg='white',command=lambda: press("*"), height=1, width=7)

Mul.grid(row=4, column=3)

Equal = Button(gui, text=' =', fg='black', bg='white',command=equalpress, height=1, width=7)

Equal.grid(row=5, column=2)

Clear = Button(gui, text=' Clear', fg='black', bg='white',command=clear, height=1, width=7)

Clear.grid(row=5, column=1)

Decimal = Button(gui, text=' .', fg='black', bg='white',command=lambda: press("."), height=1, width=7)

Decimal.grid(row=6, column=0)

gui.mainloop()

Explanation:

I fixed several other typos. Your calculator works like a charm!

You might be interested in
Write a program that reads in investment amount, annual interest rate, and number of years, and displays the future investment v
Vlada [557]

Answer:

Following are the code to this question:

import java.util.*; //importing package for user input

public class Main //defining class

{

public static void main(String []ar) //defining main method

{

double investment_amount,interest_rate,future_investment_value; //defining double variables

int years; //defining integer variable

Scanner obx=new Scanner(System.in); //creating Scanner class Object

System.out.print("Enter invest value: "); //print message

investment_amount=obx.nextDouble(); //input value

System.out.print("Enter interest rate: ");//print message

interest_rate=obx.nextDouble();//input value

System.out.print("Enter number of years: ");//print message

years=obx.nextInt();//input value

future_investment_value=investment_amount*Math.pow((1+interest_rate/1200.),years*12); //calculating value by apply formula

System.out.println("you enter amount: $"+investment_amount); //print calculated value

System.out.println("annual interest rate:"+interest_rate+"%");//print calculated value

System.out.printf("Number of years: "+years+" the future investment value is :$%.2f\n",future_investment_value);//print calculated value

}

}

output:

please find the attachment.

Explanation:

Program Description:

  • In the above-given program, inside the main method, a variable is declared that are investment_amount, interest_rate, future_investment_value, and years, in which only year variable is an integer type and other variables are double types.
  • In the next step, a scanner class object that is "obx" is created, which is used to input value from the user end, in the next line we apply the formula to calculate the future_investment_value.
  • At the last step, we all the input and a calculated value    

3 0
3 years ago
Write a basic notation for
Licemer1 [7]

Answer:

a = (b + c)/(2 * c)

z = x/(y + c)

c = (9 * c + 32)/5

Explanation:

Required

The expression in basic

To do this, we use () to group items, / as divide and * to combine factors

So, we have:

(a)\ a = \frac{(b + d)}{2c}

In basic, it is:

a = (b + c)/(2 * c)

(b)\ z = \frac{x}{y + c}

In basic, it is:

z = x/(y + c)

(c)\ c = \frac{9c + 32}{5}

c = (9 * c + 32)/5

4 0
3 years ago
Which is true about routers and switches?
Pepsi [2]

Answer:

Routers control traffic between networks while switches control traffic within a network

Explanation:

Router and switches both are used to control the traffic. In local area network, different computer are connected with each other with in the organization or network. Switch is used to connect all the computers or devices in the local area network (LAN). The switch is responsible for connecting all the computers in the LAN and controlling the traffic within the LAN network.

On the other hand, Wide Area Network (WAN) is consist of multiple number of  Local Area Networks (LANs). To connect all the LAN router is used. Router is responsible for connecting all the networks in the WAN and also responsible for controlling traffic between different networks.

5 0
3 years ago
Choose the answer that best completes the statement.
Anestetic [448]
1. A - everything starts there
2. D - always
3. C - true
4 0
3 years ago
Read 2 more answers
La computadora es un medio de comunicacion moderno?
kolbaska11 [484]
Moderno = mordern, if It does than yes!
3 0
3 years ago
Other questions:
  • The speed of a cpu is expressed in cycles called ________.
    14·1 answer
  • Prodeff, an online project management software, is available at a price of $1 per use. The software requires the user to enter t
    13·1 answer
  • A network administrator wants to increase the speed and fault tolerance of a connection between two network switches. To achieve
    9·2 answers
  • Write a program that creates a dictionary containing the U.S. states as keys and their capitals as values. (Use the Internet to
    10·1 answer
  • A STUDENT can take many COURSES and a COURSE can have more than one STUDENT enrolled in the course. In this case, both the "stud
    5·1 answer
  • Find the names of these cities with temperature and condition whose condition is neither sunny nor cloudy.
    15·1 answer
  • The keys to successful outsourcing are accountability, reporting, and ___
    7·1 answer
  • Select the correct locations on the image. Adrian wants to delve into database administration. Which certifications would help h
    5·1 answer
  • How do we store value in a variable? Give an example
    15·1 answer
  • Help<br> SOS<br> Quick <br><br><br><br><br> Hurry
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!