Module 1: Variables, Values, and Expressions

CMPS 162: Introduction to Programming

Introduction

Variables, values, and expressions form the basic components of all computer programs. A variable is a storage location in the memory of the computer that is identified by a name and can store values. Values are expressions that cannot be reduced to something simpler, such as a number or a string (i.e., text). In general, expressions can be more complex than values, such as the following expression that captures a computation, 1+2+3, and which would result in the value 6 when it is evaluated. Note that expressions can also contain variables. For example, let’s assume there is a variable x that has been assigned value 10, then the expression 2*x will result in the value 20. While it would be impossible to write programs without values and expressions, variables make the life of a programmer much easier. Hard coding a value in each location it is used would make changing programs very difficult, but variables allow us to make such a change in only one location.

Module Objectives

  • Illustrate how to alert information to the user
  • Describe variables for Strings
  • Describe variables for Numbers
  • Identify legal and illegal variable names
  • Apply familiar operators in math expressions
  • Apply unfamiliar operators in math Expressions
  • Eliminate ambiguity from math expressions

Learning Resources

  • Module 1 Readings: Chapters 1 thru 7 from Myers

Learning Activities

Video

How to get started:

For Further Study

Leave A Reply

Your email address will not be published. Required fields are marked *