question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

a basic code for calculator

See original GitHub issue

hi…i’m new to python and this is my basic code for the calculator which you can add

a=int(input("enter any number: "))
b=int(input("enter another number: "))
ope=input("enter the operand: ")
if ope=="+": 
  print(a+b) 
elif ope=="-":
  print(a-b)
elif ope=="*":
  print(a*b)
elif ope=="/":
  print(a/b)
else:
  print("invalid operand ,try again")

sounds cool?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:8
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
haymekscommented, Jan 27, 2021

Try this :

print(“”" =========================== Simple Calculator =========================== Please select an operation:

  1. Add
  2. Subtract
  3. Multiply
  4. Divide

“”") choice=input("Please enter choice(1/2/3/4)😊 num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: "))

if choice == ‘1’: print(num1,“+”,num2,“=”, num1+num2) elif choice == ‘2’: print(num1,“-”,num2,“=”, num1-num2) elif choice == ‘3’: print(num1,““,num2,”=", num1num2) elif choice == ‘4’: print(num1,”/“,num2,”=", num1/num2) else: print(“Invalid input”)

2reactions
arhattamcommented, Jan 20, 2021

Hi,

Operand? Do you mean Operator?

All good otherwise 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Program to Make a Simple Calculator - Programiz
In this example you will learn to create a simple calculator that can add, subtract, multiply or divide depending upon the input from...
Read more >
Basic calculator program using Python - GeeksforGeeks
Here we will be making a simple calculator in which we can perform basic arithmetic operations like addition, subtraction, multiplication, ...
Read more >
How to build an HTML calculator app from scratch using ...
This is an epic article where you learn how to build a calculator from scratch. We'll focus on the JavaScript you need to...
Read more >
How to Build a Simple Calculator Using HTML, CSS, and ...
Simple, calculated code is the way to go when programming. Check out how to build your own calculator in HTML, CSS, and JS....
Read more >
Python make simple Calculator - Javatpoint
Python Program to Make a Simple Calculator. In Python, we can create a simple calculator for performing the different arithmetical operations, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found