save your file as hello.py (make sure you keep the .py extension!)
Let's Take a Closer Look at "Hello World" …
SPACE!
notice there's no space prior to print
Python is whitespace significant
whitespace matters
it mostly matters at the beginning of lines
indentation specifies the beginning and end of a group of lines of code
interior spacing usually doesn't matter
this will work →
this won't →
we'll see more about spacing in our next class
Print
print is a built-in function
what's a function? →
a function is a bunch of code that gets executed whenever the name of the function is called
it's a black box that does something
similar to functions you've seen in math
it may have parameters (inputs)
it can return a value (output)
though it doesn't necessarily have to have parameters or return values
Print Continued
print is a built in function… that will output whatever you give it to the console followed by a new line
you can tell it's a built-in function because it's highlighted (purple)
if you start typing it and open parentheses, you get a hint →
notice - it can take more than one parameter or argument!
you can give print multiple parameters by separating them with a comma; all parameters will be printed out separated by a space →
A Quick Note About Functions
we will go into the rest of the hint when we cover functions
for now we're just interested in calling functions
you call a function by
typing the function's name
open parentheses
any arguments (that is, values that you use as input for the function), separated by commas
close parentheses
A String
the one argument that we pass to the print function is "Hello world!"
this is called a string…
it's just a sequence of characters
note that it's surrounded by quotes!
One Last Look…
a function named print
being called with exactly one argument
the one argument is a string:
A Reminder About a Neat Trick
Again… as mentioned previously, you can use help(thing) in the interactive shell to show information about built-in functions and other Python features:
Some More New Stuff
we'll talk a little more about strings and other types of values