Skip to content
Snippets Groups Projects
Commit 9d74435f authored by Markus Opolka's avatar Markus Opolka
Browse files

Refactor and add aufgabe2

parent 2b19ef88
No related branches found
No related tags found
No related merge requests found
File moved
File moved
File moved
File moved
# Aufgabe 2.1
Schreiben Sie ein Programm, dass eine Benutzereingabe auf ein vorher definiertes Wort prüft. Dabei soll der Benutzer eine begrenzte Anzahl an Versuchen haben.
- Die Anzahl der Versuche soll der Funktion übergeben werden
- Nutzen für das Wort die gegebene Funktion get_random_word()
Boilerplate: guessme.py
# Aufgabe 2.2
Schreiben Sie ein Programm, dass eine Pyramide mit Höhe n auf die Kommandozeile druckt.
Beispiel: n = 5
=
==
===
====
===
==
=
Bei der Eingabe einer geraden Zahl, soll der Benutzer auf eine falsche Eingabe hingewiesen werden.
Boilerplate: pyramid.py
#!/usr/bin/env python3
import random
def get_random_word():
words = [
'mammoth',
'stay',
'improve',
'zealous',
'day',
'foregoing',
'hilarious',
'oil',
'doubtful',
'brush',
'impolite',
'birthday']
return random.choice(words)
#!/usr/bin/env python3
import sys
def draw_pyramid(n):
pass
def main(args):
try:
height = int(args[0])
draw_pyramid(height)
except Exception as e:
print('Please specify pyramid height')
print(e)
if __name__ == '__main__':
args = sys.argv[1:]
main(args)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment