-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
94 changed files
with
1,226 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
%%& -job-name=Aufgaben1_16WS_v1 | ||
\documentclass[accentcolor=tud3c,colorbacktitle,12pt]{tudexercise} | ||
\usepackage[T1]{fontenc} | ||
%\usepackage[utf8]{inputenc} | ||
%\usepackage[ngerman]{babel} | ||
\input{../shared/globalCommon} | ||
\usepackage{hyperref} | ||
\usepackage{ifthen} | ||
\usepackage{listings} | ||
%\usepackage{graphicx} | ||
\usepackage{multicol} | ||
\usepackage{multirow} | ||
|
||
|
||
\definecolor{darkblue}{rgb}{0,0,.5} | ||
\hypersetup{colorlinks=true, breaklinks=true, linkcolor=darkblue, menucolor=darkblue, urlcolor=darkblue} | ||
|
||
% configuration | ||
\makeatletter | ||
\@ifundefined{c@ex}{ | ||
\newcounter{ex}\setcounter{ex}{1} | ||
}{} | ||
\makeatother | ||
\newboolean{sln}\setboolean{sln}{false} | ||
\newboolean{SoSe}\setboolean{SoSe}{false} | ||
\newcounter{nextyear}\setcounter{nextyear}{\year+1} | ||
% | ||
|
||
\newcommand{\ext}{py} | ||
\newcommand{\sln}[1]{\ifthenelse{\boolean{sln}}{\subsubsection*{Antwort}{\itshape #1}}{}} | ||
\newcommand{\slnformat}[1]{\ifthenelse{\boolean{sln}}{#1}{}} | ||
\newcommand{\taskformat}[1]{\ifthenelse{\boolean{sln}}{}{#1}} | ||
\newcommand{\task}[1]{\input{task/#1}\IfFileExists{./sln/#1.tex}{\sln{\input{sln/#1}}}{\IfFileExists{./sln/#1.\ext}{\sln{\pythonfile{sln/#1.\ext}}}{\ClassError{Vorkurs-TeX}{No solution specified for task #1}{Add solution file #1.tex or #1.\ext}}}} | ||
\newcommand{\mccmd}{Kreuze zu jeder Antwort an, ob sie zutrifft (\textbf{w}) oder nicht (\textbf{f}).} | ||
\newcommand{\mchead}{\item[\textbf{w} \textbf{f} ]} | ||
\newcommand{\mcitem}[1]{\item[$\square\ \square$] #1} | ||
\newcommand{\mcitemt}[1]{\item[$\ifthenelse{\boolean{sln}}{\blacksquare}{\square}\ \square$] #1} | ||
\newcommand{\mcitemf}[1]{\item[$\square\ \ifthenelse{\boolean{sln}}{\blacksquare}{\square}$] #1} | ||
\newcommand{\ptitle}{\ifthenelse{\boolean{SoSe}}{Sommersemester \the\year}{Wintersemester \the\year/\thenextyear}} | ||
|
||
\newcommand{\lstinlinenoit}[1]{\upshape{\lstinline|#1|}\itshape} | ||
\lstset{language=Python, basicstyle=\ttfamily\small, keywordstyle=\color{blue!80!black}, identifierstyle=, commentstyle=\color{green!50!black}, stringstyle=\ttfamily, | ||
tabsize=4, breaklines=true, numbers=left, numberstyle=\small, frame=single, backgroundcolor=\color{blue!3}} | ||
\author{Fachschaft Informatik} | ||
|
||
|
||
\newcommand{\stage}[1]{(\ifcase#1\or{Einstieg}\or{Vertiefung}\or{Herausforderung}\else\fi)} | ||
\newcommand{\bonus}[1]{\textit{BonusFact: }#1} | ||
|
||
\begin{document} | ||
\title{Aufgaben Programmiervorkurs\\Übungsblatt \theex} | ||
\subtitle{von der Fachschaft Informatik\hfill\ptitle} | ||
\maketitle | ||
|
||
\ifcase\value{ex} | ||
\or%ex1 | ||
\section{Einleitung \stage1} | ||
\task{1-intro} | ||
\task{1-mc-interpreter}\taskformat{\clearpage} | ||
\section{Ausdrücke \stage1} | ||
\task{1-interactive} | ||
\task{1-operations}\taskformat{\clearpage}\slnformat{\clearpage} | ||
\section{Konvertierung \stage2} | ||
\task{1-conversion} | ||
\task{1-conv-challenge}\slnformat{\clearpage} | ||
\section{Fehler} | ||
\task{1-error} | ||
\task{1-warmup-error} | ||
\section{Challenge} | ||
\task{1-modulo} | ||
\or%ex2 | ||
\task{2-pyfile} | ||
\section{Zum Aufwärmen \stage1}\mccmd | ||
\task{2-mc-if} | ||
\section{Variablen \stage1} | ||
\task{2-var-case}\slnformat{\clearpage} | ||
\task{2-var-id}\taskformat{\clearpage} | ||
\task{2-var-assign}\slnformat{\clearpage} | ||
\section{Logische Operationen \stage1} | ||
\task{2-stm-ops}\taskformat{\clearpage} | ||
\section{Eingabe/Ausgabe \stage2} | ||
\task{2-var-io} | ||
\task{2-stm-calc}\taskformat{\clearpage}\slnformat{\clearpage} | ||
\section{Zum Weiterdenken \stage3} | ||
\task{2-cooking}\taskformat{\clearpage}\slnformat{\clearpage} | ||
\task{2-var-processor} | ||
\or%ex3 | ||
\section{Schleifen} | ||
\task{3-loop-gauss} | ||
\task{3-loop-fac} | ||
\task{3-loop-fizz}\taskformat{\clearpage}\slnformat{\clearpage} | ||
\task{3-loop-prime}\slnformat{\clearpage} | ||
\section{Listige Listen} | ||
\task{3-list-basic} | ||
\task{3-list-len} | ||
\section{Fortgeschrittenes Lesen} | ||
\task{3-slicing} | ||
\task{3-slicing-examples}\slnformat{\clearpage} | ||
\section{Listenverarbeitung} | ||
\task{3-iterable} | ||
\task{3-text-slicing}\slnformat{\clearpage} | ||
\task{3-accumulator} | ||
\section{Challenge} | ||
\task{3-challenge} | ||
\or%ex4 | ||
\section{Funktionen} | ||
\task{4-fnc-calcr}\slnformat{\clearpage} | ||
\task{4-fnc-calcr2}\slnformat{\clearpage} | ||
\section{Schriftliches Dividieren} | ||
\task{4-fnc-divide-theory}\slnformat{\clearpage} | ||
\task{4-fnc-divide-basic}\slnformat{\clearpage} | ||
\task{4-fnc-divide-advanced}\slnformat{\clearpage} | ||
\section{Listen und Funktionen} | ||
\task{4-list-fnc}\slnformat{\clearpage} | ||
\section{Rekursion} | ||
\task{4-rec-fac} | ||
\task{4-rec-pascal}\slnformat{\clearpage} | ||
\task{4-rec-fib}\slnformat{\clearpage} | ||
\task{4-rec-oddeven}\slnformat{\clearpage} | ||
\task{4-rec-calcu}\taskformat{\clearpage} | ||
\task{4-rec-calcu2} | ||
\section{Zusatz} | ||
Wenn du die Aufgaben erledigt hast, kannst du dich gerne noch an den Schleifen-Varianten der gegebenen Algorithmen versuchen oder für Aufgaben der vergangenen Tage eine rekursive Lösung suchen. Die Tutoren stehen dir dabei gerne bei, allerdings werden wir dafür keine Lösungen bereit stellen. Du kannst die jeweiligen Versionen der Algorithmen in den Lösungen als Kontrolle für deine Versuche nutzen. | ||
\or%ex5 - nicht veröffentlicht | ||
\section{Pool} | ||
\section{Sichtbarkeit} | ||
\section{Ausdrücke evaluieren} | ||
\else\fi | ||
\end{document} | ||
\grid | ||
\grid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
IN = Aufgaben.tex | ||
SHIPDIR = _build | ||
POST = $(shell /bin/bash -c 'if which pplatex > /dev/null; then echo "| pplatex -i -"; else echo "> /dev/null"; fi') | ||
PDFLATEX = pdflatex -interaction=nonstopmode | ||
|
||
all: $(shell /bin/bash -c 'echo Aufgabe_{1,2,3,4}_{sol,nosol}.pdf') ship clean | ||
|
||
Aufgabe_%: Aufgabe_%_sol.pdf Aufgabe_%_nosol.pdf | ||
|
||
Aufgabe_%_nosol.pdf: Aufgaben_nosol.tex | ||
$(PDFLATEX) -jobname="Übung_$*" -shell-escape "\newcounter{ex} \setcounter{ex}{$*} \input{Aufgaben_nosol.tex}" $(POST) | ||
|
||
Aufgabe_%_sol.pdf: Aufgaben_sol.tex | ||
$(PDFLATEX) -jobname="Lösung_$*" -shell-escape "\newcounter{ex} \setcounter{ex}{$*} \input{Aufgaben_sol.tex}" $(POST) | ||
|
||
Aufgaben_nosol.tex: Aufgaben.tex | ||
sed -r s/'\\setboolean\{sln\}\{(true|false)\}'/"\\\\setboolean{sln}{false}"/ $(IN) > Aufgaben_nosol.tex | ||
|
||
Aufgaben_sol.tex: Aufgaben.tex | ||
sed -r s/'\\setboolean\{sln\}\{(true|false)\}'/"\\\\setboolean{sln}{true}"/ $(IN) > Aufgaben_sol.tex | ||
|
||
ship: | ||
mkdir -p $(SHIPDIR) | ||
mv *.pdf $(SHIPDIR) | ||
|
||
clean: | ||
rm -f *.aux *.log *.out Aufgaben_*sol.tex *.pdf | ||
rm -rf _minted* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
\begin{lstlisting} | ||
>>> int(str(int('1') + int('1') + int('1')) + str(0) + str(0) + str(0)) | ||
3000 | ||
\end{lstlisting} | ||
Es gibt natürlich auch noch andere Möglichkeiten. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
\begin{multicols}{3} | ||
\begin{enumerate} | ||
\item \pythoninline{100} | ||
\item \pythoninline{1.3} | ||
\item \pythoninline{nan} | ||
\item \pythoninline{'234'} | ||
\item \textbf{ValueError} | ||
\item \pythoninline{'25'} | ||
\item \pythoninline{'7'} | ||
\item \pythoninline{5.0} | ||
\item \pythoninline{5} | ||
\item \textbf{ValueError} | ||
\end{enumerate} | ||
\end{multicols} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
\begin{enumerate} | ||
\item \pythoninline{true} ist ein falsch geschriebenes Schlüsselwort und | ||
somit ein \\ lexikalischer Fehler (\textbf{NameError}, \dots) | ||
\item \pythoninline{4 +* 5} sind Operatoren, denen ein Parameter dazwischen | ||
fehlt, somit ein | ||
\\ syntaktischer Fehler (\textbf{SyntaxError}, \textbf{IndentationError}, \dots) | ||
\item \pythoninline{2 / 0} ist eine undefinierte Rechnung, also ein | ||
\\ semantischer Fehler (\textbf{ZeroDivisionError}, \textbf{ValueError}, \dots) | ||
\end{enumerate} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Zahlen ohne Anführungszeichen ergeben die Zahl. Rationale Zahlen brauchen einen | ||
Dezimal\textbf{punkt}. Anführungszeichen (\texttt{'}, \texttt{"}) ergeben Strings, | ||
der Prefix \texttt{0x} erwartet hexadezimales Format, der Prefix \texttt{0b} | ||
binäres Format. Wahrheitswerte müssen groß geschrieben werden (\texttt{True}, | ||
\texttt{False}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Python ist installiert und dem Pfad hinzugefügt. Der Befehl | ||
\texttt{python ----version} gibt eine Versionsnummer von mindestens \textit{3.4.0} | ||
aus, oder der Befehl \texttt{python3} wird verwendet. Der Python Interpreter | ||
wurde gestartet. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Die zutreffenden Antworten sind die Aussagen 1 und 3. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Ein Beispiel wäre die folgende Rechnung: | ||
\begin{lstlisting} | ||
>>> (13 ** 3) % 33 | ||
19 | ||
>>> (19 ** 7) % 33 | ||
13 | ||
\end{lstlisting} | ||
|
||
Um Strings damit zu verschlüsseln/entschlüsseln, könnte man diese Funktionen verwenden: | ||
\begin{lstlisting} | ||
>>> enc = lambda x: [(ord(c) - ord('a')) ** 3 % 33 for c in x if ord('a') <= ord(c) and ord(c) <= ord('z')] | ||
>>> dec = lambda x: "".join([chr((v ** 7 % 33) + ord('a')) for v in x if 0 <= v and v < 33]) | ||
\end{lstlisting} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Das Ergebnis ist meistens eine Variante von 42. Wichtig ist, dass hier | ||
Punkt- vor Strichrechnung gilt. Der \texttt{**} Operator potenziert. | ||
String mal Zahl ergibt eine Wiederholung des Strings. Die letzte Aufgabe | ||
betont, dass manche Operationen auf Kommazahlen keine genauen Ergebnisse | ||
liefern. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
\begin{enumerate} | ||
\item \texttt{NameError: name 'prinnt' is not defined}: Ein \textcolor{red}{Lexikalischer Fehler}, da es keine Funktion mit dem angegebenen Namen | ||
\texttt {prinnt} gibt. Gültig wäre \texttt{print}. Ein klassische Tippfehler. | ||
\item \texttt{SyntaxError: invalid syntax}: Ein \textcolor{red}{Syntaktischer Fehler}, da Strings immer in einfachen oder doppelten Anführungszeichen | ||
stehen müssen. | ||
\item \texttt{TypeError: must be str, not int}: Ein \textcolor{red}{Semantischer Fehler}, da Texte und Zahlen nicht eindeutig addierbar sind. | ||
\textbf{Bonus Fact}: Um irgendeinen Wert in einen String zu verwandeln gibt es die Funktion \texttt{str(...)} | ||
\item \texttt{SyntaxError: EOL while scanning string literal}: Ein \textcolor{red}{Syntaktischer Fehler}, da der Rest der Zeile nun auch als String | ||
gelesen wird, der aber nie endet. | ||
\end{enumerate} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python3 | ||
Mehl = 450 | ||
Wasser = 250 | ||
Salz = 1 | ||
Oliven = 4 | ||
Backpulver = 2 | ||
Tomaten = 400 | ||
Oregano = 1 | ||
Knoblauch = 1 | ||
z = input("Zutat eingeben: ") | ||
m = float(input("Menge eingeben (ohne Einheit): ")) | ||
Zutatenliste = "Zutatenliste: \n Mehl: {0} g \n Wasser: {1} ml \n Salz: {2} TL, gestrichen \n Olivenöl: {3} EL \n Backpulver: {4} TL \n passierte Tomaten: {5} g \n Oregano {6} EL \n Knoblauch {7} Zehe(n)" | ||
if z == "Mehl": | ||
factor = m / Mehl | ||
print(Zutatenliste.format(m, factor * Wasser, factor * Salz, factor * Oliven, factor * Backpulver, factor * Tomaten, factor * Oregano, factor * Knoblauch)) | ||
elif z == "Wasser": | ||
factor = m / Wasser | ||
print(Zutatenliste.format(factor * Mehl, m, factor * Salz, factor * Oliven, factor * Backpulver, factor * Tomaten, factor * Oregano, factor * Knoblauch)) | ||
elif z == "Salz": | ||
factor = m / Salz | ||
print(Zutatenliste.format(factor * Mehl, factor * Wasser, m, factor * Oliven, factor * Backpulver, factor * Tomaten, factor * Oregano, factor * Knoblauch)) | ||
elif z == "Olivenöl": | ||
factor = m / Oliven | ||
print(Zutatenliste.format(factor * Mehl, factor * Wasser, factor * Salz, m, factor * Backpulver, factor * Tomaten, factor * Oregano, factor * Knoblauch)) | ||
elif z == "Backpulver": | ||
factor = m / Backpulver | ||
print(Zutatenliste.format(factor * Mehl, factor * Wasser, factor * Salz, factor * Oliven, m, factor * Tomaten, factor * Oregano, factor * Knoblauch)) | ||
elif z == "Tomaten": | ||
factor = m / Tomaten | ||
print(Zutatenliste.format(factor * Mehl, factor * Wasser, factor * Salz, factor * Oliven, factor * Backpulver, m, factor * Oregano, factor * Knoblauch)) | ||
elif z == "Oregano": | ||
factor = m / Oregano | ||
print(Zutatenliste.format(factor * Mehl, factor * Wasser, factor * Salz, factor * Oliven, factor * Backpulver, factor * Tomaten, m, factor * Knoblauch)) | ||
elif z == "Knoblauch": | ||
factor = m / Knoblauch | ||
print(Zutatenliste.format(factor * Mehl, factor * Wasser, factor * Salz, factor * Oliven, factor * Backpulver, factor * Tomaten, factor * Oregano, m)) | ||
else: | ||
print("Eingabe nicht erkannt") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Die erste und dritte Aussage treffen zu. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Eine Python Datei kann erstellt und ausgeführt werden. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env python3 | ||
op1 = int(input("Wie lautet der erste Operand: ")) | ||
op2 = int(input("Wie lautet der zweite Operand: ")) | ||
op = input("Wie lautet der Operator: ") | ||
|
||
if op == "+": | ||
print("Das Ergebnis lautet:", op1 + op2) | ||
elif op == "-": | ||
print("Das Ergebnis lautet:", op1 - op2) | ||
elif op == "*": | ||
print("Das Ergebnis lautet:", op1 * op2) | ||
elif op == "/": | ||
print("Das Ergebnis lautet:", op1 / op2) | ||
else: | ||
print("Keine gültige Eingabe!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
\begin{multicols}{3} | ||
\begin{enumerate} | ||
\item \lstinline{b == True} | ||
\item \lstinline{b == False} | ||
\item \lstinline{b == True} | ||
\item \lstinline{b == True} | ||
\item \lstinline{b == False} | ||
\item \lstinline{b == True} | ||
\end{enumerate} | ||
\end{multicols} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Zuweisung 1: variable1 = 2 \\ | ||
Zuweisung 2: variable3 = 1 \\ | ||
Zuweisung 3: variable1 = 'b' \\ | ||
Zuweisung 4: variable3 = 'a' \\ | ||
Zuweisung 5: variable1 = 11 \\ | ||
Es gibt natürlich auch noch andere Möglichkeiten |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Die Variable in Zeile 2 müsste \textbf{m}einAlter heißen und nicht \textbf{M}einAlter. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Die Antworten c), e) und i) sind nicht gültig.\\Gültig sind somit: Matrikelnummer, ÄhmKeineAhnung, {\_}meinAlter, {\_}2Euro, Variable2, noch$\_$besser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/python3 | ||
name = input("Bitte gib deinen Namen ein: ") | ||
tag = int(input("Gib den Tag deiner Geburt ein: ")) | ||
monat = int(input("Gib den Monat deiner Geburt ein: ")) | ||
jahr = int(input("Gib das Jahr deiner Geburt ein: ")) | ||
|
||
print("{0} hat am {1}.{2}.{3} Geburtstag.".format(name, tag, monat, jahr)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
a = int(input("Zahl a einlesen: ")) | ||
b = int(input("Zahl b einlesen: ")) | ||
c = int(input("Zahl c einlesen: ")) | ||
d = 2 * a | ||
a = d + 3 | ||
d = int(input("Zahl d einlesen: ")) | ||
print(b) | ||
print(c) | ||
c = a > d | ||
if c: | ||
d = a | ||
c = a < d | ||
if c: | ||
c = d - a | ||
b = a * a | ||
a = b | ||
b = c * d | ||
c = a + b | ||
a = c | ||
b = a + d | ||
c = b + d | ||
print(a) | ||
print(b) | ||
print(c) | ||
print(d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
lst = [1,2,3,4,5,6,7] | ||
|
||
sum = 0 | ||
product = 1 | ||
quadrate = [] | ||
|
||
for l in lst: | ||
sum += l | ||
product *= l | ||
quadrate.append(l * l) | ||
|
||
print(sum) | ||
print(product) | ||
print(sum / len(list) if lst else "Leere Liste!") | ||
print(quadrate) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
print(list(range(1,8))) | ||
print(list(range(5))) | ||
print(list(range(4,11,2))) | ||
print(list(range(9,0,-3))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# lst = ... | ||
print(lst[1] + lst[2] + lst[7]) | ||
print(lst[1] * lst[3] * lst[5] * lst[7]) | ||
print(lst[0] * 300) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
list = [1,2,3,4,5] | ||
# Da die Indices bei 0 anfangen ist len(list) - 1 der letzte gültige Index. | ||
# ------------------------ | ||
index = 0 | ||
while index < len(list): | ||
print(list[index]) | ||
index += 1 | ||
# ------------------------ | ||
for i in range(len(list)): | ||
print(list[i]) |
Oops, something went wrong.