This lab assignment will require you to write some basic programs in python. Run update21, if you haven't already, to create the cs21/labs/01 directory and copy over any skeleton programs. The program handin21 will only submit files in this directory.
Then move into your cs21/labs/01 directory and create the python programs for lab 1 in this directory (handin21 looks for your lab 1 assignments in your cs21/labs/01 directory):
% cd cs21/labs/01 % pwd /home/your_user_name/cs21/labs/01
Your programs are graded on both correctness and style. Please review
the comments regarding programming style on the main page.
On the planet Jupiter, your weight would be 2.53 times what it is on Earth. Write a program to convert the user's weight to what it would be on Jupiter. Here's a sample run:
$ python weight.py This program converts your weight on Earth to what it would be on the planet Jupiter. Please enter your weight below. weight (in pounds): 160 On Jupiter, you would weigh 404.8 pounds!
$ python squares.py This program will print out squares (i*i) for i going from 1 to n. Please enter an integer for n below. n: 7 1 4 9 16 25 36 49It is okay if your program prints one square value per line (either way is fine):
$ python squares.py This program will print out squares (i*i) for i going from 1 to n. Please enter an integer for n below. n: 7 1 4 9 16 25 36 49
$ python halflife.py This program shows how the number of atoms in a radioactive sample decreases for each half-life. Please enter the starting number of atoms and the number of half-lives to show. starting number of atoms: 1000 number of half-lives to show: 4 -------------------------------- half-life 0 .... # atoms = 1000 half-life 1 .... # atoms = 500.0 half-life 2 .... # atoms = 250.0 half-life 3 .... # atoms = 125.0 half-life 4 .... # atoms = 62.5