First Programming Concepts Cheat Sheet
First Programming Concepts Cheat Sheet
Functions and Keywords
Functions and keywords are the building blocks of a language’s syntax.
Functions are pieces of code that perform a unit of work. In the examples we've seen so far, we've only encountered the print() function, which prints a message to the screen. We'll learn about a lot of other functions in later lessons but, if you're too curious to wait until then, you can discover all the functions available here.
Keywords are reserved words that are used to construct instructions. We briefly encountered for and in in our first Python example, and we'll use a bunch of other keywords as we go through the course. For reference, these are all the reserved keywords:
False | class | finally | is | return |
None | continue | for | lambda | try |
True | def | from | nonlocal | while |
and | del | global | not | with |
as | elif | if | or | yield |
assert | else | import | pass | |
break | except | in | raise |
You don't need to learn this list; we'll dive into each keyword as we encounter them. In the meantime, you can see examples of keyword usage here.
Arithmetic operators
Python can operate with numbers using the usual mathematical operators, and some special operators, too. These are all of them (we'll explore the last two in later videos).
- a + b = Adds a and b
- a - b = Subtracts b from a
- a * b = Multiplies a and b
- a / b = Divides a by b
- a ** b = Elevates a to the power of b. For non-integer values of b, this becomes a root (i.e. a**(1/2) is the square root of a)
- a // b = The integer part of the integer division of a by b
- a % b = The remainder part of the integer division of a by b
Join the conversation