デフォルトで多倍長整数演算って凄まじい発想。
print(2**19937-1)たった一行これ書くだけでメルセンヌツイスタの周期が
全て出力されるなんて。
よーしパパ黄金率をいちまんけた求めちゃうぞー
# coding: utf-8うっひょう余裕!
n0 = 0
n1 = 1
for i in range(0, 30000): # 数は適当に数倍
n = n0 + n1
n0 = n1
n1 = n
print("1." + str((10**10000)*n1//n0)[1:]) #手抜き
次はデータベースだー
import sqlite3 as sql…とまあ、だいたい何でも出来て笑えます。
con = sql.connect("mydb")
if con.execute("select count(*) co from sqlite_master where name='tbl'").fetchone()[0] == 0:
con.execute("create table tbl (id number, nm varchar(20))")
for i in range(1,10):
con.execute("insert into tbl (id, nm) values (" + str(i) + ", 'name" + str(i) + "')")
con.commit()
print(con.execute("select count(id) from tbl").fetchone()[0])
たった2行だけでデータベースを構築できるってのがもう爆笑。
言語自体が楽しい感覚って相当久しぶり。ExcelVBA以来でしょうか。