Skip to content

Instantly share code, notes, and snippets.

@dunossauro
Created May 22, 2020 03:17
Show Gist options
  • Save dunossauro/db0d3cd423239b4068a3eb2d939ce1fc to your computer and use it in GitHub Desktop.
Save dunossauro/db0d3cd423239b4068a3eb2d939ce1fc to your computer and use it in GitHub Desktop.
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