Contents

  1. area.py
  2. input_demo.py

area.py 1/2

[
top][prev][next]
# This program calculates the area of a rectangle
# by CSCI111

# Get the height and width from the user
height = input("What is the height in feet? ")
width = input("What is the width in feet? ")

# Calculate the area of the rectangle
area = height * width

# output the results in a nice way
print "The area is", area, "squared feet."

input_demo.py 2/2

[
top][prev][next]
# Demonstrate numeric and string input
# by Sara Sprenkle for CS111

color = raw_input("What is your favorite color? ")
print "Cool!  My favorite color is _light_", color, "!"

rating = input("On a scale of 1 to 10, how much do you like Matt Damon? ")
print "Cool!  I like him", rating*1.8, "much!"


Generated by GNU enscript 1.6.4.