CPSC120A
Fundamentals of Computer Science I

Lab 1

Introduction to Linux and Python

Linux Command Line Interface

Most people interact with their computers through a graphical user interface because it is intuitive and easy to learn. Many computer scientists, however, prefer to use the command line interface because it's faster once you learn to use it. In this activity you will set up your home directory to keep your files organized and learn how to use the command line interface.

Details

From the terminal, setup your home directory so that it looks like the following:

Note that username is your home directory, the directory that is the same name as you used to log in. The directories Desktop, Documents, Downloads, Music, Pictures, Public, Templates, and Videos already exist and you do not need to modify them. The directories cs120, labs, assignments, and lab1 do not exist, so you need to create them.

Example

$ pwd
/home/students/patsy
$ ls
Desktop    Downloads  Music     Public     Videos
Documents  cs120      Pictures  Templates
$ cd cs120
$ ls
labs  assignments
$ cd labs
$ ls
lab1

Hint

  1. Make sure that you are in your home directory by running the pwd command. If you are not in your home directory, run the cd command (with no arguments) to change to your home directory.
  2. Once in your home directory, create the directory cs120 by running the command mkdir. Note, this command takes an argument for the name of the directory to create. Verify that the directory was created by running the ls command.
  3. Change into the cs120 directory by using the cd command. Note, this command takes an argument for the name of the directory to change into. Verify that the present working directory is the the cs120 directory by running the pwd command.
  4. Create the directory labs with the mkdir command. Verify that the directory was created by running the ls command.
  5. Without changing directories, create the directory labs with the mkdir command. Verify that the directory was created by running the ls command.
  6. Change into the labs directory by using the cd command. Verify that the present working directory is labs by running the pwd command.
  7. Create the directory lab1 with the mkdir command. Verify that the directory was created by running the ls command.
Classmates

It's that time of the class where we ask you to get to know your fellow classmates. Of course, the sole purpose of this activity is not just getting to know one another. It's also a fantastic example of how to use the print statement.

Details

In Emacs, create a python program in a file called classmates.py. The program should print a table like the one shown below. However, instead of Sally, Alexander, Graham, and Terry, you should put your and your lab partner's information and information about two classmates sitting near you. The program should not use spaces to align columns. Instead use the tab character, "\t".

Example

$ python3 classmates.py
Name        Hometown        Intended Major
====        ========        ==============
Sally       Roanoke         Computer Science
Alexander   Washington      Math
Graham      Charlottesville Physics
Terry       Richmond        Undecided

Hint

The tab in the terminal does not advance by 4 or 5 places, it advances to the next "tab-stop." You may need to add more "\t" characters than anticipated to format the table nicely.

Challenge

You are only required to have 4 rows in your table. However, it would be very advantageous for you to get to know more people from the class. Time permitting, go talk to as many people in the class as possible, and add them to the table as well.

Submission

Please show your source code and run your programs for the instructor or lab assistant. Only a programs that have perfect style and flawless functionality will be accepted as complete.