James MacGlashan & Sue Evans
Hit the space bar for next slide
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 &
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.
for i in range(1, number): #do something with i
>>> 5 % 1 0 >>> 5 % 2 1 >>> 5 % 3 2 >>> 5 % 4 1
Use emacs to write bonus4.py that prompts the user to input x-y coordinates of a point in a Cartesian plane.