Skip to main content
Became Hot Network Question
Tweeted twitter.com/StackCodeReview/status/1467644960996483078
edited body
Source Link
Reinderien
  • 71.2k
  • 5
  • 76
  • 257

Hi I am new to python and I have written a simple calculator, I would like to ask if the code is written well or if anyone has any tips on how to write it better.


def addidtion():
    if choose == 1:
        print("Your result:", firstNum + secondNum)
def subtraction():
    if choose == 2:
        print("Your result:", firstNum - secondNum)
def multiplication():
    if choose == 3:
        print("Your result:", firstNum * secondNum)
def division():
    if choose == 4:
        print("Your result:", firstNum / secondNum)

print("Welcome to the calculator,")

firstNum = float(input("Give me first number: "))
secondNum = float(input("Give me second number: "))

choose = int(input("Choose one option:\n"
      "1.Addition\n"
      "2.Subtraction\n"
      "3.Multiplication\n"
      "4.Division\n"))

addidtion()
subtraction()
multiplication()
division()
 
```

Hi I am new to python and I have written a simple calculator, I would like to ask if the code is written well or if anyone has any tips on how to write it better.


def addidtion():
    if choose == 1:
        print("Your result:", firstNum + secondNum)
def subtraction():
    if choose == 2:
        print("Your result:", firstNum - secondNum)
def multiplication():
    if choose == 3:
        print("Your result:", firstNum * secondNum)
def division():
    if choose == 4:
        print("Your result:", firstNum / secondNum)

print("Welcome to the calculator,")

firstNum = float(input("Give me first number: "))
secondNum = float(input("Give me second number: "))

choose = int(input("Choose one option:\n"
      "1.Addition\n"
      "2.Subtraction\n"
      "3.Multiplication\n"
      "4.Division\n"))

addidtion()
subtraction()
multiplication()
division()
 
```

Hi I am new to python and I have written a simple calculator, I would like to ask if the code is written well or if anyone has any tips on how to write it better.


def addidtion():
    if choose == 1:
        print("Your result:", firstNum + secondNum)
def subtraction():
    if choose == 2:
        print("Your result:", firstNum - secondNum)
def multiplication():
    if choose == 3:
        print("Your result:", firstNum * secondNum)
def division():
    if choose == 4:
        print("Your result:", firstNum / secondNum)

print("Welcome to the calculator,")

firstNum = float(input("Give me first number: "))
secondNum = float(input("Give me second number: "))

choose = int(input("Choose one option:\n"
      "1.Addition\n"
      "2.Subtraction\n"
      "3.Multiplication\n"
      "4.Division\n"))

addidtion()
subtraction()
multiplication()
division()
Source Link

Simple Calculator Python

Hi I am new to python and I have written a simple calculator, I would like to ask if the code is written well or if anyone has any tips on how to write it better.


def addidtion():
    if choose == 1:
        print("Your result:", firstNum + secondNum)
def subtraction():
    if choose == 2:
        print("Your result:", firstNum - secondNum)
def multiplication():
    if choose == 3:
        print("Your result:", firstNum * secondNum)
def division():
    if choose == 4:
        print("Your result:", firstNum / secondNum)

print("Welcome to the calculator,")

firstNum = float(input("Give me first number: "))
secondNum = float(input("Give me second number: "))

choose = int(input("Choose one option:\n"
      "1.Addition\n"
      "2.Subtraction\n"
      "3.Multiplication\n"
      "4.Division\n"))

addidtion()
subtraction()
multiplication()
division()

```