ICT: Python 2023 、
w3Schoolvisual exeonline Pythonvscode.dev
YouTube
Quiz-1 id
Quiz-2 =
Quiz-3 %
Quiz-4 print
 input
Quiz-5 if(1)
Quiz-6 if(2)
Quiz-7 while
for .. range()
Quiz-8a for
Quiz-8b for
Quiz-9 range
While-Repeat
Videos
Thonny

TOC
Paper IB (program)
2012 Q3 A=A+B; B=A-B; ...
2013 Q5 Array (find min)
2014 Q3 Fibonacci Seq
2015 Q4 Array (sum), Search
2016 Q2 Array (search)
2017 Q3 Array (bus station)
2018 Q5 Guessing game
2019 Q5 Array (binary) 1-0
2020 Q2 HCF, while, Swap(A,B)
2021 Q3 Array (binary)
2022 Q5 Array (binary)
2023 Q3 Array

#------ myLib.py ------
from datetime import date, datetime

def dow(y,m,d=1):
    dt = date(y,m,d)
    return int(dt.strftime('%w'))

def today():
    td = date.today()
    return td.strftime("%Y-%m-%d")

def now():
    tm = datetime.now()
    return tm.strftime("%H:%M:%S")

def isleapyear(yy):
    return (yy%400==0 or (yy%4==0 and yy%100!=0))


#------ main.py ------
from myLib import *
maxdays = [0,31,28,31,30,31,30,31,31,30,31,30,31]

print(today(), now())
yy = 2023
print( dow(yy,2,28) )

if ( isleapyear(yy) ):
    maxdays[2]=29
else:
    maxdays[2]=28


#------ mysql.py ------
import mysql.connector
# https://www.w3schools.com/python/python_mysql_getstarted.asp
# python -m pip install mysql-connector-python
mydb = mysql.connector.connect(
    host    ="localhost",
    user    ="root",
    password="",
    database="test"
)

cursor = mydb.cursor()
cursor.execute("SELECT * FROM student")
result = cursor.fetchall()

# print(result[0])
# print(result[1][1])

for x in result:
    for y in x:
        print(y, end='\t')
    print()