-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataTypeQuiz
More file actions
102 lines (97 loc) · 2.33 KB
/
DataTypeQuiz
File metadata and controls
102 lines (97 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import time
import random
import datetime
def GetInt():
print(random.randint(0,100000))
def GetStr():
wordlist=["remain","resignation","face","core","population","paradox","symbol","attitude","yearn","feminist","diamond","overview","extreme","good","store","curtain","restaurant","counter","bride","quantity"]
print(random.choice(wordlist))
def GetReal():
print(random.uniform(0, 1000000))
def GetBool():
if (random. getrandbits(1))==1:
print(True)
else:
print(False)
def GetChar():
alphabet=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",1,2,3,4,5]
print(random.choice(alphabet))
def GetDate():
start = datetime.date(2000, 1, 1)
end = datetime.date(2020, 2, 1)
time_ = end- start
days_= time_.days
random_number_of_days = random.randrange(days_)
random_date = start + datetime.timedelta(days=random_number_of_days)
print(random_date)
Lives=4
Points=0
now = time.time()
while True:
answers=["integer","char","boolean","float","date","string"]
GetInt()
userinput=input("What data type is this?")
if userinput==answers[0]:
print("correct")
Points=Points+1
else:
print("Wrong")
Lives=Lives-1
if Lives<1:
break
GetChar()
userinput=input("What data type is this?")
if userinput==answers[1]:
print("correct")
Points=Points+1
else:
print("Wrong")
Lives=Lives-1
if Lives<1:
break
GetBool()
userinput=input("What data type is this?")
if userinput==answers[2]:
print("correct")
Points=Points+1
else:
print("Wrong")
Lives=Lives-1
if Lives<1:
break
GetReal()
userinput=input("What data type is this?")
if userinput==answers[3]:
print("correct")
Points=Points+1
else:
print("Wrong")
Lives=Lives-1
if Lives<1:
break
GetDate()
userinput=input("What data type is this?")
if userinput==answers[4]:
print("correct")
Points=Points+1
else:
print("Wrong")
Lives=Lives-1
if Lives<1:
break
GetStr()
userinput=input("What data type is this?")
if userinput==answers[5]:
print("correct")
Points=Points+1
else:
print("Wrong")
Lives=Lives-1
if Lives<1:
break
break
print(f"Score is {Points}")
now2=time.time()
timetaken=(now2-now)
print(timetaken,"seconds")
print(int(timetaken/Points),"score overall")