Python Program #30 - Make a Simple Calculator in Python

Поделиться
HTML-код
  • Опубликовано: 15 сен 2024

Комментарии • 7

  • @ARTOLOGY-1
    @ARTOLOGY-1 7 месяцев назад +6

    Thanks bro I see your video at 11 pm at night and tomorrow is my computer practical ,so thanks 😊❤❤

  • @RadRudner
    @RadRudner 4 месяца назад +2

    I made my own code before I watched your video. Mine’s a bit smaller:
    mode = input("Choose an operator (+, -, *, /, ^): ")
    first = float(input("First: "))
    second = float(input("Second: "))
    if mode == "+":
    sum = first + second
    print(sum)
    elif mode == "-":
    sum = first - second
    print(sum)
    elif mode == "*":
    sum = first * second
    print(sum)
    elif mode == "/":
    sum = first / second
    print(sum)
    elif mode == "^":
    sum = first ** second
    print(sum)
    else:
    print("Wasn't a compatible operator to begin with.")

  • @Waelalshami
    @Waelalshami 4 месяца назад +2

    print("add")
    print("subtract")
    print("multiply")
    print("divide")
    x = input("choose an operation: ")
    if x in ["add","subtract","multiply","divide"]:
    number1 = int(input("type a number :"))
    number2 = int(input("type a number :"))
    if (x == ("add")):
    print(number1+number2)
    elif (x ==("subtract")):
    print(number1-number2)
    elif (x == ("multiply")):
    print(number1 * number2)
    elif (x == ("divide")):
    print(number1 // number2)
    else:
    print("invalid entery")

  • @dennisowusu2570
    @dennisowusu2570 7 месяцев назад +1

    How do you reuse your answer on an operation to get another answer

    • @programmingforbeginners7392
      @programmingforbeginners7392  7 месяцев назад +1

      You can use loop to continuously select operator and provide numbers to get calculation