Python Forum
Math problem in Python - pyqt5
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Math problem in Python - pyqt5
#1
Hi,

I have a calculator project, I am able to give 2 numbers and operator to get answer after pressing = sign. Example, 1+2=3. Now, what if the user keeps adding operators before pressing the = sign. Example, 1+2+3+4+5+6+7=answer. how to track them all? I have a function that will take the first operation 1+2 passing 2 variables and an operator. How can I deal with such problem if the list is long before pressing the = sign?

def math(val1,operator,val2):
    if operator = "+":
        return val1+val2
    elif operator = "-":
        return val1-val2
this is if the operation is taking 2 values, how to deal with this if it is more than that.
Reply


Messages In This Thread
Math problem in Python - pyqt5 - by rwahdan - Jun-18-2019, 01:53 PM
RE: Math problem in Python - pyqt5 - by ichabod801 - Jun-18-2019, 02:29 PM
RE: Math problem in Python - pyqt5 - by ThomasL - Jun-18-2019, 04:07 PM
RE: Math problem in Python - pyqt5 - by ichabod801 - Jun-18-2019, 05:02 PM
RE: Math problem in Python - pyqt5 - by noisefloor - Jun-18-2019, 05:36 PM
RE: Math problem in Python - pyqt5 - by Gribouillis - Jun-18-2019, 08:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  First Day using Python. NEED Simple Math CODE HELP! Jesseluke 4 1,376 Jan-13-2023, 01:04 PM
Last Post: jefsummers
  reverse math in python, who will find the correct answer? Kakha 11 4,436 Jan-11-2021, 11:59 AM
Last Post: Gribouillis
  PyQt5 QPushButton Problem Hellmut 2 2,328 Dec-26-2020, 08:41 PM
Last Post: Hellmut
  Math Problem cryxma 2 1,917 Dec-21-2020, 09:53 PM
Last Post: Gribouillis
  math problem using recursion? mnh001 14 4,519 Sep-03-2020, 07:34 PM
Last Post: mnh001

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020