Empowering Embedded Innovators to Shape the Future

๐Ÿ 1. Introduction to Python

Python is a high-level, interpreted programming language known for its readability and simplicity. It supports multiple paradigms including procedural, object-oriented, and functional programming.

๐Ÿ”ง Key Features:

- Easy syntax, close to English

- Large standard library

- Cross-platform compatibility

- Widely used in web development, data science, automation, AI, and embedded systems (via MicroPython)

๐Ÿš€ 2. Python Getting Started

To begin coding in Python:

- Install Python from python.org

- Use an IDE like VS Code, PyCharm, or Jupyter Notebook

- Run scripts via terminal or interactive shell

๐Ÿงช Example:

print("Hello, QSignal!")

โœ๏ธ 3. Python Syntax

Python uses indentation (whitespace) to define code blocks instead of braces {}.

๐Ÿงช Example:

if 5 > 2:

print("Five is greater than two!")

โœ… Indentation is mandatory. Improper spacing will raise an error.

๐Ÿ’ฌ 4. Python Comments

Comments help explain code and are ignored during execution.

๐Ÿงช Example:

# This is a single-line comment

print("Hello") # Inline comment

"""

This is a multi-line comment

or docstring used for documentation

"""

๐Ÿ“ฆ 5. Python Variables

Variables store data. Python is dynamically typedโ€”no need to declare types.

๐Ÿงช Example:

x = 10 # Integer

name = "Karthikeyan" # String

pi = 3.14 # Float

๐Ÿ”  6. Python Data Types

Common built-in types:

- int, float, str, bool

- list, tuple, dict, set

๐Ÿงช Example:

a = 5 # int

b = 3.14 # float

c = "QSignal" # str

d = True # bool

Use type() to check:

print(type(c)) # <class 'str'>

๐Ÿ”ข 7. Python Numbers

Python supports:

- int: whole numbers

- float: decimal numbers

- complex: imaginary numbers

๐Ÿงช Example:

x = 10

y = 3.5

z = 2 + 3j

Use int(), float() to convert types.

๐Ÿ”„ 8. Python Casting

Casting means converting one data type to another.

๐Ÿงช Example:

a = int("5") # Converts string to int

b = float(10) # Converts int to float

c = str(3.14) # Converts float to string

๐Ÿ”ค 9. Python Strings

Strings are sequences of characters enclosed in quotes.

๐Ÿงช Example:

text = "Hello, QSignal"

print(text[0]) # H

print(text[-1]) # l

print(text[0:5]) # Hello

print(len(text)) # Length

๐Ÿ”ง Common Methods:

text.upper(), text.lower(), text.strip(), text.replace(), text.split()

โœ… 10. Python Booleans

Booleans represent truth values: True or False.

๐Ÿงช Example:

a = True

b = False

print(5 > 3) # True

print(5 == 3) # False

Used in conditions and loops.

โž• 11. Python Operators

Operators perform operations on variables and values.

๐Ÿ”ง Types:

- Arithmetic: +, -, , /, %, *, //

- Comparison: ==, !=, >, <, >=, <=

- Logical: and, or, not

- Assignment: =, +=, -=, etc.

๐Ÿงช Example:

x = 5

y = 3

print(x + y) # 8

print(x > y and y < 4) # True

๐Ÿ“‹ 12. Python Lists

Lists are ordered, mutable collections.

๐Ÿงช Example:

fruits = ["apple", "banana", "cherry"]

print(fruits[1]) # banana

fruits.append("orange") # Add item

fruits.remove("apple") # Remove item

๐Ÿ”ง Useful Methods:

fruits.sort(), fruits.reverse(), fruits.insert(1, "grape")