Introduction: Prank Python Calculator

Hello! As a novice python programmer, I love to make little programs to annoy my friends. (They love it too. They won't admit it.) I noticed online, that python is only used for useful things, like web apps. There really isn't a good prank python program tutorial out there. Luckily, I am here to change that. Today I will show you how to make a python calculator that gives bad answers!

This tutorial assumes that you have some basic python knowledge, and that you have the python idle on your computer. (I used python 2.7)

Step 1: Importing the Random Number

In order to make this work, we need to have a way to give the wrong answer. I could just tell the code to carry out the wrong operation, but that would be too easy. Let's make it use a random number.

To do that, open up the IDLE, and type at the top of the page;
import random

This will make the computer import the tools for the node 'random'

Step 2: Variables

Next we need to get the user's numbers, and operation. To do that we'll use raw input. However, raw_input makes whatever the user inputs a string. We don't want that. So make that string an integer by using int(). We'll do this twice, to find the two numbers the user has in mind. Here is the user number variables;

num1 = int(raw_input('What is the first number'))
num2 = int(raw_input('What is the first number'))

Now we need to figure out what operation the user is doing. Use raw_input to ask.

op = raw_input('Are you adding, subtracting, multiplying or dividing? (input as + , - , * , /)')

Now the fun part, the random number. To do that, we need to make a variable to generate a random number, as an integer. Here is how;

rand = int(random.randint(2 , 9))

Step 3: Wrapping It Up

Now all you need to do is make an if/elif/else statement to carry out the operation.

if op == '+':
print num1 + rand
elif op == '-':
print num1 - rand
elif op == '*':
print num1 * rand
elif op == '/':
print num1 / rand
print 'I didn\'t understand you'

Step 4: That's All

That's all that you need to do! Go mess with friends, enemies, small children, etc, etc.
Have fun