## tynation.com           ## Tuesday, April 12, 2011

### if (IT104 == class)

In Intro to Programming we learned how to properly use if statements in python and how to compare various values against each other. This is fun stuff.

Also, I made the CSS to display the code as a uniform spaced text. Good times.

First code: Rewards determiner

books = 0
points = 0
print "How many books has the customer purchased this month?"
books = input()
if (books == 0):
points = 0
if (books == 1):
points = 5
if (books == 2):
points = 15
if (books == 3):
points = 30
if (books >= 4):
points = 60
if (books < 0):
print "There was an error: " print "You have", points, "award points."

Second code: Massiveness determiner

mass = 0
weight = 0
print "WHAT IS THE MASS OF YOUR OBJECT?"
mass = input()
weight = mass * 9.8
if (weight >= 1000):
print "MASS IS TOO GREAT, FAILURE IMMENENT"
if (weight <= 10):
print "MASS IS TOO SMALL, OVERCOMPENSATION ERROR"
if (weight < 1000 and weight > 10):
print "MASS WITHIN ACCEPTABLE BOUNDS; PROCEED"

Third code: Hindu-Arabic Numerals to Roman Numeral Converter

num = 0
print "Enter number between 1 and 10"
num = input()
if (num == 1):
print "I"
if (num == 2):
print "II"
if (num == 3):
print "III"
if (num == 4):
print "IV"
if (num == 5):
print "V"
if (num == 6):
print "VI"
if (num == 7):
print "VII"
if (num == 8):
print "VIII"
if (num == 9):
print "IX"
if (num == 10):
print "X"
if (num <= 0 or num > 10):
print "Invalid input"

Final Code: Rectangle Comparison

rectL1 = 0
rectW1 = 0
rectL2 = 0
rectW2 = 0
rectArea1 = 0
rectArea2 = 0

print "enter first rectangle length"
rectL1 = input()
print "enter first rectangle width"
rectW1 = input()
print "enter second rectangle length"
rectL2 = input()
print "enter second rectangle width"
rectW2 = input()
rectArea1 = rectL1 * rectW1
rectArea2 = rectL2 * rectW2
if (rectArea1 > rectArea2):
print "First rectangle is bigger"
if (rectArea1 < rectArea2):
print "Second rectangle is bigger"
if (rectArea1 == rectArea2):
print "Rectangles are of equal size"