TA Evaluation! (at Midterm)

Please make sure your TA places their name on the board.

After the TA has left the room, please click on the link below to take an ANONYMOUS survey.

TA Midterm Survey

The TA will reenter in 5 minutes and class will resume.
Cover page images (keyboard)

Conditionals Lab

James MacGlashan & Sue Evans

Hit the space bar for next slide


Objectives for today's lab:

Step 0: Setup

The first step is to create a lab4 folder in your cs201/labs directory and make a lab4.py file to start programming.

From your home directory :

cd 201/labs
mkdir lab4
cd lab4
emacs lab4.py &

Step 1 - What's a perfect number ?

Your task for lab 4 is to write a program that determines whether a number the user enters is a perfect number or not.

A perfect number is a positive integer that is equal to the sum of its divisors (excluding itself).
For example, the divisors of 6 are 1, 2 and 3. Since 6 = 1 + 2 + 3, 6 is a perfect number. The next three perfect numbers are 28, 496 and 8128.

6 = 1+2+3
28 = 1+2+4+7+14
496 = 1+2+4+8+16+31+62+124+248

30 != 1+2+3+5+6+10+15 Not a perfect number!! (42 in total!!)

Step 2 - How do I do that ?

Bonus Step - Coodinates on a X/Y Plane

Use emacs to write bonus4.py that prompts the user to input x-y coordinates of a point in a Cartesian plane.

  1. For the Lab 4 bonus, you will prompt a user for two values (x and y) to determine where that point lies either in a quadrant, origin, or on an axis. Use the chart above.
  2. To start you will prompt the user for the following information
    • x (x coordinate)
    • y (y coordinate)
  3. Based on the input information, the program should tell the user whether the point is located in:
    • the origin
    • x axis
    • y axis
    • Quadrant 1
    • Quadrant 2
    • Quadrant 3
    • Quadrant 4