Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/A01_introduction/01_hello_world.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Hello World
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# This simple program prints "Hello world!" and performs a basic
# addition (1 + 1) to highlight Python's core syntax.

Expand Down
2 changes: 1 addition & 1 deletion examples/A01_introduction/02_print_function.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use the print() function to output text to the console.
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# The print() function is used to output data to the screen. It can take
# multiple arguments and will convert them to strings before printing them.

Expand Down
2 changes: 1 addition & 1 deletion examples/A01_introduction/03_statements.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use statements to perform actions in Python.
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# A statement is a piece of code that performs an action. It can be as simple
# as a single line or a more complex block of code. The following is true
# for all statements:
Expand Down
2 changes: 1 addition & 1 deletion examples/A01_introduction/04_expressions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use expressions to evaluate values in Python.
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# An expression is anything that evaluates to a value. The following is true
# for all expressions:
#
Expand Down
2 changes: 1 addition & 1 deletion examples/A01_introduction/05_modules.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use import to access Python code from other files.
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# A module is a file containing Python code. It can define functions,
# classes, and variables that you can use in your code. You can import a
# module using the `import` statement.
Expand Down
2 changes: 1 addition & 1 deletion examples/A01_introduction/06_zen_of_python.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Import the `this` module to print the Zen of Python
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# This is a fun Easter egg in Python that prints the Zen of Python, the
# guiding principles for writing computer programs in Python. It emphasizes
# simplicity, readability, and the importance of explicitness in code design.
Expand Down
2 changes: 1 addition & 1 deletion examples/A02_variables/01_problem_without_variables.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Problem without variables
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# This example explains why variables are useful. Without them we would
# repeat the same value throughout the code and update each occurrence
# manually. Imagine printing "Hello world" 1000 times and later wanting
Expand Down
2 changes: 1 addition & 1 deletion examples/A02_variables/02_solution_with_variables.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Solution: Variables as containers for data
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# This code uses a variable as a container for data. The variable `text`
# stores a string value that can be reused multiple times, illustrating how
# variables allow you to store and manipulate data efficiently.
Expand Down
2 changes: 1 addition & 1 deletion examples/A02_variables/03_integer_numbers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Integer numbers
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# The integer type in Python is used to represent whole numbers, both
# positive and negative. Python supports various bases for integers,
# including decimal, binary, octal, and hexadecimal.
Expand Down
2 changes: 1 addition & 1 deletion examples/A02_variables/04_real_numbers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Real numbers
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Floating point numbers are used to represent real numbers and can be defined
# in standard decimal format or scientific notation. Python's `float` type is
# based on the IEEE 754 double-precision floating-point format, which provides
Expand Down
2 changes: 1 addition & 1 deletion examples/A02_variables/05_complex_numbers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Complex numbers
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# This code creates and manipulates complex numbers in Python. A complex
# number is written as `a + bj`, where `a` is the real part and `b` is the
# imaginary part.
Expand Down
2 changes: 1 addition & 1 deletion examples/A02_variables/06_boolean_numbers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Boolean numbers
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# This example uses boolean variables to represent truth values—either
# `True` or `False`. Such variables are often part of conditional
# statements and logical operations.
Expand Down
2 changes: 1 addition & 1 deletion examples/A02_variables/07_list_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# List data
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# The list type in Python is used to represent a collection of items. It is
# important to note that lists are passed by reference (see mutability in
# examples). When you assign a list to another variable, both variables point
Expand Down
2 changes: 1 addition & 1 deletion examples/A02_variables/08_tuple_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Tuple data
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# A tuple is very similar to a list that is immutable, meaning it cannot be
# changed after creation. Their main advantage is the memory efficiency
# and performance benefits they provide over lists, especially when dealing
Expand Down
2 changes: 1 addition & 1 deletion examples/A02_variables/09_set_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Set data
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# The set type in Python is a collection of elements with unique values. It
# used to remove duplicates from a collection and to perform set operations like
# union, intersection, and difference. The set type has the following
Expand Down
2 changes: 1 addition & 1 deletion examples/A02_variables/10_dictionary_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Dictionary data
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# This code creates and manipulates dictionaries in Python. A dictionary is
# a collection of key–value pairs where each key is unique. If a key
# appears more than once, the last assigned value is retained. The
Expand Down
2 changes: 1 addition & 1 deletion examples/A02_variables/11_string_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# String data
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# String variables in Python can be defined using single or double quotes.
# Both types of quotes are valid and can be used interchangeably. The string
# has the following characteristics:
Expand Down
2 changes: 1 addition & 1 deletion examples/A02_variables/12_none_type.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# None
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# The None type in Python is used to show that the variable is not assigned
# any value. It is useful when you want to indicate that a variable is
# intentionally left empty or when a function does not return a value, e.g.
Expand Down
2 changes: 1 addition & 1 deletion examples/A02_variables/13_mutable_variables.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Mutable variables in Python
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Some variables in Python are mutable, meaning their value can be changed after
# they are created allowing you to dynamic modification of their contents. The
# most common mutable variable types in Python are lists, dictionaries, and
Expand Down
2 changes: 1 addition & 1 deletion examples/A02_variables/14_immutable_variables.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Immutable variables in Python
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Some variables in Python are immutable, meaning their value cannot be changed
# after they are created. This is in contrast to mutable variables, which can
# be modified after creation.
Expand Down
2 changes: 1 addition & 1 deletion examples/A02_variables/15_get_variable_type.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Get the type of a variable
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Python offers a way to inspect the type of a variable using `type()`. Type
# is a special class in Python that servers many purposes, including
# determining the type of a variable. When invoked on a variable, it returns
Expand Down
2 changes: 1 addition & 1 deletion examples/A03_comments/01_single_line_comments.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Single-line comments in Python
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# A single-line comment in Python starts with a hash symbol (#).

# This code will print junior message and the sum of two numbers
Expand Down
2 changes: 1 addition & 1 deletion examples/A03_comments/02_multi_line_comments.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Multi-line comments in Python
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Multi-line comments in Python can be created using triple quotes.

"""
Expand Down
2 changes: 1 addition & 1 deletion examples/A04_operators/01_arithmetic_operatos.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Arithmetic Operators in Python
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Arithmetic operators are used to perform mathematical operations on
# numeric values. In Python, these operators include addition, subtraction,
# multiplication, division, floor division, modulus, and exponentiation.
Expand Down
2 changes: 1 addition & 1 deletion examples/A04_operators/02_comparison_operators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Comparison Operators in Python
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Comparison operators are used to compare two values. They return a boolean
# value (True or False) based on the comparison.

Expand Down
2 changes: 1 addition & 1 deletion examples/A04_operators/03_boolean_operators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Boolean Operators in Python
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Boolean operators evaluate expressions to produce a boolean value, meaning
# either `True` or `False`.
#
Expand Down
2 changes: 1 addition & 1 deletion examples/A04_operators/04_identity_operators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Identity Operators in Python
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Identity operators are used to compare the memory locations of two objects.
# If two variables point to the same object in memory, they are considered
# identical.
Expand Down
2 changes: 1 addition & 1 deletion examples/A04_operators/05_membership_operators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Membership Operators in Python
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Membership operators are used to test whether a value is a member of a
# sequence (e.g., a list, tuple, or string).

Expand Down
2 changes: 1 addition & 1 deletion examples/A04_operators/06_bitwise_operators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Bitwise Operators in Python
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Bitwise operators are used to perform bit-level operations on integers. These
# operators directly manipulate the binary representations of numbers. Each bit
# is calculated independently, based on the truth table of the operation.
Expand Down
2 changes: 1 addition & 1 deletion examples/A04_operators/07_assignment_operators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Assignment Operators
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Assignment operators are used to assign values to variables and can also
# perform operations on those values.
#
Expand Down
2 changes: 1 addition & 1 deletion examples/A04_operators/08_conditional_operators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Conditional Expressions in Python
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Conditional expressions allow you to evaluate a condition and return one
# of two values based on the result of the condition.
#
Expand Down
2 changes: 1 addition & 1 deletion examples/A04_operators/09_list_operators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Common list operators in Python
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# This file contains examples of the most commonly used operators on lists,
# including indexing, slicing, concatenation, repetition, and membership tests.

Expand Down
2 changes: 1 addition & 1 deletion examples/A04_operators/10_tuple_operators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Tuple Operators in Python
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# This example demonstrates common tuple operations including indexing,
# slicing, concatenation, repetition, and membership tests.

Expand Down
2 changes: 1 addition & 1 deletion examples/A04_operators/11_set_operators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Set Operators in Python
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Demonstrates fundamental set operations including union, intersection,
# difference, symmetric difference, and subset/superset checks.

Expand Down
2 changes: 1 addition & 1 deletion examples/A04_operators/12_dict_operators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Merging and updating dictionaries
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Python 3.9 introduced the | and |= operators to combine dictionaries. The |
# operator creates a new dictionary containing keys from both operands, while
# |= updates the dictionary on the left in place. This provides a concise
Expand Down
2 changes: 1 addition & 1 deletion examples/A05_user_input/01_user_input_python3.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# User Input in Python 3
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Use `input()` to get input from the user, which returns a string. Use `eval()`
# to evaluate the input as a Python expression, or `int()` to convert it to
# an integer.
Expand Down
2 changes: 1 addition & 1 deletion examples/A05_user_input/02_user_input_python2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# User Input in Python 2
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Use `input()` to execute the input as Python code, or `raw_input()` to get a
# string input. Please not that this example works in Python 2.x only.

Expand Down
2 changes: 1 addition & 1 deletion examples/A05_user_input/03_user_input_with_six.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Cross-Version User Input with six
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# If the code needs to work in both Python 2 and 3, you can use the `six`
# library to handle user input.

Expand Down
2 changes: 1 addition & 1 deletion examples/A06_strings/01_string_length.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Calculate the length of a string
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# This snippet calculates the number of characters in a string. The
# result differs from the byte length when the string contains UTF-8
# characters that use multiple bytes.
Expand Down
2 changes: 1 addition & 1 deletion examples/A06_strings/02_string_concatenation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# String concatenation example
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# This code concatenates (joins) strings using the `+` operator. This
# technique is common when constructing messages or combining text from
# different sources.
Expand Down
2 changes: 1 addition & 1 deletion examples/A06_strings/03_string_interpolation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# String interpolation
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# This code uses f-strings (formatted string literals) to create strings
# that include variables. Expressions inside curly braces `{}` are
# evaluated in place.
Expand Down
2 changes: 1 addition & 1 deletion examples/A06_strings/04_string_escaping.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Escape sequences in Python strings
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# This example uses escape sequences in strings so you can include
# characters that would otherwise be difficult or impossible to type
# directly.
Expand Down
2 changes: 1 addition & 1 deletion examples/A06_strings/05_string_indexing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# String indexing
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# This code accesses individual characters in a string by index. Strings are
# sequences of characters, so index 0 refers to the first character, and
# negative indices let you read characters from the end of the string.
Expand Down
2 changes: 1 addition & 1 deletion examples/A06_strings/06_string_slicing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# String slicing
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# This code slices strings in Python. Slicing extracts a portion of a string
# by specifying a start index, an end index, and an optional step using
# the syntax `string[start:end:step]`.
Expand Down
2 changes: 1 addition & 1 deletion examples/A06_strings/07_string_splitting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Splitting Strings
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# The `split()` method is used to split a string into a list of tokens based
# on a specified separator. If no separator is provided, it defaults to
# whitespace. The `splitlines()` method is used to split a string into a
Expand Down
2 changes: 1 addition & 1 deletion examples/A06_strings/08_string_joining.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# String joining
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# The `join()` method is a string method that takes an iterable (like a list)
# and concatenates its elements into a single string, with a specified separator
# between each element. If no separator is provided, it defaults to an empty
Expand Down
2 changes: 1 addition & 1 deletion examples/A06_strings/09_string_case.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# String case manipulation examples
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# This code applies various string case manipulation methods in Python.

# Store the string to be manipulated
Expand Down
2 changes: 1 addition & 1 deletion examples/A07_control_flow/01_if_statement.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Conditional logic using `if`, `elif`, and `else` to handle different cases based on conditions.
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# The conditional statements in Python allow you to control the flow of your
# program based on certain conditions. This way we can execute different
# blocks of code depending on the condition that is met.
Expand Down
2 changes: 1 addition & 1 deletion examples/A07_control_flow/02_for_statement.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Iterating over sequences using `for` loops.
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Loops that use the `for` statement to iterate over a sequence or other
# iterable objects are useful for executing a block of code a fixed number of
# times (we know the number of iterations in advance).
Expand Down
2 changes: 1 addition & 1 deletion examples/A07_control_flow/03_while_statement.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Repeating code with `while` loops until a condition is met.
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Loops that use the `while` statement to repeat a block of code as long as a
# condition is true. This is useful when the number of iterations is not known
# beforehand, and the loop continues until a specific condition is met.
Expand Down
2 changes: 1 addition & 1 deletion examples/A07_control_flow/04_break_statement.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Exiting loops prematurely with the `break` statement.
# --------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# The `break` statement is used to exit a loop prematurely. It can be used in
# both `for` and `while` loops. When the `break` statement is encountered,
# the loop is terminated immediately, and control is transferred to the next
Expand Down
Loading