Testpage: Unterschied zwischen den Versionen

Aus Unterrichtsmaterial
Wechseln zu:Navigation, Suche
Zeile 12: Zeile 12:
  
  
<br /><syntaxhighlight lang="python3" line="1">
+
<br />
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
<syntaxhighlight lang="python" line="1">
 
# Import the modules
 
# Import the modules
 +
 
import sys
 
import sys
 +
 
import random
 
import random
 +
  
 
ans = True
 
ans = True
 +
  
 
while ans:
 
while ans:
 +
 
     question = raw_input("Ask the magic 8 ball a question: (press enter to quit) ")
 
     question = raw_input("Ask the magic 8 ball a question: (press enter to quit) ")
 +
 
      
 
      
 +
 
     answers = random.randint(1,8)
 
     answers = random.randint(1,8)
 +
 
      
 
      
 +
 
     if question == "":
 
     if question == "":
 +
 
         sys.exit()
 
         sys.exit()
 +
 
      
 
      
 +
 
     elif answers == 1:
 
     elif answers == 1:
 +
 
         print "It is certain"
 
         print "It is certain"
 +
 
      
 
      
 +
 
     elif answers == 2:
 
     elif answers == 2:
 +
 
         print "Outlook good"
 
         print "Outlook good"
 +
 
      
 
      
 +
 
     elif answers == 3:
 
     elif answers == 3:
 +
 
         print "You may rely on it"
 
         print "You may rely on it"
 +
 
      
 
      
 +
 
     elif answers == 4:
 
     elif answers == 4:
 +
 
         print "Ask again later"
 
         print "Ask again later"
 +
 
      
 
      
 +
 
     elif answers == 5:
 
     elif answers == 5:
 +
 
         print "Concentrate and ask again"
 
         print "Concentrate and ask again"
 +
 
      
 
      
 +
 
     elif answers == 6:
 
     elif answers == 6:
 +
 
         print "Reply hazy, try again"
 
         print "Reply hazy, try again"
 +
 
      
 
      
 +
 
     elif answers == 7:
 
     elif answers == 7:
 +
 
         print "My reply is no"
 
         print "My reply is no"
 +
 
      
 
      
 +
 
     elif answers == 8:
 
     elif answers == 8:
 +
 
         print "My sources say no"
 
         print "My sources say no"
 
</syntaxhighlight>
 
</syntaxhighlight>

Version vom 5. März 2020, 14:09 Uhr

Übersicht
Roadmap.JPG
Themenfeld Big Data
Editiert am 05.3.2020









 1 # Import the modules
 2 
 3 import sys
 4 
 5 import random
 6 
 7 
 8 ans = True
 9 
10 
11 while ans:
12 
13     question = raw_input("Ask the magic 8 ball a question: (press enter to quit) ")
14 
15     
16 
17     answers = random.randint(1,8)
18 
19     
20 
21     if question == "":
22 
23         sys.exit()
24 
25     
26 
27     elif answers == 1:
28 
29         print "It is certain"
30 
31     
32 
33     elif answers == 2:
34 
35         print "Outlook good"
36 
37     
38 
39     elif answers == 3:
40 
41         print "You may rely on it"
42 
43     
44 
45     elif answers == 4:
46 
47         print "Ask again later"
48 
49     
50 
51     elif answers == 5:
52 
53         print "Concentrate and ask again"
54 
55     
56 
57     elif answers == 6:
58 
59         print "Reply hazy, try again"
60 
61     
62 
63     elif answers == 7:
64 
65         print "My reply is no"
66 
67     
68 
69     elif answers == 8:
70 
71         print "My sources say no"