This lab assignment will require you to write three 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.
One acre is equivalent to 4840 square yards. Write a program to convert a number of acres entered by the user to its equivalent number of square yards. Here are some sample runs:
$ python acres_to_yards.py This program converts a number of acres to its equivalent number of square yards Enter the number of acres: 4 The number of square yards in 4 acres is 19360 $ python acres_to_yards.py This program converts a number of acres to its equivalent number of square yards Enter the number of acres: 6.4 The number of square yards in 6.4 acres is 30976.0
Here are some example runs of a working program:
$ python cubes.py This program prints the cubes of 1 to n Enter a value for n: 10 1 8 27 64 125 216 343 512 729 1000 $ python cubes.py This program prints the cubes of 1 to n Enter a value for n: 4 1 8 27 64It is okay if your program prints one cube value per line rather than all values on the same line (either way is fine):
$ python cubes.py This program prints the cubes of 1 to n Enter a value for n: 3 1 8 27
To get the values to line up in columns you can print out one or more tab characters ("\t") between printing the dollar and euros amount on each line. For example, try these print statements in python and see what happens:
print 3, "\t\t", 4 print 3, "\t", 4Here are example runs a working program:
$ python dollars_to_euros.py This program prints a conversion table of US dollars to Euros of a range given by the usr. Enter the starting dollar amount for the range: 4 Enter the ending dollar amount: 10 Dollars Euros ---------------------------- 4 2.8032 5 3.504 6 4.2048 7 4.9056 8 5.6064 9 6.3072 10 7.008 $ python dollars_to_euros.py This program prints a conversion table of US dollars to Euros of a range given by the usr. Enter the starting dollar amount for the range: 31 Enter the ending dollar amount: 47 Dollars Euros ---------------------------- 31 21.7248 32 22.4256 33 23.1264 34 23.8272 35 24.528 36 25.2288 37 25.9296 38 26.6304 39 27.3312 40 28.032 41 28.7328 42 29.4336 43 30.1344 44 30.8352 45 31.536 46 32.2368 47 32.9376