Testpage: Unterschied zwischen den Versionen

Aus Unterrichtsmaterial
Wechseln zu:Navigation, Suche
Zeile 12: Zeile 12:
  
  
<br /><syntaxhighlight lang="python3" line="1">
+
<br /><syntaxhighlight class="mw-collapsible" lang="python3" line="1">
 
# Import the modules
 
# Import the modules
 
import sys
 
import sys

Version vom 5. März 2020, 13:38 Uhr

Übersicht
Roadmap.JPG
Themenfeld Big Data
Editiert am 05.3.2020






 1 # Import the modules
 2 import sys
 3 import random
 4 
 5 ans = True
 6 
 7 while ans:
 8     question = raw_input("Ask the magic 8 ball a question: (press enter to quit) ")
 9     
10     answers = random.randint(1,8)
11     
12     if question == "":
13         sys.exit()
14     
15     elif answers == 1:
16         print "It is certain"
17     
18     elif answers == 2:
19         print "Outlook good"
20     
21     elif answers == 3:
22         print "You may rely on it"
23     
24     elif answers == 4:
25         print "Ask again later"
26     
27     elif answers == 5:
28         print "Concentrate and ask again"
29     
30     elif answers == 6:
31         print "Reply hazy, try again"
32     
33     elif answers == 7:
34         print "My reply is no"
35     
36     elif answers == 8:
37         print "My sources say no"