I’ve come across a couple of students who can do machine learning stuff, but cannot write a proper nested for loop to do a simple task (which isn’t very ideal).
This checklist thus aims to be a benchmark for the stuff a Python beginner needs to be decently familiar/competent with before I feel he/she is ready to move on to harder stuff eg. OOP, DSA, web dev or whatever. Of course, this is my personal opinion (formed from tutoring Python) and it could differ from yours.
1) Basic Python Syntax
- Using the
print()
function - Using the
print()
function with commas eg.print(1, 2, 3)
- Comments in Python using
#
- The Assignment Operator
=
- What makes a variable name valid?
- How to ask the user for input using the
input()
function - What happens when
x=4
and thenx=5
? - How to switch the values of 2 variables
2) Basic Data Types
- Integers
int
- Floats
float
- Strings
str
- Booleans
bool
- Type casting eg. how to convert an integer to string and vice versa
3) Numerical Operators
- Addition
+
- Subtraction
-
- Multiplication
*
- True division
/
- Floor division
//
+ how is this different from true division? - Modulus
%
- Exponentiation
**
- Order of operations — which ones of these are executed first? (PEDMAS)
- Addition for strings (also known as concatenation)
- Multiplication for strings
- Numerical operators with incompatible types (using type casting)
- Compound assignment operators eg.
+=
,-=
,*=
and so on
4) Conditional Statements
- Comparison operators
==
,!=
,<
,<=
,>
,>=
- If-elif-else loop syntax + which statements execute given a condition
- Logical operators
and
,or
¬
- De Morgan's Law —
not (X and Y)
equalsnot X or not Y
5) Functions
- Built-in functions eg.
print()
,input()
,range()
,abs()
- Syntax of defining your own function — 0, 1, 2 … arguments
- How to call your own function
- How to call a function in another function
6) For Loops
- Basic for loop syntax
- The
range
function with 1 argument - The
range
function with 2 arguments - The
range
function with 3 arguments - The
range
function with 3 arguments + step is negative - The
break
keyword and what it does
7) While Loops
- Basic while loop syntax
- How to save your computer from an infinite while loop
- How to NOT create an infinite while loop
- The
break
keyword and what it does - When to use for loop VS when to use while loop
- Looping condition vs breaking condition
8) Strings
- Basic string syntax — how to create a string
- String addition and multiplication
- Indexes in strings, and how to index strings to get single characters
- Basic string slicing with
start
andend
- String slicing with empty
start
andend
arguments - String slicing with negative
start
andend
arguments - String slicing with 3 arguments
start
,end
andstep
- String slicing with 3 arguments + empty arguments
- String slicing with 3 arguments + negative
step
- Common string functions — len, upper, lower, strip, count, index, find, rfind, replace, isupper, islower, isalpha, isnumeric, isalnum
- Checking if a string contains a character or substring using
in
- Whitespace and escape characters eg.
" "
,"n"
,"t"
etc - Formatted strings eg.
f"My name is {name}"
- How to iterate through strings using for loop or while loop
- Strings + compound assignment operators
+=
and*=
9) Lists
- Basic list syntax — defining a list
- List addition and multiplication
- Indexes in lists + how to index lists
- List slicing (this works the same way as strings)
- Adding new elements to back of list using
.append
- Replacing existing elements in list
- More common list methods eg. len, index, count etc
- Checking if an element exists inside list using
in
- Iterating through a list using a for loop vs while loop
10) Dictionaries
- Basic dictionary syntax — defining a dictionary
- What data types are valid dictionary keys/values?
- Accessing values in a dictionary using a key
- Adding new key-value pairs into existing dictionary
- Replacing existing key-value pair in dictionary
- Updating dictionary value using compound assignment operators
- Common dictionary methods — len, values, items, keys
- Checking if key/value exists inside dictionary
- Iterating through dictionaries
11) Tuples
- Basic tuple syntax — defining tuples
- Tuples vs lists — concept of immutability
- Simple tuple unpacking
- Tuple indexing & slicing (same as lists)
12) Sets
- Basic set syntax — defining sets
- What values we can or cannot add into a set
- Why we use sets
- Adding new values into a set using
.add
- Removing values from sets using
.remove
- Common set methods — len, intersection, union
13) File Reading & Writing
- Simple file reading using
with open(filename) as f
- Read, append and overwrite modes
- Simple file writing using
with open(filename, mode) as f
14) Accumulation Using A Loop
- Getting 15 from
[1, 2, 3, 4, 5]
— sum of numbers in list - Getting 120 from
[1, 2, 3, 4, 5]
— products of numbers in list - Getting 9 from
[1, 2, 3, 4, 5]
— sum of odd numbers in list - Getting
"ieae"
from"pineapple"
— keeping only vowels - Getting
[1, 4, 9, 16, 25]
from[1, 2, 3, 4, 5]
- Getting
{1:1, 2:4, 3:9, 4:16}
from[1, 2, 3, 4, 5]
15) Nested Loops
- Being able to do the following using nested loops (no hardcoding)
- Print the following pattern given
n
. For instance, ifn=3
andn=5
:
1 12 123 1 12 123 1234 12345
- Print the following pattern given
n
. For instance, ifn=3
andn=5
:
1 21 321 1 21 321 4321 54321
- Print the following pattern given
n
. For instance, ifn=3
andn=5
:
321 21 1 54321 4321 321 21 1
- Print the following pattern given
n
. For instance, ifn=3
andn=5
:
321 32 3 54321 5432 543 54 5
- Print the following pattern given
n
. For instance, ifn=3
andn=5
:
1 12 123 1 12 123 1234 12345
- Print the following pattern given
n
. For instance, ifn=3
andn=5
:
1 21 321 1 21 321 4321 54321
Conclusion
Did you manage to check 95% of the boxes?
Some Final words
If this article provided value and you wish to support me, do consider signing up for a Medium membership — It's $5 a month, and you get unlimited access to articles on Medium. If you sign up using my link below, I'll earn a tiny commission at zero additional cost to you.
Sign up using my link here to read unlimited Medium articles.
Get my free Ebooks: https://zlliu.co/books
I write programming articles (mainly Python) that would have probably helped the younger me a lot. Do join my email list to get notified whenever I publish.
More content at PlainEnglish.io. Sign up for our free weekly newsletter. Follow us on Twitter, LinkedIn, YouTube, and Discord. Interested in Growth Hacking? Check out Circuit.