Chapter:Computer introduction - Exercises

From Juneday education
Jump to: navigation, search

Exercises

These are the exercises for the Computer introduction chapter. They were previously part of the chapter itself, but were moved here to keep the chapter page smaller and easier to grasp.

Hardware

Exercises

What is the hardware used to store information temporarily (until the power goes off) called?

Expand using link to the right to see the full content.

RAM or memory.

What is the hardware used to store information permanently (even after the power goes off) called?

Expand using link to the right to see the full content.

Disk. There are several different kinds of disks, e g hard disk. Sometimes this is referred to as persistent memory.

What is the hardware that functions rather much like the brain in the computer? I. e what part of the computer is the one who does the "thinking"?

Expand using link to the right to see the full content.

CPU - Central Processing Unit.

Give examples of hardware that can be used to communicate with a computer.

Expand using link to the right to see the full content.

  • screen/monitor/tv
  • The list will be long if we tried to list them all, so we’ll give some examples:
    • keyboard and mouse
    • joystick and game pad
    • gesture detection hardware
    • voice recognition hardware
    • ...

We read somewhere that VR is an output device. We are pretty sure, though, that VR is not an "output device". VR glasses perhaps are. VR usually stands for Virtual Reality, which encompasses much more than hardware.

What is the difference between software and hardware?

Expand using link to the right to see the full content.

Software are sequences of instructions performed by some kind of hardware, in our case typically the CPU in the computer. The software is not a physical item, although it is stored on some kind of storage media. Hardware is some kind of physical device that can perform some task(s) in relation to the computer. The hardware can be instructed using programs or it can be “hard wired”.

What is the memory in a computer used for?

Expand using link to the right to see the full content.

The memory is used to store information/data.

When storing a value in memory the computer puts that value in a certain place, called an address. Instead of you and/or your program remembering the address you can name this memory, e g `nr-of-students`. What is such a named memory called?

Expand using link to the right to see the full content.

Variable

Filetype

There are two main catergories of file types, text files and binary files. Explain what they are and give examples of each.

Expand using link to the right to see the full content.

  • Text files are files containing (data which can be interpreted as) text only. Binary files can contain (data which can represent) anything.
    • Text files:
      • HTML files
      • software source code
      • XML files
    • Binary files:
      • audio files (ogg, mp3, ...)
      • video files (ogv, avi, mp4 ...)

Together with these exercises we have a source code file Testing.java which you can find in this chapter's zip-file. Open this file using different programs, e g

    1. firefox, chrome or some other browser
    2. emacs, notepad, edit, Atom or some other text editor
    3. vlc or some other media player

Expand using link to the right to see the full content.

Which program do you think best suits the needs if you also want to change the file and save the changes?

Together with these exercises you have a presentation in video format. Open this file using different programs, e g

    1. firefox, chrome or some other browser
    2. emacs, notepad, edit or some other text editor
    3. vlc or some other media player

Expand using link to the right to see the full content.

Which program worked best for watching the video?

  1. Together with these exercises you have a document stored in various different formats. Open these documents (one by one) in
    1. firefox, chrome or some other browser
    2. emacs, notepad, edit or some other text editor
    3. vlc or some other media player

Expand using link to the right to see the full content.

Try to reflect upon what the different formats means in terms of how you can access the files.

File System

Information
You do have bash installed for your terminal, haven't you?

Before you start with the exercises you need to have a terminal with bash up and running, see using bash.

Newer version of Windows come with a bash shell, as do Mac OS and GNU/Linux. If you have an older version of Windows, you need some extra software.

If you don't have bash on your computer (only Windows 10 comes with bash), then now is the time to install it! These chapters in our Bash course book shows you how to install it and how to get started:

Those pages have instructional videos and exercises. If you intend to take a whole Java course using the material of which this page is a part of, then we strongly advice you to take a break from this page, make sure you have bash installed and know the basics, before returning here and continuing on the exercises below!

Some notes on typography: To show that a command is entered interactively via the terminal window, the command line is prefixed with a dollar sign "$". The commands you should enter follows the "$". In other words, you should not enter the "$" itself, it is just there to show that the command is entered into a terminal window!

  1. Find out where in the file system you're in. This can be done in several ways. You can, for example, look at the prompt:
    username:/home/adam$ or using ~ to mean "home directory" :username:~$
    You're in your "[HOME]" folder. HOME is nothing but a directory simply called HOME. Each (normal) user has a HOME directory. Nowadays the home directory contains directories such as [Desktop directory], [Documents directory], [Photos directory] etc.
  2. You can also run a command in the shell, e g pwd:
    $ pwd
  3. Your location (where you stand) is called working directory or "current directory". The command pwd is an abbreviation for "print name of current/working directory".
  4. Create a new directory using mkdir:
    $ mkdir new-catalog
    
  5. Make sure you can see the directory:
    $ ls new-catalog
    
  6. Check which files and directories exist in the current directory. This can be accomplished simply by entering:
    $ ls
    
  7. Change directory to the newly created directory (new-catalog):
    $ cd new-catalog
    
    Verify that you have changed directory:
    $ pwd
    
  8. Check if there are any files in this directory:
    $ ls
    
  9. Create a file in the new directory using your favorite application for creating text files (an editor of some sort). Save the file (in the newly created directory) and exit the editor. Return to the shell/terminal and list all files in the newly created directory again. Can you see the new textfile listed? If not, you have made some error while saving the text file!
    To list all files, enter:
    $ ls
    
    and verify that you see the file in the list.
  10. Go back to the directory you originally were located in (one directory "up" from the newly created directory):
    $ cd ..
    
  11. Find out what directory you are now located in. It should be "above" the newly created directory.
    $ pwd
    
  12. Delete the text file you created in the new directory using the rm command:
    $ rm new-catalog/THE_FILE_NAME_YOU_CHOSE
    
  13. Verify that the file is now gone:
    $ ls new-catalog
    
  14. Delete the new directory. N.B.! The syntax below will only work if you are located in the directory "above" the directory to be removed. That is, if you are located in the directory where you were located when you created the new directory. To remove a directory (and all of its contents) use the rm command with the -r flag. Or you may use the rmdir command to remove an empty directory.
    $ rm -r new-catalog
    
    (alteratively, you may use the
    rmdir
    
    command)
  15. Verify that the directory is gone:
    $ ls new-catalog
    
    The shell should reply: "No such file or directory"
  16. Launch an application from the command line. For instance, launch notepad or TextEdit (or some other application). Find out how to do this using any search engine you'd like. Hint for search phrases to enter into the search engine:
    open text editor from command line cygwin

Solutions to file system exercises

There are no solutions for these exercises, but we have a video where you can watch us "solve" these exercises here: Computer introduction - Exercises

OS

Give examples of how different computers communicate with each other.

Expand using link to the right to see the full content.

Using (IP) network cards, bluetooth, serial cable, pidgeons leds.... Most common way to communicate is to use network cards. The internet is loads of computers connected via network cards.

If you want to send an ordinary mail you specify the recipient and the address. How do you specify the recipient of an email? Explain the parts of the address.

Expand using link to the right to see the full content.

Let's assume you want to send an email to one of the authors of these exercises, Henrik Sandklef. His address is sandklef@chalmers.se. There are two parts in this email address separated by the @ sign. The second part chalmers.se is the domain name, typically an organisation or company name. The first part sandklef is the recipient at the specified organsiation. So when you're sending the email the email is received by a computer at chalmers.se and by that computer is stored in sandklef's INBOX.

Let's assume you want to go to a website, e g www.gnu.org. From where does your computer get data (or information) when you tell the browser to open up that address?

Expand using link to the right to see the full content.

Your computer opens a network connection to the computer at www.gnu.org and gets the information from that.

In the question above, your computer connects to another computer to get the information. That computer is connected using an address different from www.gnu.org. How is www.gnu.org translated to a so called IP address?

Expand using link to the right to see the full content.

The address www.gnu.org is translated using Domain Names Servers to an IP address (4 numbers separated with three dots).

Start a shell (or command prompt).

Expand using link to the right to see the full content.

This is done in ways that differ between OS:es. Go back to the videos on bash and cygwin for more information.

Find out what date it is by using the shell

Expand using link to the right to see the full content.

Type the following command

$ date

Print the value of the PATH variable. This is done in different ways depending on the underlying operating system.

Expand using link to the right to see the full content.

Type the following command

$ echo $PATH

Explain in your own words what is printed out.

Expand using link to the right to see the full content.

The various directories where the operating system (more specifically the shell) will look for programs, are listed. The PATH variable contains a list of such places, which allows you to enter a command like date in the terminal. The shell must know where to find the program date so that it can execute it, and the list inside the PATH variable helps the shell find the date program for instance.

Print the value of the NOTEXIST variable. Explain in your own words what is printed out.

Expand using link to the right to see the full content.

Most likely this variable has no value assigned so nothing is printed.

Assign the NOTEXIST variable the value 42. Print the value of the NOTEXIST variable and explain in your own words what is printed out.

Expand using link to the right to see the full content.

Type the following command

$ NOTEXIST=42
$ echo $NOTEXIST

42 is printed out since the value of the NOTEXIST variable now has been set to 42.

Program

What is a program? Give some examples of programs.

Expand using link to the right to see the full content.

A program is a sequence of instructions that a computer with an operating system can execute.

Examples: chrome, firefox, thunderbird

What is a process?

Expand using link to the right to see the full content.

A process is an executing instance of a program?

Give two examples of how a program can be started by a user?

Expand using link to the right to see the full content.

You can start programs:

  • from the shell (typing in its name and arguments, then hitting the enter key) - requires the program to be installed in a directory included in the PATH variable, or that you type the absolute path to the program
  • from a menu system (e.g. start menu)
  • by clicking a link
  • ... and probably several more ways

Does a program have to have a GUI (graphical user interface)?

Expand using link to the right to see the full content.

No. Many program have no graphical user interface. These programs are often text based in its communication with the user or system.

What do you think happens when starting firefox (a browser) from a shell the following way:
$ firefox http://www.gnu.org
(provided you have firefox installed, and the firefox executable is in a directory in your PATH variable)

Expand using link to the right to see the full content.

Firefox starts up and loads the website http://www.gnu.org (or if it's not installed or not in your PATH, the shell will say something like "firefox: command not found"

What are the argument(s) supplied to a program (see previous exercise) on the command line called?

Expand using link to the right to see the full content.

There are different names for these arguments:

  • Command line arguments - typically answering the question "What?"
  • Command line options - typically answering the question "How?"
  • Program/command line options are sometimes also called "flags".

An example with both argument and option could be:

$ ls -l /tmp

The command is called ls and the option/flag is -l and the argument is /tmp. The ls command is here invoked to list the files in /tmp - the answer to the "what question" - and to list them in the long format including lots of information using the flag -l - the answer to the "how question".

Links

Where to go next

« PreviousBook TOCNext »