Created
May 22, 2020 03:17
-
-
Save dunossauro/db0d3cd423239b4068a3eb2d939ce1fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlite3 import connect | |
from random import randint | |
db = connect('database.sqlite') | |
cursor = db.cursor() | |
def pergunta(): | |
n = randint(1, 1816) | |
query = cursor.execute(f'select pergunta from charadas where id={n}') | |
return n, query.fetchone()[0] | |
def resposta(n): | |
query = cursor.execute(f'select resposta from charadas where id={n}') | |
return query.fetchone()[0] | |
numero_da_pergunta, charada = pergunta() | |
resposta(numero_da_pergunta) | |
print(charada) | |
print(resposta(numero_da_pergunta)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment