This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.

Object Oriented programming with the Python language.

With Python, learning to program is easy and fun! Many Python programs are clear and concise, reading like plain English. This course will cover the fundamental aspects of Python including data types, flow control, encapsulation, inheritance, and helpful tools from the Python standard library.

These three aspects are fundamental 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 such as names and operators.

Names are labels that point to a specific item in the computer's memory. Assignment statements are statements where we assign a name to a value, or memory location. Below, a_name points to the memory location of a_value.

>>> a_name = 'a_value'

Names, technically called identifiers, must start with an underscore (the "_" character) or a letter. Names can contain any sequence of letters, numbers, and underscores. Names cannot contain spaces or other special characters. Names are case sensetive, so 'Sunshine' and 'SUNSHINE' are two different names.

There are 33 reserved words that may not be used as names. The following table outlines Python's reserved words.

Python Reserved Words

False

None

True

and

assert

break

class

continue

def

del

else

except

finally

for

from

global

import

in

is

lambda

nonlocal

not

pass

raise

return

try

while

with

Expressions typically return some result. The result can then be assigned a name.

In the following example, the expression on the right hand side will be evaluated and then assigned to the name to the left of the '=' assignment operator.

>>> total = 35.9 + 24.29
>>> total
60.19

Basic examples of expressions include arithmetic operations. Operators are included in expressions and consist of symbols such as:

Assignment

Copy your completed excercises and share them via a pastebin service such as dPaste.

If you have any questions or difficulties post them here and we will work together to make sure that everyone has a positive learning experience. Please also post ideas and insights into these concepts. We can learn a lot from each others' perspectives and experience :-)

Task Discussion

I wrote a script to address all of the parts of the chapter 2 exercises. I tried to show different ways of doing each thing, so there is no consistency in the script, but there are a lot of different approaches toward the same end instead.

Hi,
PRINT is a command or function so you should not use an equal sign, as it. Will confuse the interpretation.
You could use something like
For python 3
print("name:" % name)
For python 2
print "name:" % name
Happy programming!
S.
Sent from my iPad

As Coffe Bean said, you are not going to see an output because you are doing an "invisible" assignment of the "Hello", name to a variable called print. The print command is designed to make variable contents visible, as in

Greetings from Ireland.
Thank you for contacting me. I am currently out of the country with very limited access to my emails. I shall return to the office on Tuesday May 7th 2013. Please be aware that Monday May 6th is a bank holiday in Ireland.
During my absence Ms. Aoife Hayes will be delighted to answer your queries. You may reach her at aoife.hayes@cst-international.com
Warmest Regards,
Rosetta Talley