-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment2.py
More file actions
46 lines (38 loc) · 1.06 KB
/
Assignment2.py
File metadata and controls
46 lines (38 loc) · 1.06 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
from tkinter import *
import random
import sqlite3
from PUT import CREATETABLE
conn=sqlite3.connect('showdata.sqlite')
cur=conn.cursor()
try:
cur.execute('SELECT name FROM Shows')
except:
CREATETABLE()
cur.execute('SELECT name FROM Shows ORDER BY RANDOM() LIMIT 10')
listofshows=list()
listofshowsmixed=list()
score=0
for i in range(0,10):
scrambled=''
name=cur.fetchone()[0]
listofshows.append(name)
if ' ' not in name:
scrambled=''.join(random.sample(name,len(name)))
if ' ' in name:
temp=name.split()
for i in temp:
scrambled=scrambled+''.join(random.sample(i,len(i)))+' '
scrambled.strip()
scrambled=scrambled.lower()
listofshowsmixed.append(scrambled)
for i in range(0,10):
print('Name number ',i+1,':')
print(listofshowsmixed[i])
print('Enter your guess: ')
guess=input()
if(guess.lower()==listofshows[i].lower()):
score+=1
print('Correct!')
else:
print('Wrong!')
print('You scored ',score,'.')