Juje007 » Blog


My first Python script

Uncategorized • May 24, 2011 • By Juje007 @ 4:16 pm • • 1 Comments


After a tutorial about Python on NetTuts I decided to create my first python script: a simple calculator.
And here is the result:


print "Welcome to the calculator";
nr1 = raw_input("The first number: ");
what = raw_input("What do you want to do (+, -, *, /): ");
nr2 = raw_input("The second number: ");

print "";
print "The outcome is:";

if what == "+":
	print int(nr1) + int(nr2);
elif what == "-":
	print int(nr1) - int(nr2);
elif what == "*":
	print int(nr1) * int(nr2);
elif what == "/":
	print int(nr1) / int(nr2);

Recent Posts

Archives