INF1-IP: Week 1
Lecture 0 - Introduction to Introduction to Programming
Lecture 1 - Algorithmic thinking
- Lecture slides
- Self-guided notebook (right-click → Save As... then remove the .txt part so it is saved as an .ipynb)
Learning outcomes
- What a Python program typically looks like
- Displaying text and values with
print()and collecting text withinput() - Assigning and using variables
- Using arithmetic operators to perform calculations
- Planning programs using decomposition and pseudocode
- Documenting your code with comments
Key terms
Click to expand.
Program
A set of instructions to a computer.
Algorithm
A set of instructions that describes how to solve a problem.
Syntax
The rules of the symbols of a programming language.
Decomposition
Breaking down a problem into smaller, more manageable chunks.
Pseudocode
Computer code written in human-readable format, preserving the exact instructions but ignoring a programming language's particular syntax.
String
A type of value that holds text, enclosed in quotation marks.
Escaping characters
In a string, using a backslash
\to indicate to Python to represent a character such as a quotation mark.Variable
A name that refers to an object.
Variable assignment
Giving an object a particular name that you can use to refer to it from your code.
Comment
A piece of code that is ignored by the computer, usually used to add human-readable descriptions.
New syntax
Click to expand.
=The assignment operator, giving a name to an object.
'...'and"..."Denote a string.
+,-,*,/Addition, subtraction, multiplication, and division operators, respectively.
(and)(in mathematical expressions)Parentheses that group mathematical expressions to be executed before the expressions outside of the parentheses.
print(content)Displays
contentto the user. Can display multiple values on one line, when separated by,.input(prompt)Displays
promptto the user and asks them to provide input which can be saved to a variable..strip()Removes excess whitespace from the beginning and end of a string.
#Starts a comment, telling Python to ignore the rest of the line.
Further practice
Further practice sections will link to online materials that you might find useful if you want more exercises. Their content might not match one-to-one to what's presented in the lectures but we'll try to match them as close as possible. More will be added over the course of the semester - and if you find any that you find useful yourself, let us know on EdStem and we'll add them here!
- Official Python Tutorial: An informal introduction - later parts go beyond what this lecture teaches.
- W3Schools: Output, Comments, and Variables
- Helsinki Python MOOC: Getting started, Information from the user, and More about variables
Tutorial
No tutorial this week.
Assessment
No assessment this week.