Sure, here’s a cheat sheet for Lesson 1: Introduction to Python:
Basics:
- Python: High-level, interpreted programming language known for its simplicity and readability.
- Jupyter Notebook: Interactive environment for running Python code.
Syntax:
- Variables: Containers for storing data. Example:
x = 5 - Data Types:
- Integer:
int, Example:5 - Float:
float, Example:5.0 - String:
str, Example:'hello' - Boolean:
bool, Example:True
- Integer:
- Arithmetic Operators:
- Addition:
+ - Subtraction:
- - Multiplication:
* - Division:
/ - Exponentiation:
** - Modulus:
%
- Addition:
- Printing: Displaying outputs. Example:
print("Hello, world!")
Example Code:
# Variables
x = 5
y = 3.14
name = "Alice"
is_valid = True
# Arithmetic Operations
result = x + y
print("Result:", result)
# Printing
print("My name is", name)
Notes:
- Python is dynamically typed, meaning you don’t need to declare variable types explicitly.
- Use
#for comments. - Python uses indentation for code blocks instead of braces
{}like in other languages.