Skip to content
Related Articles

Related Articles

Improve Article
Faulty calculator using Python
  • Difficulty Level : Basic
  • Last Updated : 05 Apr, 2021

A faulty calculator is simply a calculator which operates simple tasks, but in some cases (set by the programmer) it gives the wrong output. You all must be wondering why do we need a faulty calculator? This type of calculator is not needed unless you want to prank someone or prove them wrong in case of some maths problem.


  • First, we take input from the user that what he/she wants to do
  • Then we write the code of Addition, Subtraction, Multiplication, and Division
  • And lastly, we insert those cases that we want wrong results.



print("what type of arithemetic operation you want to do?\n"
      "type + for addition\n"
      "type - for subtraction\n"
      "type / for division\n"
      "type* for multiplication\n")
# taking input
type_of_calculation = input()
print("enter the first number")
A = int(input())
print("enter the second number\n")
B = int(input())
b = "+"
c = "-"
d = "*"
e = "/"
# setting normal and false condition for calculator
if type_of_calculation == b:
    # for addition
    if (A == 53 and B == 9) or (A == 90 and B == 52):
elif type_of_calculation == c:
    # for subtraction
elif type_of_calculation == d:
    # for multiplication
    if A == 45 and B == 3 or A == 4 and B == 67:
elif type_of_calculation == e:
    # for division
    if A == 5 and B == 63:


For normal condition

For false condition

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :