Python runs one statement after another. print writes to the cell output. A # starts a comment.
Goal
Run print, a comment, and see the difference between print(x) and a bare x.
First cell
print("Hello, Python")
print("Swiftener notebook")Comments and multiple prints
# This line is ignored.
print("Ada")
print("Alan")
print("Grace")Last expression
"Nairobi"The notebook shows 'Nairobi' because it is the last expression. Compare:
city = "Nairobi"
print("printed:", city)
cityErrors are useful
print("about to fail")
print(unknown_name)You should see a NameError and a traceback. The next chapter puts names on the left of =.
Tip
If nothing appears, the cell is empty, still loading Python, or you ran a markdown cell. Check the status line, then Shift+Enter on a code cell.