Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a brief description of the print statement #101

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions python_introduction/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,22 @@ Awesome, right? Of course, variables can be anything, so numbers too! Try this:

Play with this for a while and see what you can do!


## The print function

Try this:

>>> message = 'hello'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer using name = 'Ola' rather than the traditional hello world.

I've found that it makes the participants subsitute their own name instead and they're more engaged as a result.

>>> message
'hello'
>>> print(message)
hello

When you just type `message`, the Python interpreter responds with the string *representation* of the variable 'message', which is the letters h-e-l-l-o, surrounded by single quotes, ''. When you say `print(message)`, Python will "print" the contents of the variable to the screen, without the quotes, which is neater.

As we'll see later, `print()` is also useful when we want to print things from inside functions, or when we want to print things on multiple lines.


## Lists

Beside strings and integers, Python has all sorts of different types of objects. Now we're going to introduce one called __list__. Lists are exactly what you think they are: they are objects which are lists of other objects :)
Expand Down