Computer Science 20
Data Types
All computer programming languages identify different types of data. This is necessary because a computer must perform different operations with different types of data. Words and numbers are different. A language must be designed so that a programmer can't try to find the square root of a word. A variable is a memory location in which data is stored. Variables are labeled with a variable name and then a value of that data type can be stored in that variable. The type of data which a variable will hold is identified through the variable name or a program statement.

Data Type Practice Activity

    Assignments

  1. Using your textbook, or the links provided, create a list of the different data types for the language that you are using. (Hint: Often people talk about variable types meaning data types.)
  2. Explain how variable names for the different data types are identified in the language that you are using.
  3. Each language will have some words which are reserved for special functions and cannot be used for a variable name. Make a list of reserved words for your language.
  4. Using a book from a different language, or the links provided, compare the data types and the way they are identified for a different language.

    Language Resources
    1. Thau's JavaScript Tutorial

Variable Names
When you are writing a program any variable names that follow the rules of your language will work in a program. However, it is always a great idea to name your variables so that the names tell you what they represent. For example if a variable in a program was named x the program would run, but if x represented salary then it would be much better to name the variable salary. Other variables might be raise, overtime and tax.

    Assignments

  1. For the following lists of variable names guess what you think each program is about:

    List 1
    student
    assignment1
    assignment2
    assignment3
    midterm
    final
    mark
    List 2
    theatre
    movie
    date
    price
    attend_1
    attend_2
    revenue
    List 3
    date
    player
    place
    serve
    hit
    kill
    spike
    List 4
    name
    offence
    judge
    sentence
    witness
    alibi
    officer

  2. Write a small program with all of one column of variable names used in it. Be sure to decide what type each variable is and change the name to fit the type if that is necessary.
  3. Make up a variable list like the ones above and share it with your classmates for them to guess.