Quiz 16_3-3: Databases | Python for Everybody 配套练习_解题记录

news2024/11/18 15:45:27

文章目录

  • Python for Everybody
  • 课程简介
  • Quiz 16_3-3: Databases
    • 单选题(1-10)
    • 操作题
      • Autograder: Many Students in Many Courses


Python for Everybody


课程简介

Python for Everybody 零基础程序设计(Python 入门)

  • This course aims to teach everyone the basics of programming computers using Python. 本课程旨在向所有人传授使用 Python 进行计算机编程的基础知识。
  • We cover the basics of how one constructs a program from a series of simple instructions in Python. 我们介绍了如何通过 Python 中的一系列简单指令构建程序的基础知识。
  • The course has no pre-requisites and avoids all but the simplest mathematics. Anyone with moderate computer experience should be able to master the materials in this course. 该课程没有任何先决条件,除了最简单的数学之外,避免了所有内容。任何具有中等计算机经验的人都应该能够掌握本课程中的材料。
  • This course will cover Chapters 1-5 of the textbook “Python for Everybody”. Once a student completes this course, they will be ready to take more advanced programming courses. 本课程将涵盖《Python for Everyday》教科书的第 1-5 章。学生完成本课程后,他们将准备好学习更高级的编程课程。
  • This course covers Python 3.

在这里插入图片描述

coursera

Python for Everybody 零基础程序设计(Python 入门)

Charles Russell Severance
Clinical Professor

在这里插入图片描述

个人主页
Twitter

在这里插入图片描述

University of Michigan


课程资源

coursera原版课程视频
coursera原版视频-中英文精校字幕-B站
Dr. Chuck官方翻录版视频-机器翻译字幕-B站

PY4E-课程配套练习
Dr. Chuck Online - 系列课程开源官网



Quiz 16_3-3: Databases

Databases give us very fast random access to large amounts of data. There is a lot of material in this chapter as we learn the Structured Query Language (SQL).


单选题(1-10)

  1. How do we model a many-to-many relationship between two database tables?
  • We use a BLOB column in both tables
  • We use the ARRAY column type in both of the tables
  • We add 10 foreign keys to each table with names like artict_id_1, artist_id2, etc.
  • We add a table with two foreign keys
  1. In Python, what is a database “cursor” most like?
  • A function
  • A Python dictionary
  • A method within a class
  • A file handle
  1. What method do you call in an SQLIte cursor object in Python to run an SQL command?
  • send()
  • run()
  • execute()
  • socket()
  1. In the following SQL,
cur.execute('SELECT count FROM Counts WHERE org = ? ', (org, ))

what is the purpose of the “?”?

  • It is a syntax error
  • It is a placeholder for the contents of the “org” variable
  • It allows more than one boolean operation in the WHERE clause
  • It is a search wildcard
  1. In the following Python code sequence (assuming cur is a SQLite cursor object),
cur.execute('SELECT count FROM Counts WHERE org = ? ', (org, ))
row = cur.fetchone()

what is the value in row if no rows match the WHERE clause?

  • -1
  • None
  • An empty dictionary
  • An empty list
  1. What does the LIMIT clause in the following SQL accomplish?
SELECT org, count FROM Counts
   ORDER BY count DESC LIMIT 10
  • It only sorts on the first 10 characters of the column
  • It reverses the sort order if there are more than 10 rows
  • It only retrieves the first 10 rows from the table
  • It avoids reading data from any table other than Counts
  1. What does the executescript() method in the Python SQLite cursor object do that the normal execute() method does not do?
  • It allows multiple SQL statements separated by semicolons
  • It allows database tables to be created
  • It allows embeded Python to be executed
  • It allows embedded JavaScript to be executed
  1. What is the purpose of “OR IGNORE” in the following SQL:
INSERT OR IGNORE INTO Course (title) VALUES ( ? )
  • It ignores errors in the SQL syntax for the statement
  • It makes sure that if a particular title is already in the table, there are no duplicate rows inserted
  • It ignores any foreign key constraint errors
  • It updates the created_at value if the title already exists in the table
  1. For the following Python code to work, what must be added to the title column in the CREATE TABLE statement for the Course table:
cur.execute('''INSERT OR IGNORE INTO Course (title)
    VALUES ( ? )''', ( title, ) )
cur.execute('SELECT id FROM Course WHERE title = ? ',
    (title, ))

course_id = cur.fetchone()[0]

  • An AUTOINCREMENT indication
  • A UNIQUE constraint
  • A PRIMARY KEY indication
  • A NOT NULL constraint
  1. What do we generally avoid in a many-to-many junction table?
  • Data items specific to the many-to-many relationship
  • A logical key
  • Two foreign keys
  • An AUTOINCREMENT primary key column

操作题

Autograder: Many Students in Many Courses

Instructions
This application will read roster data in JSON format, parse the file, and then produce an SQLite database that contains a User, Course, and Member table and populate the tables from the data file.

You can base your solution on this code: http://www.py4e.com/code3/roster/roster.py - this code is incomplete as you need to modify the program to store the role column in the Member table to complete the assignment.

Each student gets their own file for the assignment. Download this file and save it as roster_data.json. Move the downloaded file into the same folder as your roster.py program.

Once you have made the necessary changes to the program and it has been run successfully reading the above JSON data, run the following SQL command:

SELECT User.name,Course.title, Member.role FROM 
    User JOIN Member JOIN Course 
    ON User.id = Member.user_id AND Member.course_id = Course.id
    ORDER BY User.name DESC, Course.title DESC, Member.role DESC LIMIT 2;

The output should look as follows:

Zuzu|si422|0
Zunairah|si334|0

Once that query gives the correct data, run this query:

SELECT 'XYZZY' || hex(User.name || Course.title || Member.role ) AS X FROM 
    User JOIN Member JOIN Course 
    ON User.id = Member.user_id AND Member.course_id = Course.id
    ORDER BY X LIMIT 1;

You should get one row with a string that looks like XYZZY53656C696E613333.

(Hint: starts with XYZZY41616)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/706863.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

AI Is the New Power

这个题目纯粹是为了博眼球,因为吴恩达有个题目是AI Is the New Electricity。:)但是我想AI确实是为我们这些企业信息化顾问顾问赋予了新的力量,在我们的职业生涯中开辟了新的可能性。 在几周前的文章中,我们提到“终点…

前端vue入门(纯代码)19

不管何时何地,永远保持热爱,永远积极向上!!! 【21.Vue中的插槽slot】 问题:插槽(slot)是什么?兄弟们也可以点这里去看这位兄弟的博客,写的比我详细&#xff…

Linux--查询指令所在路径:which

语法: which 指令 示例: ①查询ls所在路径

更进一步!可视化一切递归算法!

学算法认准 labuladong 后台回复课程查看精品课 点击卡片可搜索文章👇 在线学习网站: https://labuladong.gitee.io/algo/ 上次我发布了算法代码可视化功能,适配了我的网站和我的系列插件,最近我修复了一些 bug 并增加了一些功能优…

windows系统根据端口查询pid并结束进程

用管理员权限打开命令指示符,输入命令: 1、查看被占用端口所对应的 PID netstat -aon|findstr “端口号” 2、查看指定PID的进程 tasklist|findstr ”57672” 3、结束进程 taskkill -pid 进程号 -f

Unity VR 开发教程:Meta Quest 一体机开发 (二)混合现实 MR 透视 Passthrough 环境配置

文章目录 📕教程说明📕配置透视的串流调试功能📕第一步:设置 OVRManager📕第二步:添加 OVRPassthroughLayer 脚本📕第三步:在场景中添加虚拟物体📕第四步:删除…

c++摘花生

先看题目: Hello Kitty想摘点花生送给她喜欢的米老鼠。 她来到一片有网格状道路的矩形花生地(如下图),从西北角进去,东南角出来。 地里每个道路的交叉点上都有种着一株花生苗,上面有若干颗花生,经过一株花生苗就能摘…

html前端输入框模糊查询2

1、一个页面内多个模糊查询情况&#xff1a; <!DOCTYPE html> <html> <head> <meta charset"UTF-8" /> <meta name"viewport" content"widthdevice-width, initial-scale1.0, user-scalable0, minimum-scale1.0, maximum-…

网络安全合规-渗透工程师

首先放一张渗透工程师薪资招聘。 各类网络空间人才缺口高达97%&#xff0c;专业人才供不应求。市场环境对网络安全人才求贤若渴&#xff0c;渗透测试工程师尤为紧俏&#xff0c;企业高薪求才&#xff0c;薪资一涨再涨&#xff01; 工资高&#xff0c;待遇好&#xff0c;但是有…

大模型浪潮下的平台、框架、AI编译器和芯片架构丨2023智源大会精彩回顾

导读 在大模型时代&#xff0c;应该如何组织AI系统使其能力与市场需求对齐&#xff0c;是底层的AI工程师需要不断思考和探讨的话题。围绕这一问题&#xff0c;在2023智源大会AI系统分论坛上&#xff0c;从事AI框架开发、芯片研发和AI编译器优化的专家汇聚在一起&#xff0c;共同…

广告行业中那些趣事系列63:使用chatgpt类大模型进行文本分类任务

导读&#xff1a;本文是“数据拾光者”专栏的第六十三篇文章&#xff0c;这个系列将介绍在广告行业中自然语言处理和推荐系统实践。本篇主要介绍了使用chatgpt类大语言模型进行文本分类任务&#xff0c;对于希望使用chatgpt类大语言模型上进行数据标注、文本分类和关键词抽取等…

debug调试高级用法

文章目录 前言一、如何给程序加断点,并调试二、开始调试1.断点查看2.查看所有断点,去掉断点,批量去断点3. 断点改值4. 断点条件 总结 前言 在开发调试中,如果你不会debug调试,一般情况下,就只能控制台打印,然后一遍一遍重启了,所有debug是必不可少的技能,尤其当遇到问题的时候…

xxl-job的实践

pom.xml文件导入xxl-job 包 <dependency><groupId>com.xuxueli</groupId><artifactId>xxl-job-core</artifactId><version>${xxl-job.version}</version></dependency><xxl-job.version>2.3.1</xxl-job.version> …

Android学习日志 二、Button组件调用函数

文章目录 Button组件调用函数配置代码By-Round Moon Button组件调用函数 Android Studio 版本:2022.2.1 patch 2 配置 接日志一的操作&#xff0c;我们创建一个空项目&#xff0c;名字可以自己起 等待构建完成后&#xff0c;我们创建一个模块 创建一个activity 在相应的x…

Spring Boot中RabbitMQ自动配置的介绍、原理和使用

Spring Boot中RabbitMQ自动配置的介绍、原理和使用 引言 RabbitMQ是一种高性能的消息队列系统&#xff0c;它支持多种消息协议和丰富的功能&#xff0c;如消息路由、消息确认、消息重试、死信队列等。在Spring Boot中&#xff0c;我们可以通过自动配置的方式来使用RabbitMQ。…

碳排放预测模型 | Python实现基于时间序列趋势外推的碳排放预测模型(线性趋势、指数趋势、平方趋势)

文章目录 效果一览文章概述源码设计参考资料效果一览 文章概述 碳排放预测模型 | Python实现基于时间序列趋势外推的碳排放预测模型(线性趋势、指数趋势、平方趋势) 源码设计 import pandas as pd import numpy as np import scipy

SpringBoot(三)SpringBoot热部署

在开发SpringBoot项目过程中&#xff0c;你有没有遇到如下的问题&#xff1a;每次修改java代码&#xff0c;都得重新run一下Application才会生效。起初我也遇到了这样的问题&#xff0c;但SpringBoot这种成熟的框架&#xff0c;怎么可能不支持热部署呢。本篇&#xff0c;我们就…

Ubuntu虚拟机文件系统挂了:Failure: File system check of the root filesystem failed

问题描述 太久不用虚拟机Ubuntu 20.04&#xff0c;就把虚拟机移动到了移动硬盘中&#xff0c;然后虚拟机挂了。准确地说是文件系统挂了。由于没有保护好现场&#xff0c;出错位置是一个/dev/xxx&#xff0c;提示Failure: File system check of the root filesystem failed。 …

10 DCT变换对灰度图像压缩(matlab程序)

1.简述 一、设计任务 1、在图像的变换和压缩中&#xff0c;常常用到离散余弦变换&#xff08;DCT&#xff09;。DCT变换用于图像的压缩实例。请在测试图像中验证你的结论。 2、请编程实现图像的真彩色增强。 3、通过直方图均衡化的方法实现图像的灰度变换&#xff0c;在测试…

threejs材质

个人博客地址: https://cxx001.gitee.io 前言 前面简单的介绍了材质&#xff0c;你已经了解到材质结合几何体就可以创建网格&#xff0c;网格对象才可以添加到Threejs渲染的场景中。材质就像物体的皮肤&#xff0c;决定了几何体的外表。如&#xff0c;几何体看起来是否像金属…