Run ❯
Get your
own Python
server
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Change Language
Go to Spaces
Ctrl+Alt+P
import sqlite3 con = sqlite3.connect(":memory:") cur = con.cursor() # The database is in memory, so it is # empty every time the program starts. # Create the table and add the rows: cur.execute(""" CREATE TABLE players (name TEXT, score INTEGER) """) cur.execute(""" INSERT INTO players VALUES ('Emil', 120), ('Tobias', 95), ('Linus', 150), ('Lene', 80) """) con.commit() cur.execute(""" SELECT name, score FROM players ORDER BY score DESC LIMIT 3 """) place = 1 for name, score in cur.fetchall(): print(place, name, score) place += 1
1 Linus 150
2 Emil 120
3 Tobias 95