111 lab1

Computer Science 111 – Fundamentals of Programming I Programming Project 1

Due 11:59 P.M., Friday 18 September


  1. Logintoacomputer.
  2. Navigatetoyourhomedirectory.
  3. Right click in your home directory’s window and select Run in Terminal to open a terminal window.
  4. Typethecommandidle3&andpressEntertolaunchIDLE.
  5. Enter the following expressions at the shell prompt (one line at a time). Someexpressions will produce errors (printed in red).


    4/ 3
    4 // 3
    4/ 0
    4> 3
    4 == 3
    “Hello there!”
    “Hello ” +
    “there!” “Hi” + 4
    print(“Hello there!”)
    age = int(input(“Enter your age: “)) age

       name = input("Enter your name: ")

    print(name, age) print(name + age) print(name + str(age)) pi import math math.pi math.sqrt(2) math.sqrt(-1) dir(math) help(math) help(math.sqrt)

  1. From the link below this PDF document, right-click the link forcircle.py and save circle.py to your home directory.
  2. Select File/Open in IDLE and select the file circle.py in your home directory. Study the code in the script, and then run it by pressing the F5 (function-5) key. Notice the output in the shell window. Now enter the expression import circle in the shell window and notice the output. Now enter the expression help(circle) in the shell window and notice the output. You may use this file as a template for all of your Python files if you wish.
  3. Returntotheterminalwindowandenterthecommandpython3circle.pytorunthe program as a script from the terminal.

To Turn In

Create a project1 directory in your home directory. Complete the following exercises. Save the solution to each of the following exercises in a separate file in your directory. Each file should include a prefatory docstring (using the triple quotes) containing your name, project number, file name, and a statement of the purpose of the program (hint: use the circle program as a role model).

  1. Writeaprogramthatprintsbiographicalinformation.Thisinformationshould include your name, class year, and something interesting about yourself (this info will remain confidential!). Develop and test your program in an IDLE window and save the file with the name bio.py. When you think your program is running correctly, try running it as a script from a terminal prompt. (Open a new terminal window in your project1 directory and enter the command python3 bio.py).
  2. Write a Python program that prompts the user for the radius of a sphere and computes and prints the sphere’s diameter, circumference, surface area, and volume (you can look up the formulae for these quantities on Google or Wikipedia). The outputs should be suitably labeled. Be sure to use the most accurate representation of PI available. Develop and test your program in an IDLE window and save it with the file namesphere.py. When you think your program is running correctly, try running it as a script from a terminal prompt as you did in the previous exercise.

Drop your project1 directory into the course turnin directory and be sure to logout when you leave.

Some basic Linux terminal commands:

cd <dir name>

Move to the given subdirectory

cd ..

Move to the parent directory (above me)

cd /

Move to the root directory


List the contents of the current directory


List the path to the current directory