Feel free to use this repository as template for practical python examples. The try to cover a few basic topics:
- loops
- if-statements
- functions
- unit tests (to verify the code)
simply call python unittests.py
from a command line of your choice
do not forget to mark the samples
directory as sources root!
many of the python scripts have a run()
method that runs the commandline program. On the shell of your choice execute the following steps:
python
>>> import binary
>>> binary.run()
This will call the (very simple) CLI.
Contains a function to_binary
that converts an integer into its binary representation (str
).
Contains a function calc_factorial
that computes the factorial for any given positive integer N
.
Contains a function checking if a given number is a prime.
Computes all prime numbers up to a given upper limit.
contains a small program reading input from stdin
along some basic error handling.
that this repository serves the sole purpose of demonstrating very basic semantic concepts to an audience with little to no programming knowledge. I know very well that in production software one would do things differently, but for the sake of clarity much of the usual project setup has been ditched.