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

FileDescription
helloworld.pyBasic hello world example
indentation.pyDemonstration of Python indentation rules
dynamic-types.pyDynamic typing in Python
evaluate.pyBasic evaluation example
print_color.pyPrinting with color
string_format.pyString formatting techniques

Control Flow

FileDescription
decision.pyControl flow decision making
repetition.pyRepetition and loops
try-except.pyBasic exception handling
exception_try.pyAdvanced exception handling
raise_exception.pyRaising exceptions
switch_class.pyClass-based switch implementation
switch_func.pyFunction-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

FileDescription
functions.pyDefining and using functions
arguments.pyFunction arguments
call-back.pyCallback functions
closure.pyClosure implementation
fibonacci-function.pyFibonacci using functions
function-attributes.pyFunction attributes
generator.pyUsing generators
globals.pyUsing global variables
lambda.pyLambda functions
map-and-filter.pyMap and filter
namespace.pyUnderstanding namespaces
optional-argument.pyOptional arguments
parameters.pyFunction parameters
scope.pyVariable scope
varargs.pyVariable arguments

Data Structures

FileDescription
complex_collections.pyComplex collections
comprehension.pyList comprehension
data_types.pyCommon data types
deconstruction.pyData deconstruction
dictionary.pyDictionaries
dictionary_builder.pyDictionary builder
list_comprehension.pyList comprehension
record.pyRecord handling
set-operators.pySet operators
slices.pyData slicing
spreading.pyData spreading

Object Oriented Programming

FileDescription
abstraction.pyClass abstraction
attributes.pyClass attributes
class_dog.pyDog class example
class-person.pyPerson class example

I/O & Advanced

FileDescription
delete-file.pyDeleting files
file-read.pyReading files
file-write.pyWriting files
fetch-url.pyFetching URLs
json_dump.pyJSON dumping
json_load.pyJSON loading
mp-executor.pyMultiprocessing executor
parallel-mp.pyParallel processing