Files
cmkiss/cmjs/articles/alice/programming/python-for-beginners.md
T
2026-08-23 21:54:17 +02:00

1.5 KiB

title, date, description, draft
title date description draft
Python for Beginners 2026-06-01 An introduction to Python programming with practical examples and clear explanations. false

Python is a high-level, general-purpose programming language known for its readable syntax and large standard library. It's a great first language.

Variables and types

Python is dynamically typed — you don't declare types explicitly:

name = "Alice"
age = 30
height = 1.72
is_admin = True

Control flow

Lorem ipsum dolor sit amet, consectetur adipiscing elit:

# Conditionals
if age >= 18:
    print("Adult")
elif age >= 13:
    print("Teenager")
else:
    print("Child")

# Loops
for i in range(5):
    print(i)

fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
    print(fruit)

Functions

Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua:

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

print(greet("Alice"))           # Hello, Alice!
print(greet("Bob", "Hi"))       # Hi, Bob!

Lists and dictionaries

# List — ordered, mutable
numbers = [3, 1, 4, 1, 5, 9]
numbers.append(2)
numbers.sort()

# Dictionary — key-value pairs
user = {
    "name": "Alice",
    "age": 30,
    "roles": ["admin", "editor"]
}
print(user["name"])   # Alice

Why Python?

  • Clean, readable syntax
  • Huge standard library
  • Active ecosystem (pip, PyPI)
  • Used in web, data science, automation, AI

Write code that is easy to read. You'll spend far more time reading code than writing it.