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.
ASCII Art

ASCII (pronounced ass-kee) is system for encoding characters including the letters of the English alphabet, numbers, and punctuation symbols, essentially the characters you see on the keyboard. ASCII art is pictures created using only the ASCII characters. Making smiley faces for text messaging is one form of ASCII Art (^_^). They can also be much more complicated.

Details

In Emacs create a python program in a file called ascii_art.py in your lab1 directory. The program should print some ASCII art when run. The art should be more complicated than a smiley face, but does not need to be realistic like the complicated examples above. It should be multiple lines long and you should sign your names at the bottom of the drawing. You can design it yourself or do web searches for art that you can reproduce. For example if you wanted to draw a cute rabbit, you could do a Google Image Search for 'rabbit ascii art'.

Example

$ python3 ascii_art.py
( ) ( )
(>*.*<)
(") (")
By Roger the Shrubber

Hint

Your program should have one print statement for each line of the ascii art. For example, the first line of the above example would look like print('( ) ( )'). Don't get carried away and try to write the whole program at once. Write just the first line, then run it to make sure that it is correct. Once it is, proceed to the next line, and so on.

 

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.