Commit 5c1bfd3c authored by Raffaele Grosso's avatar Raffaele Grosso
Browse files

Add exercise sheet in english

parent 9e5ab29b
......@@ -8,3 +8,6 @@
# Editor backups
*~
*.swp
# notebook
.ipynb*
......@@ -2,10 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"metadata": {},
"source": [
"### Aufgabe 1 b)\n",
"In Python 2 benutze raw_input für Strings und input für Integers, in Python 3 input und eval(input)"
......@@ -15,9 +12,7 @@
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": true,
"deletable": true,
"editable": true
"collapsed": true
},
"outputs": [
{
......@@ -55,10 +50,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"metadata": {},
"source": [
"### Aufgabe 2 a)"
]
......@@ -67,9 +59,7 @@
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true,
"deletable": true,
"editable": true
"collapsed": true
},
"outputs": [],
"source": [
......@@ -84,10 +74,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"metadata": {},
"source": [
"### Aufgabe 2 b)"
]
......@@ -96,9 +83,7 @@
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": true,
"deletable": true,
"editable": true
"collapsed": true
},
"outputs": [
{
......@@ -118,10 +103,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"metadata": {},
"source": [
"### Aufgabe 2 c), d)"
]
......@@ -129,11 +111,7 @@
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"metadata": {},
"outputs": [
{
"name": "stdout",
......@@ -153,10 +131,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"metadata": {},
"source": [
"### Aufgabe 2 e)"
]
......@@ -164,11 +139,7 @@
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"metadata": {},
"outputs": [
{
"name": "stdout",
......@@ -195,10 +166,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"metadata": {},
"source": [
"### Aufgabe 3 a)"
]
......@@ -206,11 +174,7 @@
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"metadata": {},
"outputs": [
{
"name": "stdout",
......@@ -272,10 +236,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"metadata": {},
"source": [
"### Aufgabe 4 a)"
]
......@@ -283,11 +244,7 @@
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"metadata": {},
"outputs": [],
"source": [
"in_file_str = \"sampletext.txt\"\n",
......@@ -307,10 +264,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"metadata": {},
"source": [
"### Aufgabe 4 b)"
]
......@@ -318,11 +272,7 @@
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"metadata": {},
"outputs": [
{
"name": "stdout",
......@@ -360,11 +310,7 @@
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"metadata": {},
"outputs": [
{
"name": "stdout",
......@@ -380,10 +326,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"metadata": {},
"source": [
"### Aufgabe 5 a)"
]
......@@ -391,11 +334,7 @@
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"metadata": {},
"outputs": [
{
"data": {
......@@ -433,10 +372,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"metadata": {},
"source": [
"### Aufgabe 6 a)"
]
......@@ -444,11 +380,7 @@
{
"cell_type": "code",
"execution_count": 28,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"metadata": {},
"outputs": [
{
"name": "stdout",
......@@ -497,9 +429,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"deletable": true,
"editable": true
"collapsed": true
},
"outputs": [],
"source": []
......@@ -514,14 +444,14 @@
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
......
......@@ -37,8 +37,8 @@
\begin{enumerate}[label=\textbf{\alph*)}]
\item Schreibe ein Programm, welches zehn Zahlen, welche vom Terminal eingegeben werden, in eine Liste packt und alle geraden Zahlen aus dieser Liste ausgibt.
\Hinweis{``\textit{list comprehension}'' benutzen.}
\item Schreibe ein Programm, welches die Worte eines Satz, der im Terminal eingegeben wird, in umgekehrter Reihenfolge wieder ausgibt. \Hinweis{Benutze \texttt{[::-1]} als besondere ``\textit{extended slice syntax}''}
\\ \Hinweis{``\textit{Das ist ein Haus.}'' wird zu ``\textit{Haus ein ist Das.}''}.
\item Schreibe ein Programm, welches die Worte eines Satzes, der im Terminal eingegeben wird, in umgekehrter Reihenfolge wieder ausgibt. \Hinweis{Benutze \texttt{[::-1]} als besondere ``\textit{extended slice syntax}''. Alternativ die \texttt{reverse}-Funktion von der Liste.}
\\ {\color{Blue} Beispiel:} ``\textit{Das ist ein Haus.}'' wird zu ``\textit{Haus ein ist Das.}''
\item Schreibe ein Programm, welches alle Worte eines Satzes, der im Terminal eingegeben wird, in umgekehrter alphabetischer Ordnung ausgibt.
\item Wie in der vorherigen Übung, aber Groß- und Kleinschreibung werden nicht unterschieden. \Hinweis{\texttt{sort} oder \texttt{sorted} können als ``\texttt{key=}'' Argument eine Lambda-Funktion gegeben werden \ldots}
\item Schreibe ein Programm, welches ein Schlüsselwert-Verzeichnis (\textit{dictionary}) mit z.B. zehn Name => Geburtsmonate Schlüssel-Wert-Paaren enthält. Das Programm
......
\documentclass[10pt,a4paper]{letter}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
%\usepackage{amsmath}
\usepackage{enumitem}
\usepackage[margin=4.2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{relsize}
\newcommand{\Hint}[1]{{\color{Blue} Hint:} #1}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\rhead{\thepage}
\lhead{Python Exercises for Trainees}
\newcounter{ChapterCounter}
\newcommand{\Chapter}[1]{\refstepcounter{ChapterCounter}\textbf{\theChapterCounter. #1 \label{#1}}}
\begin{document}
\Chapter{Hello World and basic I/O}
\begin{enumerate}[label=\textbf{\alph*)}]
\item Write a Hello World program, that is a program that just writes: \texttt{"Hello World!"}
\item Write a program which asks the user its name and birth year and then writes the following text: \texttt{"Hi NAME, you will become X years old this year."}.
\end{enumerate}
\Chapter{Lists}
\begin{enumerate}[label=\textbf{\alph*)}]
\item Write a program that fills a list with ten integers taken as input from the terminal and returns only the even ones.
\Hint{``Use a \textit{list comprehension}''}
\item Write a program which returns in reversed order the words of a sentence received as input. \Hint{Use the ``\textit{extended slice syntax}'' \texttt{[::-1]}. Alternatively use the \texttt{reverse} function of a list object.}
\\ {\color{Blue} Example:} ``\textit{I like this color}'' should give ``\textit{color this like I}''
\item \label{1} Write a program which returns in alphabetical order the words of a sentence received as input.
\\ {\color{Blue} Example:} the example above should give ``\textit{I color like this}''
\end{enumerate}
\Chapter{Dictionaries}
\begin{enumerate}[label=\textbf{\alph*)}]
\item Write a program filling a dictionary with ten name-birthday pairs requested as input and printing out the month of birth for the names chosen by the user.
\end{enumerate}
\Chapter{Conditions}
\begin{enumerate}[label=\textbf{\alph*)}]
\item Write a ``guess the number'' game: the user guesses an integer between 1 and 10 until he/she enters "exit" or until she gets the right number.
\end{enumerate}
\Chapter{File I/O}
\begin{enumerate}[label=\textbf{\alph*)}]
\item Write a program reading a text from a file and writing it to a second file after replacing newlines with spaces. The two file names are to be given as input.
\item Now the program should fill a dictionary with key-value pairs read from a first json file and write them to a second json file after having added or replaced a few entries according to input given by the user.
\end{enumerate}
\Chapter{Functions}
\begin{enumerate}[label=\textbf{\alph*)}]
\item Write a program which, by means of a function, prints out a sketched chessboard: the first, last and all odd lines are a sequence of dashes while the even lines are a sequence of spaced vertical bars.
\end{enumerate}
Lambda functions:
\begin{enumerate}[label=\textbf{\alph*)}]
\item Like in exercise \ref{Lists}.\ref{1} but with case insensitive order. \Hint{You can pass a lambda function as ``\texttt{key=}'' argument of \texttt{sort} or \texttt{sorted} e ``\texttt{key=}''}
\\ {\color{Blue} Example:} ``\textit{I like this color}'' should give ``\textit{color I like this}''
\end{enumerate}
\Chapter{Classes and Objects}
\Chapter{Plots and Histograms}
\begin{enumerate}[label=\textbf{\alph*)}]
\item Plot an histogramm with the distribution of births per month from Exercise \ref{Dictionaries}.
\end{enumerate}
\end{document}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment