Professional Documents
Culture Documents
- Constantly ask yourself "What would happen if I ran X?" and then immediately answer that question by
running it!
Strings
- Ex. 'hello'
Adding Strings
- Strings can be added together using + (very different from adding numbers)
- + combines or joins two strings together end to end. This is called concatenation
Introducing Variables
- a way to refer to values that are unknown ahead of time and can change - values that can vary
- Ex. word = Hello; word is a variable, 'word' is not. Quotes within a string makes the difference.
- 'word' is literally just 'word' because the string has no value. It is called string literal
- an underscore is used to separate words when you want a variable name containing multiple
words.
- You can use variables in calculations just like you would use literals. Example: ‘Hello’ +
your_name
Writing Programs
- Editor is a place where you can writ and run longer programs.
- when print is used multiple times, each thing is printed on its own line.
- The program runs in the shell = meaning that the variables defined in the program
now exist in the shell with the last values they had in the program. This lets you explore
in the shell after the program completes
- Programs run in isolation - they don't depend on any previously defined variables. The
shell is reset and all previous variables are cleared.
- If you enter code in the shell and it has a value, that value will automatically be
displayed. That doesn't happen for programs in the editor - you have to print
values. If you remove print() from the program, changing the two lines to
just word + ' ' + name, nothing will be displayed.