Notification texts go here Contact Us Click here

Calculator making by using Python programming

Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated

 


  1. ➤ Using if ,elif and else condition to making calculator :
  2.  
  3. num1=int(input("Enter the first number : "))
  4.  
  5. opr=input("Enter the operation to be operate..('+ - * /) : ")
  6. num2=int(input("Enter the number : "))
  7. if( opr==" + "):
  8. print(num1+num2)
  9. elif( opr==" * "):
  10. print(num1*num2)
  11. elif(opr==" - "):
  12. print(num1 - num2)
  13. elif(opr==" / "):
  14. print(num1/num2)
  15. else:
  16. print("Invalid choice")
  17.  
  18. OUTPUT :
  19. Enter the first number : 12
  20. Enter the operation to be operate..('+ - * /) : *
  21. Enter the number : 2
  22. 24
  23. Enter the first number : 8
  24. Enter the operation to be operate..('+ - * /) : -
  25. Enter the number : 4
  26. 4
  27.  
  28. Enter the first number : 12
  29. Enter the operation to be operate..('+ - * /): /
  30. Enter the number : 4
  31. 3
  32.  
  33.  
  34. ➤ Using if ,elif and else condition to making calculator :
  35. print('''
  36.  
  37. + ADD
  38. - SUBTRACT
  39. * MULTIPLY
  40. / DIVIDE
  41. ''')
  42. num1=int(input("Enter the value1:- "))
  43. num2=int(input("Enter the value2:- "))
  44. opr=input("Enter the opr..(+ , -, *, /)")
  45. if opr=="+":
  46. print(num1+num2)
  47. elif opr=="-":
  48. print(num1-num2)
  49. elif opr=="*":
  50. print(num1*num2)
  51. elif opr=="/":
  52. print(num1/num2)
  53. else:
  54. print("invalid choice")
  55.  
  56.  
  57. OUTPUT :
  58. + ADD
  59. - SUBTRACT
  60. * MULTIPLY
  61. / DIVIDE
  62.  
  63. Enter the value1:- 12
  64. Enter the value2:- 4
  65. Enter the opr..(+,-,*,/)+
  66. 16 # adding (12+4)
  67.  

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.