创建学生库

we400760 程序题 共 个子题

题目说明

import sqlite3
conn = sqlite3.connect('        ①        ')
cursor = conn.cursor()
cursor.execute('''        ②         students_table(id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT,age INTEGER,grade TEXT)''')
students = [ ('Alice', 17, '10th'), ('Bob', 18, '11th'), ('Charlie', 16, '10th'),  ('David', 19, '12th'),('Eve', 17, '11th')]
cursor.executemany('''INSERT INTO students_table (name, age, grade) VALUES (?, ?, ?)''', students)
conn.commit()
cursor.execute('SELECT * FROM students_table         ③        ')
print("年龄大于18岁的学生:")
print(cursor.        ④        )
cursor.execute('UPDATE students_table SET age = age + 1 WHERE name = "Alice"')
cursor.execute('DELETE FROM students_table WHERE name = "Bob"')
conn.commit()
conn.close()

评分标准

(1)students.db 或等效答案;(2分) (2)CREATE TABLE 或等效答案; (2分) (3)WHERE age > 18 或等效答案;(3分) (4)fetchall() 或等效答案。(3分)

本题为编程题,提交代码并运行通过测试点后判分。

正在加载题目数据…
已答 /
子题
该题型需在试卷/作业中作答,单题练习暂不支持
答案解析
提交记录
共 条 仅展示自由练习提交
正在加载提交记录…
讨论
发布
登录后参与讨论 立即登录
发布讨论需先绑定并验证手机号 去绑定手机号
加载中…
我
我
回复 @
回复 @
发送
还没有人讨论,来发表第一条吧