Skip to content

Commit 43e3004

Browse files
committed
first steps into data types
1 parent 5542043 commit 43e3004

File tree

8 files changed

+106
-2
lines changed

8 files changed

+106
-2
lines changed

bibliography/bibliography.bib

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ @string { a_zinoviev_dimitry
164164
@string { l_australia_hobart = "{{Hobart}, {TAS}, {Australia}}" }
165165
@string { l_portugal_lisbon = "{{Lisbon}, {Portugal}}" }
166166
@string { l_switzerland_cham = "{{Cham}, {Switzerland}}" }
167+
@string { l_switzerland_geneva = "{{Geneva}, {Switzerland}}" }
167168
@string { l_uk_birmingham = "{{Birmingham}, {England}, {UK}} " }
168169
@string { l_uk_cambridge = "{{Cambridge}, {England}, {UK}}" }
169170
@string { l_uk_chichester = "{{Chichester}, {West Sussex}, {England}, {UK}}" }
@@ -189,7 +190,10 @@ @string { p_cambridge_uni_press_ass
189190
@string { p_cnri = "{Corporation for National Research Initiatives~({CNRI})}" }
190191
@string { p_cornell_university_library = "{Cornell Universiy Library}" }
191192
@string { p_github = "{{GitHub} Inc}" }
193+
@string { p_iec = "{International Electrotechnical Commission~{(IEC)}}" }
192194
@string { p_ieee = "{Institute of Electrical and Electronics Engineers~{(IEEE)}}" }
195+
@string { p_iso = "{International Organization for Standardization~{(ISO)}}" }
196+
@string { p_iso_iec = "{International Organization for Standardization~{(ISO)} / International Electrotechnical Commission~{(IEC)}}" }
193197
@string { p_informs = "{The Institute for Operations Research and the Management Sciences~({INFORMS})}" }
194198
@string { p_mit_press = "{{MIT} Press}" }
195199
@string { p_oreilly = "{{O'Reilly} Media, Inc.}" }
@@ -210,13 +214,14 @@ @string { pa_cambridge_uni_press_ass
210214
@string { pa_cnri = l_usa_reston }
211215
@string { pa_cornell_university_library = l_usa_ithaca }
212216
@string { pa_github = l_usa_san_francisco }
217+
@string { pa_iso_iec = l_switzerland_geneva }
213218
@string { pa_ieee = l_usa_piscataway }
214219
@string { pa_informs = l_usa_catonsville }
215220
@string { pa_mit_press = l_usa_cambridge }
216221
@string { pa_oreilly = l_usa_sebastopol }
217222
@string { pa_packt = l_uk_birmingham }
218223
@string { pa_pearson_education = l_usa_hoboken }
219-
@string { pa_ploss = l_usa_san_francisco }
224+
@string { pa_plos = l_usa_san_francisco }
220225
@string { pa_microsoft_press = pa_pearson_education }
221226
@string { pa_springer_cham = l_switzerland_cham }
222227
@string { pa_springer_nature_limited = l_uk_london }
@@ -314,6 +319,12 @@ @xdata{rep_cnri_proposal
314319
type = {CNRI Proposal},
315320
}
316321

322+
@xdata{rep_iso_iec_standard,
323+
institution = p_iso_iec,
324+
address = pa_iso_iec,
325+
type = {International Standard},
326+
}
327+
317328

318329
%% series
319330
@xdata{ser_bs,
@@ -449,6 +460,15 @@ @article{HMvdWGVCWTBSKPHvKBHFdRWPGMSRWAGO2020APWN
449460
doi = {10.1038/S41586-020-2649-2},
450461
}
451462

463+
@techreport{ISOIEC207PLCWDOS,
464+
title = {Programming Languages -- \softwareStyle{C}, Working Document of~{SC22/WG14}},
465+
number = {{ISO/\linebreak{3}IEC9899:2017} {C17~ballot} {N2176}},
466+
xdata = {rep_iso_iec_standard},
467+
date = {2017-11},
468+
url = {https://files.lhmouse.com/standards/ISO%20C%20N2176.pdf},
469+
urldate = {2024-06-29},
470+
}
471+
452472
@book{LH2015DSAAWP,
453473
author = a_lee_kent_d # and # a_hubbard_steve,
454474
title = {Data Structures and Algorithms with \python},

notation/math.sty

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
%%%
2+
%%% Mathematical Notation
3+
%%%
4+
\protected\gdef\mathSpace#1{\ensuremath{\mathbb{#1}}}%
5+
%
6+
\newSymbol{realNumbers}{\mathSpace{R}}{R}{the set of the real numbers}%
7+
\newSymbol{integerNumbers}{\ensuremath{\mathSpace{Z}}}{Z}{the set of the integers numbers including positive and negative numbers and~0, i.e., {\dots}, -3, -2, -1, 0, 1, 2, 3, {\dots}, and so on}%
8+
%
9+
\protected\gdef\intRange#1#2{\ensuremath{#1..#2}}%
10+
%

notation/notation.sty

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
\RequirePackage{notation/sources}%
44
\RequirePackage{notation/terms}%
55
\RequirePackage{notation/acronyms}%
6+
\RequirePackage{notation/math}%
67
%

text/main/basics/basics.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
\end{itemize}%
99
%
1010
\hinput{gettingStarted}{gettingStarted.tex}%
11+
\hinput{simpleDataTypesAndOperations}{simpleDataTypesAndOperations.tex}%
1112
\endhsection%
1213
%

text/main/basics/gettingStarted/firstProgram/firstProgram.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
Indeed, the text \bashil{Hello World!} appears.
147147

148148
Well, before that text, we see the command line that was actually executed, namely the \python\ interpreter with our file's path as parameter.
149-
And after our program's output, we are notified that \inQuotes{Process finished with exit code 0,} which means that the program has completed successfully and without error.
149+
And after our program's output, we are notified that \inQuotes{Process finished with exit code~0,} which means that the program has completed successfully and without error.
150150

151151
Congratulations.
152152
You now have written, saved, and executed your first ever \python\ program!%
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
\hsection{Integers}%
2+
\label{sec:int}%
3+
%
4+
Integer arithmetic is the very first thing that you learn in mathematics in primary school.
5+
Integer arithmetic is also the very first thing you learn here.
6+
\emph{Integer} is a Latin word that means \inQuotes{whole} or \inQuotes{intact.}
7+
The integers include all whole numbers and negative numbers and zero, without fractions and decimals.
8+
9+
In many programming languages, there are different integer datatypes with different ranges.
10+
In \softwareStyle{Java}, a \pythonil{byte} is an integer datatype with range~\intRange{-2^7}{2^7-1}, a \pythonil{short} has range~\intRange{-2^{15}}{2^{17}-1}, an \pythonil{int} has range~\intRange{-2^{31}}{2^{31}-1}, and \pythonil{long} has range~\intRange{-2^{63}}{2^{63}-1}, for example.
11+
The draft for the \softwareStyle{C17} standard for the \softwareStyle{C}~programming language lists five signed and five unsigned integer types, plus several ways to extend them~\cite{ISOIEC207PLCWDOS}.
12+
%
13+
\endhsection%
14+
%
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
\hsection{Primitive Data Types and Operations}%
2+
%
3+
We now know how to create and run \python\ programs, both in the \pgls{IDE} and \pgls{terminal}.
4+
We have also already learned our first two \python\ commands:%
5+
%
6+
\begin{itemize}%
7+
\item \pythonil{print("Hello World!")} prints the text \inQuotes{Hello World!} to the output.
8+
\item \pythonil{exit()} exits and terminates the \python\ interpreter.%
9+
\end{itemize}%
10+
%
11+
Now, it would be very strange if the \pythonil{print} function could print \inQuotes{Hello World!}.
12+
That would not make much sense.
13+
\pythonil{print} expects one parameter.
14+
This parameter cannot just be anything.
15+
It must be a text.
16+
17+
The command \pythonil{exit}, on the other hand, can either have no parameter or one parameter.
18+
If it receives one parameter, this parameter will be the exit code of the program.
19+
Here, \pythonil{0} indicates success.
20+
If no parameter is provided, this will be used as default value.
21+
We need to invoke \pythonil{exit} if we use the \python\ console in the \pgls{terminal} explicitly.
22+
If we just run a program, then after the last instruction of the program was executed, then the interpreter will also terminate with exit code~0.
23+
Indeed, when we executed our first program in \cref{sec:ourFirstProgram}, we saw exactly that happen in \cref{fig:firstProgram09programResult}.
24+
Different from the parameter of \pythonil{print}, which must be some text, the parameter of \pythonil{exit} needs to be a number.
25+
26+
We realize:
27+
Distinguishing different types of data makes sense.
28+
Sometimes we need to do something with text.
29+
Sometimes we want to do something with numbers.
30+
Somtimes, we want to just handle a decision which can be either \inQuotes{yes} or \inQuotes{no}.
31+
32+
Of course, for these different situations, different possible operations may be useful.
33+
For example, when we use numbers, we may want to divide or multiply them.
34+
When we handle text, we may want to concatenate two portions of text, or maybe we want to convert lowercase characters to uppercase.
35+
We may want to do something if two decision variables are both \inQuotes{yes} or, maybe, if at least one of them is.
36+
37+
In this chapter, we will look into the simple datatypes of \python, namely:%
38+
%
39+
\begin{itemize}%
40+
%
41+
\item \pythonil{int}: the integer datatype, which represents integers numbers~\integerNumbers~(\cref{sec:int}),%
42+
\item \pythonil{float}: the floating point numbers, i.e., a subset of the real numbers~\realNumbers,%
43+
\item \pythonil{bool}: Boolean values, which can be either \pythonil{True} or \pythonil{False}, and%
44+
\item \pythonil{str}: strings, i.e., portions of text of arbitrary length.%
45+
\item \pythonil{None}: nothing, which is the result of any command that does not expliclty return a value.%
46+
%
47+
\end{itemize}%
48+
%
49+
\hinput{int}{int.tex}%
50+
%
51+
\endhsection%
52+
%
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
\hsection{Primitive Data Types and Operations}%
2+
%
3+
\hinput{introduction}{introduction.tex}%
4+
%
5+
\endhsection%
6+
%

0 commit comments

Comments
 (0)