Update galerie

This commit is contained in:
2019-06-03 16:10:09 +02:00
parent 9daadd17fe
commit 4bbf823199
2 changed files with 57 additions and 1 deletions

53
uebung6/galerie.py Normal file
View File

@@ -0,0 +1,53 @@
#!/usr/bin/python3
import cgi
import cgitb
import sys
from random import randint
cgitb.enable()
error = False
#try:
# # FieldStorage-Instanz erzeugen
# form = cgi.FieldStorage(encoding='utf8')
#
# # Zugriff auf die Parameter (nach Integer konvertieren!)
# s1 = int(form.getvalue('s1'))
# s2 = int(form.getvalue('s2'))
#
# # Summe berechnen
# my_sum = s1 + s2
#
#except:
# error = True
# Ausgabe
print("Content-type: text/html\n")
print("""
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<title>Summenrechner</title>
</head>
<body>
""")
randomnum = 3 * randint(1, 7)
count = 1
while count <= randomnum:
print(""" <img src="https://picsum.photos/800/600?random={}"> """.format(count))
count += 1
print("""
</body>
</html>
""")

View File

@@ -6,19 +6,22 @@ print("***********************************")
print("Willkommen zum lustigen Zahlenraten")
print("***********************************")
# Zahlen initialisieren
randomNum = randint(0, 99)
eingabe = -1
#Funktion getNumber gibt die Eingabe des Spielers zurück
def getNumber():
try:
value = int(input('Geben Sie eine Zahl von 0-99 ein: '))
except ValueError:
print("Not a number")
print("Keine Zahl!")
value = -1
return value
while eingabe != randomNum:
eingabe = getNumber()
if eingabe == -1: continue
if eingabe > randomNum:
print("Zahl zu groß")
elif eingabe < randomNum: