Created
November 13, 2018 18:27
Star
You must be signed in to star a gist
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
# .*. coding: latin1 .*. | |
# importa wxPythton | |
import sqlite3 | |
con = sqlite3.connect('aula3228524.db') | |
cur = con.cursor() | |
sql = 'create table imc (id integer primary key, peso float, altura float, imc float)' | |
cur.execute(sql) | |
print("banco criado com sucesso") | |
peso = float(input ("insira o seu peso: ")); | |
altura = float(input("insira sua altura em cm: ")); | |
imc = peso / (altura**2) | |
print ("seu imc é: {:.1f}".format(imc) ) | |
insert = 'insert into imc values (null, '+ str(peso) +', '+str(altura)+', '+str(imc)+')' | |
cur.execute(insert) | |
con.commit() | |
cur.execute('select * from imc') | |
recset = cur.fetchall() | |
print ('exibindo dados gravados no banco: ') | |
print (recset) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment