Learn Python

Python Basics

Learn Python programming step by step.

Introduction to Python

Python is a versatile programming language that is easy to learn and widely used for various applications.

def greet(name):
    return f"Hello, {name}!"

print(greet("World"))

Variables and Data Types

In Python, you can create variables to store data. Here are some common data types:

  • Integer: Whole numbers
  • Float: Decimal numbers
  • String: Text data
age = 30
height = 5.9
name = "Alice"

print(f"Name: {name}, Age: {age}, Height: {height}")

Control Structures

Python includes control structures like loops and conditionals. Here's an example of a simple if statement.

if age >= 18:
    print("You are an adult.")
else:
    print("You are a minor.")

Functions

Functions allow you to encapsulate code for reuse. Here’s an example of a function that calculates the area of a rectangle.

def area_of_rectangle(length, width):
    return length * width

print(area_of_rectangle(5, 3))

Introduction to LaTeX

LaTeX is a typesetting system that is widely used for mathematical and scientific documents.

Quadratic Formula: x=b±b24ac2a\text{Quadratic Formula: } x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

Example of a Quadratic Equation

Let's solve a quadratic equation using the formula.

For example: 2x2+3x2=0\text{For example: } 2x^2 + 3x - 2 = 0

Conclusion

Python is a powerful tool for programming, and learning its basics is the first step towards mastering it.