Python Demo Examples
The examples below are ready for study. Please note that these demos are read-only in the viewer. You are encouraged to download them to your local environment, where you can modify, experiment, and run the code to deepen your understanding of Python programming.
Basics
| File | Description |
|---|---|
| helloworld.py | Basic hello world example |
| indentation.py | Demonstration of Python indentation rules |
| dynamic-types.py | Dynamic typing in Python |
| evaluate.py | Basic evaluation example |
| print_color.py | Printing with color |
| string_format.py | String formatting techniques |
Control Flow
| File | Description |
|---|---|
| decision.py | Control flow decision making |
| repetition.py | Repetition and loops |
| try-except.py | Basic exception handling |
| exception_try.py | Advanced exception handling |
| raise_exception.py | Raising exceptions |
| switch_class.py | Class-based switch implementation |
| switch_func.py | Function-based switch implementation |
The examples below are ready for study. Please note that these demos are read-only in the viewer. You are encouraged to download them to your local environment, where you can modify, experiment, and run the code to deepen your understanding of Python programming.
Functions & Scope
| File | Description |
|---|---|
| functions.py | Defining and using functions |
| arguments.py | Function arguments |
| call-back.py | Callback functions |
| closure.py | Closure implementation |
| fibonacci-function.py | Fibonacci using functions |
| function-attributes.py | Function attributes |
| generator.py | Using generators |
| globals.py | Using global variables |
| lambda.py | Lambda functions |
| map-and-filter.py | Map and filter |
| namespace.py | Understanding namespaces |
| optional-argument.py | Optional arguments |
| parameters.py | Function parameters |
| scope.py | Variable scope |
| varargs.py | Variable arguments |
Data Structures
| File | Description |
|---|---|
| complex_collections.py | Complex collections |
| comprehension.py | List comprehension |
| data_types.py | Common data types |
| deconstruction.py | Data deconstruction |
| dictionary.py | Dictionaries |
| dictionary_builder.py | Dictionary builder |
| list_comprehension.py | List comprehension |
| record.py | Record handling |
| set-operators.py | Set operators |
| slices.py | Data slicing |
| spreading.py | Data spreading |
Object Oriented Programming
| File | Description |
|---|---|
| abstraction.py | Class abstraction |
| attributes.py | Class attributes |
| class_dog.py | Dog class example |
| class-person.py | Person class example |
I/O & Advanced
| File | Description |
|---|---|
| delete-file.py | Deleting files |
| file-read.py | Reading files |
| file-write.py | Writing files |
| fetch-url.py | Fetching URLs |
| json_dump.py | JSON dumping |
| json_load.py | JSON loading |
| mp-executor.py | Multiprocessing executor |
| parallel-mp.py | Parallel processing |