This document contains coding exercises and notes to reinforce core Python concepts from the Masterschool program. The content was developed through an interactive, conversational approach with an AI assistant (Gemini) to solidify my understanding.
- Rapid Review: To quickly review and reinforce fundamental Python topics.
- Personal Notes: To create a personal, organized set of notes and code examples for future reference.
The exercises and code examples in this repository cover the following fundamental topics:
- Data Types
- Variables
- Arithmetic Operators
- Functions
- Conditional Statements
This project serves as a practical study guide to help me keep my Python skills sharp.
Data types are classifications of data that tell the computer what kind of data to expect and how to handle it. In Python, some common data types you've learned are:
- Integers (
int): Whole numbers, like5,-10,100. - Floats (
float): Numbers with a decimal point, like3.14,-0.5,2.0. - Strings (
str): Text enclosed in single or double quotes, like"Hello World",'Python'. - Booleans (
bool): Represents one of two values:TrueorFalse. They are often used in conditional statements.
Variables are used to store data values. Think of them as containers with labels. You assign a value to a variable using the equal sign (=).
Arithmetic operators are used to perform mathematical operations.
| Operator | Description | Example | Result |
|---|---|---|---|
+ |
Addition | 5 + 3 |
8 |
- |
Subtraction | 10 - 4 |
6 |
* |
Multiplication | 6 * 7 |
42 |
/ |
Division | 15 / 2 |
7.5 |
// |
Floor Division | 15 // 2 |
7 |
% |
Modulus (Remainder) | 10 % 3 |
1 |
** |
Exponentiation | 2 ** 3 |
8 |
Functions are reusable blocks of code that perform a specific task. They help make your code organized and easy to maintain. You can define a function using the def keyword, give it a name, and optionally include parameters to pass data into it. The return statement is used to send a value back from the function.
Conditional statements allow your program to make decisions. They execute a block of code only if a certain condition is True. You use if, elif (else if), and else keywords.
- The
ifblock runs if the first condition isTrue. - The
elifblock is checked if theifcondition isFalse. - The
elseblock runs if all previous conditions areFalse.
You'll also use comparison operators to evaluate conditions, such as: == (equal to), != (not equal to), > (greater than), < (less than), >= (greater than or equal to), and <= (less than or equal to).