Variables, expressionss, and statements. [April 26, 2011, 12:34 a.m.]
Lets look at three components of many programming languages.
Three primary tools we will be working with are:
- Statements - small parts of a program that do not necessarily return a result. A program is formed by a sequence of one or more statements.
- Names (a.k.a. variables) - pointers to data stored in memory.
- Expressions - combination of names, symbols, functions, and/or operators that return another value.
These three aspects are fundamenal to programming in general and will be explored throughout this course.
Examples:
In Python, statements can take many forms and work with many programming elements. For example assigning a name to a value:
a_name = value
Names are labels that point to a specific item in the computer's memory. With the above example a_name points to the memory location of value.
Expressions are a subset of statements and typically return some result. Basic examples of expressions include arithmetic operations:
2 + 3
3 - 2
5 * 5
10 / 5
Operators are included in expressions and consist of symbols such as +, -, /, *, **, etc.
Learning Resources
- Python for Informatics -- Chapter 2 (Slides, Printable Slides, Streaming Video, Download Video, Lecture Audio)