aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTinWoodman92 <chrhodgden@gmail.com>2022-11-26 20:53:32 -0600
committerTinWoodman92 <chrhodgden@gmail.com>2022-11-26 20:53:32 -0600
commit591b1ed6237f250e60eaef321ab9fe0f93c070a0 (patch)
tree077cff9b16139ba69200125438eff3458d89441a
parent93b849e2c52c4f23655855349583c5ade5604c8f (diff)
integrated sexy database
-rw-r--r--.gitignore3
-rw-r--r--hw.py40
2 files changed, 39 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2a32ac5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.db
+*demo*
+*test* \ No newline at end of file
diff --git a/hw.py b/hw.py
index b883951..ca100c9 100644
--- a/hw.py
+++ b/hw.py
@@ -1,10 +1,42 @@
-import random
+import os
+from random import *
+from sqlite3 import *
-chk = random.randint(0,1)
-if chk:
+if not os.path.isfile(os.path.join(os.getcwd(), 'sexy.db')):
+ chk_1 = True
+else:
+ chk_1 = False
+
+con = connect('sexy.db')
+cur = con.cursor()
+
+if chk_1:
+ cur.execute("CREATE TABLE sexy_tbl (chk INTEGER);")
+
+chk_2 = randint(0,1)
+
+cur.execute("INSERT INTO sexy_tbl (chk) VALUES(:chk);", {"chk" : chk_2})
+
+rst = []
+k = []
+res = cur.execute("SELECT sum(chk) as sum_chk, count(chk) as count_chk FROM sexy_tbl;")
+for desc in cur.description: k.append(desc[0])
+for row in res.fetchall(): rst.append(dict(zip(k,row)))
+
+rcd = rst[0]
+chk_3 = (rcd["sum_chk"]/rcd["count_chk"]) > 0.5
+
+if chk_3:
print("\033[95mheyy sexy!\033[0m")
else:
print("Hello World!")
-input()
+diag = input()
+
+if 'sexy' in diag.lower():
+ print(f"Your sexy score is {rcd['sum_chk']} out of {rcd['count_chk']}.")
+
+con.commit()
+cur = None
+con = None \ No newline at end of file