This is the P2PU Archive. If you want the current site, go to www.p2pu.org!

Python Programming 101

Expressions, Statements, and Names

Brylie Oxley's picture
Sat, 2011-04-23 00:44

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


 

Comments

You gonna go into OOP much or

Wesley Pennock's picture
Wesley Pennock
Sat, 2011-04-23 03:56

You gonna go into OOP much or not?

I think that we will be able

Brylie Oxley's picture
Brylie Oxley
Sat, 2011-04-23 05:17

I think that we will be able to explore functions, classes, and modules (including an introduction to the Python standard library) during this course.