Skip to content

Commit 86f2358

Browse files
committed
first draft
1 parent 4fea776 commit 86f2358

File tree

232 files changed

+7173
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

232 files changed

+7173
-2
lines changed

.gitignore

Lines changed: 479 additions & 0 deletions
Large diffs are not rendered by default.

LICENSE.md

Lines changed: 175 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,66 @@
1-
# programmingWithPythonSlides
2-
The slides to the book "Programming with Python"
1+
# Programming with Python
2+
3+
## 1. Introduction
4+
5+
*"Programming with Python"* is both a book and a course held at [Hefei University](http://www.hfuu.edu.cn/english/) ([合肥大学](http://www.hfuu.edu.cn/)).
6+
We here provide all the resources of this course.
7+
8+
The goal of the course and book is to teach undergraduate and graduate students how to program with the Python programming language.
9+
The resources may also be suitable to high school students or whoever else may be interested in the topic.
10+
Our aim is to strike a good balance between theory and practice, leaning more to the practice side.
11+
In particular, we try to teach programming together with some software engineering concepts.
12+
It is the firm opinion of the author that these two cannot be separated.
13+
Teaching programming alone without introducing tools such as static code analysis, unit tests, and enforcing principles such as code style and proper commenting will create bad programmers.
14+
So we discuss these aspects while working our way through the principles of programming.
15+
16+
17+
## 2. Resources
18+
The website with up-to-date information about the course is <https://thomasweise.github.io/programmingWithPython>.
19+
20+
### 2.1. The Book
21+
The book itself can be downloaded as pdf at <https://thomasweise.github.io/programmingWithPython/programmingWithPython.pdf>.
22+
23+
### 2.2. The Slides
24+
The slides for the course are available at <https://thomasweise.github.io/programmingWithPythonSlides> and also listed below.
25+
26+
1. [Introduction](https://thomasweise.github.io/programmingWithPythonSlides/01_introduction.pdf)
27+
2. [Getting Started](https://thomasweise.github.io/programmingWithPythonSlides/02_getting_started)
28+
29+
### 2.3. The Example Python Programs
30+
Our course offers a lot of examples.
31+
You can find all of them in the repository <https://github.com/thomasWeise/programmingWithPythonCode>.
32+
33+
34+
### 2.4. LaTeX Sources, Graphics, Bibliography, etc.
35+
Both the book and the slides are written in LaTeX.
36+
You can find their sources in <https://github.com/thomasWeise/programmingWithPython> and <https://github.com/thomasWeise/programmingWithPythonSlides>, respectively.
37+
You may use these files under the licensing terms provided below.
38+
39+
40+
## 3. License
41+
All the course material is freely available.
42+
You can download its newest version from <https://thomasweise.github.io/programmingWithPython>.
43+
This version may change since this course and book both are work in progress.
44+
You can freely share this.
45+
You can also copy text or figures under the license given below, as long as you cite the book as the original source, e.g., by using the following BibTeX:
46+
47+
<pre>@book{programmingWithPython,<br/>&nbsp;author&nbsp;=&nbsp;{<a href="http://iao.hfuu.edu.cn/5">Thomas&nbsp;Weise</a>},<br/>&nbsp;title&nbsp;=&nbsp;{Programming&nbsp;with&nbsp;Python},<br/>&nbsp;year&nbsp;=&nbsp;{2024},<br/>&nbsp;publisher&nbsp;=&nbsp;{<a href="http://iao.hfuu.edu.cn">Institute&nbsp;of&nbsp;Applied&nbsp;Optimization</a>,<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.hfuu.edu.cn/aibd">School&nbsp;of&nbsp;Artificial&nbsp;Intelligence&nbsp;and&nbsp;Big&nbsp;Data</a>,<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.hfuu.edu.cn/">Hefei&nbsp;University</a>},<br/>&nbsp;address&nbsp;=&nbsp;{Hefei,&nbsp;Anhui,&nbsp;China},<br/>&nbsp;url&nbsp;=&nbsp;{<a href="https://thomasweise.github.io/programmingWithPython">https://thomasweise.github.io/programmingWithPython</a>}<br/>}</pre>
48+
49+
**If you have any comments or suggestions regarding the book, or if you spotted an error or typo, please feel free to submit an [issue here](https://github.com/thomasWeise/programmingWithPython/issues).**
50+
Your feedback would help us to improve the book.
51+
52+
This book is released under the Attribution-NonCommercial-ShareAlike 4.0 International license (CC&nbsp;BY&#8209;NC&#8209;SA&nbsp;4.0), see [http://creativecommons.org/licenses/by-nc-sa/4.0/](http://creativecommons.org/licenses/by-nc-sa/4.0/) for a summary.
53+
54+
We statically include the [pdfsizeopt](https://github.com/pts/pdfsizeopt) tool in the [GitHub Repository](https://github.com/thomasWeise/programmingWithPython) of our book and use it during the book compiling and building process to compress the book pdf file.
55+
This tool is excluded from the license mentioned above.
56+
It is under the GNU GENERAL PUBLIC LICENSE Version 2, June 1991 and the copyright belongs to its authors.
57+
58+
59+
## 4. Contact
60+
If you have any questions or suggestions, please contact
61+
Prof. Dr. [Thomas Weise](http://iao.hfuu.edu.cn/5) (汤卫思教授)
62+
at the Institute of Applied Optimization (应用优化研究所, [IAO](http://iao.hfuu.edu.cn))
63+
of the School of Artificial Intelligence and Big Data ([人工智能与大数据学院](http://www.hfuu.edu.cn/aibd))
64+
of [Hefei University](http://www.hfuu.edu.cn/english/) ([合肥大学](http://www.hfuu.edu.cn/)),
65+
in Hefei, Anhui, China (中国安徽省合肥市)
66+
via email to [tweise@hfuu.edu.cn](mailto:tweise@hfuu.edu.cn) with CC to [tweise@ustc.edu.cn](mailto:tweise@ustc.edu.cn).

make.sh

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
3+
# Make the slides.
4+
5+
# strict error handling
6+
set -o pipefail # trace ERR through pipes
7+
set -o errtrace # trace ERR through 'time command' and other functions
8+
set -o nounset # set -u : exit the script if you try to use an uninitialized variable
9+
set -o errexit # set -e : exit the script if any statement returns a non-true return value
10+
11+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Welcome to the book building script."
12+
13+
currentDir="$(pwd)"
14+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): We are working in directory: '$currentDir'."
15+
scriptDir="$currentDir/shared/scripts"
16+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): The script directory is '$scriptDir'."
17+
18+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): We delete all left over data."
19+
websiteDir="$currentDir/website"
20+
rm -rf "$websiteDir" || true
21+
mkdir -p "$websiteDir"
22+
23+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): We setup a virtual environment in a temp directory."
24+
venvDir="$(mktemp -d)"
25+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Got temp dir '$venvDir', now creating environment in it."
26+
python3 -m venv --upgrade-deps --copies "$venvDir"
27+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Activating virtual environment in '$venvDir'."
28+
source "$venvDir/bin/activate"
29+
export PYTHON_INTERPRETER="$venvDir/bin/python3"
30+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Setting python interpreter to '$PYTHON_INTERPRETER'."
31+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): We install all required Python packages from requirements.txt to virtual environment in '$venvDir'."
32+
"$PYTHON_INTERPRETER" -m pip install --no-input --timeout 360 --retries 100 -r requirements.txt
33+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Finished installing the requirements, now printing all installed packages."
34+
pip freeze
35+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Finished printing all installed packages."
36+
37+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): We now build the slides."
38+
39+
slidesDir="$currentDir/slides"
40+
lastLatexGit=""
41+
for dirName in "$slidesDir/"*; do
42+
dirName="$(basename "$dirName")"
43+
theDir="$slidesDir/$dirName"
44+
if [ -d "$theDir" ]; then
45+
docName="$dirName.tex"
46+
if [ -f "$theDir/$docName" ]; then
47+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Found directory '$theDir' with document '$docName'."
48+
49+
curDirGit="$theDir/__git__"
50+
rm -rf "$curDirGit"
51+
if [ -n "$lastLatexGit" ]; then
52+
mv "$lastLatexGit" "$theDir"
53+
lastLatexGit=""
54+
fi
55+
56+
cd "$theDir"
57+
"$scriptDir/pdflatex.sh" "$docName"
58+
"$scriptDir/pdfsizeopt.sh" "$dirName.pdf" "$websiteDir/$dirName.pdf"
59+
rm "$dirName.pdf"
60+
61+
if [ -d "$curDirGit" ]; then
62+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Git directory is $curDirGit."
63+
lastLatexGit="$(realpath "$curDirGit")"
64+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Canonicalized git directory is $lastLatexGit."
65+
fi
66+
cd "$currentDir"
67+
else
68+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Found directory '$theDir', but it does not contain a corresponding LaTeX document."
69+
fi
70+
fi
71+
done
72+
73+
if [ -d "$lastLatexGit" ]; then
74+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Cleaning up '$lastLatexGit'."
75+
rm -rf "$lastLatexGit"
76+
fi
77+
78+
"$scriptDir/website.sh" "$websiteDir"
79+
80+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Deactivating virtual environment."
81+
deactivate
82+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Deleting virtual environment."
83+
rm -rf "$venvDir"
84+
85+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): We have finished the slides building process."

requirements.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# Dependencies Required to Build the Optimization Algorithms Book
3+
#
4+
5+
# Basically, we only need the `latexgit` Python companion package.
6+
# You can find it at https://thomasweise.github.io/latexgit_py,
7+
# https://github.com/thomasWeise/latexgit_py, or at
8+
# https://pypi.org/project/latexgit.
9+
latexgit == 0.8.25
10+
11+
# minify_html is needed to minify html output.
12+
minify_html == 0.15.0
13+
14+
# for converting the additional markdown files to HTML
15+
markdown == 3.7
16+
17+
# for converting files to HTML
18+
Pygments == 2.18.0

0 commit comments

Comments
 (0)