1/108
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Python
Is a high-level programming language known for its simple and readable syntax.
It is widely used in different fields such as web development, data science, automation, and artificial intelligence.
It is popular among beginners is because it is easy to learn compared to many other programming languages.
Guido van Rossum
He is a Dutch programmer.
In 1989 while he was working at the Centrum Wiskunde & Informatica (CWI) in the Netherlands.
The first official version of Python (Python 0.9.0) was released in February 1991.
This early version already included important features such as functions, exception handling, and core data types like lists and dictionaries.
Monty Python’s Flying Circus
The name “Python” was inspired by the British comedy show ___ which Guido van Rossum enjoyed watching. The name was chosen because it was short, unique, and memorable.
Where is Python Used?
It is used in many areas of technology and software development.
It is commonly used in web development, where developers create websites and web applications using frameworks such as Flask and Django.
Python is also widely used in data science and artificial intelligence, where it helps analyze data and build machine learning models.
In addition, Python is used for automation, scripting tasks, software development, and system administration.
Companies that use Python
Netflix
Spotify
Why Python is Good for Beginners?
It is considered one of the best programming languages for beginners because its syntax is simple and easy to read.
Unlike many other languages, Python requires fewer lines of code to accomplish tasks.
This allows students to focus more on understanding programming logic and problem-solving, rather than worrying about complex syntax.
Because of these advantages, Python is widely used in universities and programming courses around the world.
top to bottom
Python scripts are read and executed line by line from ____
Visual Studio Code
The code editor (IDE) used in this course to write and edit Python programs.
.py
The standard file extension used when naming Python files.
Data Types
String (str)
Integer (int)
Float (float)
Boolean (bool)
String (str)
Text data enclosed in double quotation marks (" ")
Does not require explicit "str" declaration.
Integer (int)
Whole numbers without any decimal points.
Float (float)
Numbers containing decimals, represented as 64-bit values.
Boolean (bool)
A logical data type that can only be either True or False
Collection Data Types
List
Tuple
Set
List
An ordered, mutable collection that can store multiple values in a single variable.
Example of a List
fruits = ["apple", "orange", "orange"]
where print(fruits[0]) outputs "apple".
Tuple
An immutable collection where values cannot be changed once they are created; often used for coordinates.
Example of a Tuple
coordinates = (10, 20)
Set
An unordered collection of unique values that automatically removes duplicate items.
Example of a Set
numbers = {1, 2, 3, 4, 4, 5}.
print()
A built-in function used to display output to the console.
input()
A function that receives user input and always returns it as a string value.
Type Conversion
Also known as Type Casting
Converting one data type to another, such as using int() to convert a string input into a number.
Example of Type Conversion
# The variable is at the front, followed by the conversion type
age = int(input("Enter your age: "))
# Now you can perform math because 'age' is an integer
print(age + 1)
Arithmetic Operators
These are used to perform mathematical calculations.
Examples of Arithmetic Operators
Addition +
Subtraction -
Multiplication *
Division /
Modulus %
Exponent **
Floor Division //
Comparison Operators
These are used to compare two values and always return a Boolean (True or False).
Examples of Comparison Operators
Equal to (==)
Not equal to (!=)
Greater than (>)
Less than (<)
Greater than or equal to (>=)
Less than or equal to (<=)
Logical Operators
These are used to combine multiple conditions together.
Examples of Logical Operators
and
or
not
and
Returns True only if both conditions are True.
or
Returns True if at least one condition is True.
not
Reverses the result; turns True to False and False to True.
Data Structure
An organizational framework and methods for organizing data.
It provides specific methods for organizing, managing, and storing data to enable efficient access and modification.
Importance of Data Structures
Efficiency
Problem-Solving
Regional Demand (e.g. Engypt, Saudi Arabia, MENA)
Abstract Data Types (ADTs)
Define allowed operations without focusing on the underlying implementation.
A logical description of a data set and the operations allowed on it without specifying how the data is actually stored in memory.
Big-O Notations
Big O
O (log n)
O (1)
O (n)
Big O Notation
A mathematical notation used in computer science to measure and describe the efficiency of an algorithm's execution time or space requirements as the input size grows.
O(log n)
Represents logarithmic time, commonly seen in binary search operations.
O(1)
Constant time complexity; the fastest performance regardless of data size.
O(n)
Linear time complexity; performance scales directly with a linear scan of the data.
Linear Data Structure
A structure where data elements are arranged sequentially, meaning each element is attached to its previous and next adjacent elements.
Types of Linear Data Structures
Arrays
Linked List
Stack
Queue
Arrays
Efficient storage using a contiguous memory layout for quick access.
Linked List
Efficient organization where elements are connected by pointers in a flexible memory structure.
Stack
A "Last-In, First-Out" structure (LIFO)
Uses push to add elements to the top and pop to remove the most recently added item.
Queue
A "First-In, First-Out" structure (FIFO)
Uses enqueue to add and dequeue to remove items.
Non-Linear Data Structure
Used for managing complex, hierarchical relationships within data.
Types of Non-Linear Data Structures
Trees
Graphs
Trees
A hierarchical structure that forms a relationship like that of the parent and a child.
It consists of various nodes linked together.
It includes types like Binary Trees and Binary Search Trees.
Graphs
A structure consisting of nodes (vertices) representing entities and edges representing the connections or relationships between those entities.
Hash Tables
A structure that maps keys to values for extremely fast data retrieval; it uses collision handling like chaining or open addressing to manage data conflicts.
MENA Core Studies
Localized applications of these data structures used to build infrastructure for Smart Cities, Healthcare systems, and Fintech (Financial Technology).
Common Learning Challenges
Pointers
Recursion
Debugging
Visual Learning
Hands-on Coding
Practice Platforms
Code Quality Standars
Industry best practices for writing maintainable software, such as using clear naming conventions, performing unit testing, and adhering to style guides.
Flask
A lightweight, flexible Python web framework designed for building applications quickly with minimal complexity by functioning as a web server that processes browser requests and returns HTML, data, or templates.
Armin Ronacher
The developer who released Flask in 2010, originally as an April Fool's joke, after deciding to create a simpler alternative to more complex Python frameworks.
Micro-framework
A design concept where the framework includes only basic tools for routing, request handling, and template rendering without enforcing a strict project structure or built-in modules for authentication and databases.
Sinatra Inspiration
The Ruby web framework known for simplicity and minimalism that inspired the creation and design philosophy of Flask.
BSD License
The open-source license under which Flask was initially released, allowing for free and open distribution and use.
Flask vs. Django
Flask is a micro-framework providing only essential tools, whereas
Django is a "full-stack" framework that integrates ORM systems, authentication, and an MTV (Model-Template-View) architectural pattern by default.
Server-Side Rendering (SSR)
The process used by Flask where the complete HTML content is generated on the server before being sent to the client browser, resulting in a new document for each request.
Client-Side Rendering (CSR)
The process used by React where the browser downloads JavaScript to dynamically generate and manipulate HTML within the client environment, updating locally without a full-page reload.
Route Decorator
The @app.route() syntax used to associate a specific URL pattern with a Python function; when the URL matches, Flask executes that function.
Root URL (/)
The base address of a website; in Flask, this URL pattern typically corresponds to the index() function.
Server Response Types
After executing a function, the Flask server typically sends back an HTML document, plain text, JSON data, or a redirect instruction to the client.
Main Runtime Block
The if __name__ == "__main__": statement which ensures the Flask server only starts when the script is executed directly, and not when imported as a module.
WSGI-Compatible
Refers to how Flask runs as a Web Server Gateway Interface application, which is the standard protocol for Python web development.
Flask Development Server
A temporary server created by Flask upon execution that listens on a specified network port (default is 5000) for incoming HTTP requests.
app = Flask(name)
The code used to initialize the Flask class and create an application object, which serves as the central registry for the app.
name
A built-in Python variable passed to the Flask constructor to help the framework determine the root path of the application and locate resources like templates and static files.
Secret Key
A cryptographic string, such as app.secret_key = "myfirstapp", used by Flask to securely sign session cookies and prevent client-side data tampering.
debug=True
A parameter in the app.run() method that activates automatic reloading of the server when code changes and provides detailed error messages for troubleshooting.
Query Parameters (GET)
Additional data supplied through key-value pairs that appear after a question mark (?) in a URL; used for filtering or optional values.
request.args.get()
The Flask method used to retrieve specific values from query parameters.
Path Variables
Dynamic elements embedded directly within the URL pattern (e.g., <username>) that capture variable input as arguments for the function.
Dynamic URL Parameters
A route like @app.route("/profile/<username>/<age>") where Flask automatically converts dynamic segments into function arguments
Dynamic Argument Example
In the URL /profile/Ana/21, "Ana" and "21" are extracted by Flask and passed directly into the profile(username, age) function.
PIP
The Python package installer used to download libraries; it is included by default in Python versions 3.4 and later.
pip -- version
The command used in the terminal to check if PIP is already installed on your system.
python -m ensurepip --upgrade
The specific command used to download and install/upgrade PIP if it is not currently installed.
pip install flask
The terminal command used to download and install the Flask web framework to your local environment.
Flask Instance Creation
The lines from flask import Flask and app = Flask(__name__) which import the library and create the application instance.
app.secret_key
A required configuration setting used by Flask to secure user sessions.
@app.route("/")
A decorator and function that tells Flask to display specific content (like "Hello World") when the user loads the homepage.
if __name__ == "__main__":
The code added at the bottom of the file to ensure the Flask server only starts when the file is run directly.
app.run(debug=True)
The command inside the runtime block that starts the web server and enables debug mode for easier troubleshooting.
python filename.py
The terminal command executed inside the project folder to start the Flask web server.
http://127.0.0.1:5000/
The default local address (localhost) where you can view your running Flask application in a web browser.
templates folder
A specific folder that must be created inside flask_project to store all HTML files, as Flask is designed to look for templates only in this directory.
index.html
A standard HTML file created inside the templates folder to define the structure and layout of a webpage.
render_template
A Flask function that must be imported to allow the server to load and display HTML files from the templates folder.
Flask Form
The process by which user input is collected through an HTML form, transmitted via HTTP (usually POST), and handled by Flask using the request.form object. It ensures secure data handling, validation, and user-friendly navigation through the Post/Redirect/Get pattern.
Redirect
Is a process of sending the user from one URL to another URL. This is commonly used after a form submission to prevent duplicate submissions and to guide the user to the correct page after completing an action.
redirect()
Is a function that is used to redirect the user.
Automatically sends user to another route.
url_for()
Finds the URL based on function name.
This function is used to generate the correct URL for a specific route function instead of writing the URL manually. This makes the code more flexible and easier to maintain because if the URL changes, the function name remains the same.
This function is commonly used together with redirect() to navigateusers to another page after processing data from a form.
Post/Redirect/Get (PRG)
The ___ pattern is a web development design pattern used to prevent duplicate form submission. In this pattern, when a user submits a form, the server processes the data using a POST request, then redirects the user to another page using a redirect, and finally the new page is loaded using a GET request.
This pattern prevents the form from being resubmitted if the user refreshes the page and improves the overall user experience.
GET Method
Is an HTTP request method used to request or retrieve data from the server.
When using ___, the data is visible in the URL as query parameters.
This method is commonly used for search functions, filtering data, and retrieving information from the server.
They are not recommended for sensitive data because the information is visible in the browser URL.
POST Method
Is an HTTP request method used to send data from the client (browser) to the server.
The data sent using ___ is not visible in the URL, making it more secure than GET.
This method is commonly used in login forms, registration forms, and other forms that handle sensitive data.
They are commonly used when submitting HTML forms.