Explore Python Programs # Faulty Calculator In Python With Code Want to know how to create faulty calculator program in python, then you are at the right place today in this tutorial. I will show you how to create faulty calculator in python with source code.

A faulty calculator is a calculator which does all the basic operations but in some cases specified by the programmer it will print faulty result.

## Python Code For Faulty Calculator

``````
num1 = int(input("Enter a number: "))
num2 = int(input("Enter another number: "))

operation = input("What operation do you want to do (+,-,/,*): ")

if operation == "+":
# Change if condition values according to you
if num1 == 1 and num2 == 3:
print(97)
else:
print(num1 + num2)
elif operation == "-":
# Change if condition values according to you
if num1 == 5 and num2 == 2:
print(327)
else:
print(num1 - num2)
elif operation == "*":
# Change if condition values according to you
if num1 == 2 and num2 == 9:
print(357)
else:
print(num1 * num2)
elif operation == "/":
# Change if condition values according to you
if num1 == 4 and num2 == 2:
print(99)
else:
print(num1 / num2)
```
```

Above is the python faulty calculator program. Now to run this program you need to have python installed on your computer, If you don’t have then follow this guide: Install and setup python on your computer.

To run this python program, follow the below steps:

• Create a new folder for this python project.
• Open it in a code editor of your choice.
• Create a python file with an ending .py extension.
• Copy the above code and paste it in your file.
• Open a terminal or CMD at folder location
• And type this command python filename.py (Name of your file).

After running this program you will see that it asks you to enter two numbers and the operation you want to perform then it will check if the entered numbers match the faulty conditions or not if not then it will print the real result if matches it prints the faulty result you entered below is an example output.

``````
Enter a number: 2
Enter another number: 9
What operation do you want to do (+,-,/,*): *
357
```
```

As you can see we successfully created this program in python. Don’t want to create all the files and folders then you can run this program now using this online python compiler.

## Summary

This was a simple faulty calculator in python. I hope you found this tutorial helpful and useful. Do share this tutorial with your friends who might need this program.

Here are some more python program tutorials for you:

I hope you found what you were looking for from this tutorial, and if you want more python programs and tutorials like this, do join our Telegram channel for future updates.

Thanks for reading, have a nice day 🙂