Created
August 3, 2021 14:15
-
-
Save AthosFB/221dc6c1d327e4fd2ae9d6a3ec4311c1 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 random import randint | |
cont = 0 | |
def mysql(a, b, database): | |
import mysql.connector | |
cnx = mysql.connector.connect(user='root', password='', host='127.0.0.1') | |
mycursor = cnx.cursor() | |
mycursor.execute(f"use {database}") | |
mycursor.execute(f"insert into {a} value('{b}');") | |
print("Pensei em um número de 1 - 10!") | |
pc = randint(1, 10) | |
mysql(a='pc', b=pc, database='numeros') | |
while True: | |
num = int(input("Tente Adivinhar: ")) | |
mysql(a='escolhas', b=num, database='numeros') | |
if pc == num: | |
cont += 1 | |
mysql(a='tentativas', b=cont, database='numeros') | |
break | |
else: | |
cont += 1 | |
print("\033[1;31mERROOOOOOOU. Tente novamente\033[m") | |
print("\033[1;32mAcertou!!!\033[m") | |
print(f"Número = {pc}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment