Using Databases with Python Coursera Quiz Answers – Networking Funda

All Weeks Using Databases with Python Coursera Quiz Answers

Using Databases with Python Week 01 Quiz Answers

Quiz 1: Using Encoded Data in Python 3

Q1. What is the most common Unicode encoding when moving data between systems?

  • UTF-32
  • UTF-8
  • UTF-128
  • UTF-64
  • UTF-16

Q2. What is the ASCII character that is associated with the decimal value 42?

  • Newline
  • *
  • w
  • W
  • 0

Q3. What word does the following sequence of numbers represent in ASCII:

108, 105, 115, 116

  • list
  • first
  • webs
  • dict
  • mist

Q4. How are strings stored internally in Python 3?

  • UTF-16
  • inverted
  • bubble memory
  • Unicode

Q5. When reading data across the network (i.e. from a URL) in Python 3, what method must be used to convert it to the internal format used by strings?

  • decode()
  • rstrip()
  • encode()
  • split()
  • internal()

Quiz 2: Object Oriented Programming

Q1. Which came first, the instance or the class?

  • class
  • instance
  • function
  • method

Q2. In Object Oriented Programming, what is another name for the “attributes” of an object?

  • methods
  • messages
  • portions
  • forms
  • fields

Q3. At the moment of creation of a new object, Python looks at the _ definition to define the structure and capabilities of the newly created object.

  • class
  • instance
  • method
  • cache
  • constructor

Q4. Which of the following is NOT a good synonym for “class” in Python?

  • blueprint
  • direction
  • template
  • pattern

Q5. What does this Python statement do if PartyAnimal is a class?

zap = PartyAnimal()
  • Subtract the value of the zap variable from the value in the PartyAnimal variable and put the difference in zap
  • Use the PartyAnimal template to make a new object and assign it to zap
  • Copy the value from the PartyAnimal variable to the variable zap
  • Clear out all the data in the PartyAnimal variable and put the old values for the data in zap

Q6. What is the syntax to look up the full name attribute in an object stored in the variable colleen?

  • colleen[‘fullname’]
  • colleen.fullname
  • colleen::fullname
  • colleen->fullname

Q7. Which of these statements is used to indicate that class A will inherit all the features of class B?

class A instance Of B :

  • class A inherits B :
  • class A(B) :
  • A=B++;
  • class A extends B :

Q8. What keyword is used to indicate the start of a method in a Python class?

  • continue
  • break
  • function
  • def

Q9. What is “self” typically used for in a Python method within a class?

  • To refer to the instance in which the method is being called
  • To set the residual value in an expression where the method is used
  • To terminate a loop
  • The number of parameters to the method

Q10. What does the Python dir() function show when we pass an object into it as a parameter?

  • It shows the methods and attributes of the object
  • It shows the number of parameters to the constructor
  • It shows the type of the object
  • It shows the parent class

Q11. Which of the following is rarely used in Object-Oriented Programming?

  • Destructor
  • Attribute
  • Constructor
  • Method

Using Databases with Python Week 02 Quiz Answers

Q1. Structured Query Language (SQL) is used to (check all that apply)

  • Insert data
  • Check Python code for errors
  • Delete data
  • Create a table

Q2. Which of these is the right syntax to make a new table?

  • MAKE people;
  • CREATE people;
  • MAKE DATASET people;
  • CREATE TABLE people;

Q3. Which SQL command is used to insert a new row into a table?


Q4. Which command is used to retrieve all records from a table?

  • SELECT * FROM Users
  • SELECT all FROM Users
  • RETRIEVE all FROM User

Q5. Which keyword will cause the results of the query to be displayed in sorted order?

  • None of these

Q6. In database terminology, another word for table is

  • row
  • relation
  • field
  • attribute

Q7. In a typical online production environment, who has direct access to the production database?

  • Database Administrator
  • Project Manager
  • UI/UX Designer
  • Developer

Q8. Which of the following is the database software used in this class?

  • SQLite
  • Oracle
  • Postgres
  • SQL Server
  • MySQL

Q9. What happens if a DELETE command is run on a table without a WHERE clause?

  • All the rows in the table are deleted
  • The first row of the table will be deleted
  • It is a syntax error
  • All the rows without a primary key will be deleted

Q10. Which of the following commands would update a column named “name” in a table named “Users”?

  • Users->name = ‘new name’ WHERE …
  • UPDATE Users SET name=’new name’ WHERE …
  •’new name’ WHERE …
  • UPDATE Users (name) VALUES (‘new name’) WHERE …

Q11. What does this SQL command do?


Hint: This is not from the lecture

  • It only retrieves the rows of Users if there are at least two rows
  • It counts the rows in the table Users
  • It is a syntax errror
  • It adds a COUNT column to the Users table

Using Databases with Python Week 03 Quiz Answers

Q1. What is the primary added value of relational databases over flat files?

  • Ability to execute JavaScript in the file
  • Ability to execute Python code within the file
  • Ability to quickly convert data to HTML
  • Ability to store data in a format that can be sent across a network
  • Ability to scan large amounts of data quickly

Q2. What is the purpose of a primary key?

  • To look up a row based on a string that comes from outside the program
  • To look up a particular row in a table very quickly
  • To point to a particular row in another table
  • To track the number of duplicate values in another column

Q3. Which of the following is NOT a good rule to follow when developing a database model?

  • Use a person’s email address as their primary key
  • Use integers as primary keys
  • Never repeat string data in more than one table in a data model
  • Model each “object” in the application as one or more tables

Q4. If our user interface (i.e., like iTunes) has repeated strings on one column of the user interface, how should we model this properly in a database?

  • Make a table that maps the strings in the column to numbers and then use those numbers in the column
  • Put the string in the first row where it occurs and then put that row number in the column of all of the rest of the rows where the string occurs
  • Put the string in the first row where it occurs and then put NULL in all of the other rows
  • Encode the entire row as JSON and store it in a TEXT column in the database
  • Put the string in the last row where it occurs and put the number of that row in the column of all of the rest of the rows where the string occurs

Q5. Which of the following is the label we give a column that the “outside world” uses to look up a particular row?

  • Local key
  • Remote key
  • Primary key
  • Logical key
  • Foreign key

Q6. What is the label we give to a column that is an integer and used to point to a row in a different table?

  • Foreign key
  • Local key
  • Primary key
  • Remote key
  • Logical key

Q7. What SQLite keyword is added to primary keys in a CREATE TABLE statement to indicate that the database is to provide a value for the column when records are inserted?


Q8. What is the SQL keyword that reconnects rows that have foreign keys with the corresponding data in the table that the foreign key points to?

  • JOIN

Q9. What happens when you JOIN two tables together without an ON clause?

  • The rows of the left table are connected to the rows in the right table when their primary key matches
  • You get all of the rows of the left table in the JOIN and NULLs in all of the columns of the right table
  • Leaving out the ON clause when joining two tables in SQLite is a syntax error
  • The number of rows you get is the number of rows in the first table times the number of rows in the second table
  • You get no rows at all

Q10. When you are doing a SELECT with a JOIN across multiple tables with identical column names, how do you distinguish the column names?

  • tablename[‘columnname’]
  • tablename/columnname
  • tablename.columnname
  • tablename->columnname

Using Databases with Python Week 04 Quiz Answers

Q1. How do we model a many-to-many relationship between two database 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
  • We use a BLOB column in both tables

Q2. In Python, what is a database “cursor” most like?

  • A function
  • A method within a class
  • A file handle
  • A Python dictionary

Q3. What method do you call in an SQLIte cursor object in Python to run an SQL command?

  • execute()
  • send()
  • socket()
  • run()

Q4. In the following SQL,

cur.execute('SELECT count FROM Counts WHERE org = ? ', (org, ))
what is the purpose of the "?"?
  • It allows more than one boolean operation in the WHERE clause
  • It is a syntax error
  • It is a placeholder for the contents of the “org” variable
  • It is a search wildcard

Q5. In the following Python code sequence (assuming cur is a SQLite cursor object),

1.cur.execute('SELECT count FROM Counts WHERE org = ? ', (org, ))
2.row = cur.fetchone()

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

  • An empty list
  • An empty dictionary
  • None
  • -1

Q6. What does the LIMIT clause in the following SQL accomplish?

SELECT org, count FROM Counts
  • It only retrieves the first 10 rows from the table
  • It only sorts on the first 10 characters of the column
  • It reverses the sort order if there are more than 10 rows
  • It avoids reading data from any table other than Counts

Q7. What does the executescript() method in the Python SQLite cursor object do that the normal execute() method does not do?

  • It allows embedded JavaScript to be executed
  • It allows multiple SQL statements separated by semicolons
  • It allows embeded Python to be executed
  • It allows database tables to be created

Q8. What is the purpose of “OR IGNORE” in the following SQL:

  • It makes sure that if a particular title is already in the table, there are no duplicate rows inserted
  • It ignores errors in the SQL syntax for the statement
  • It updates the created_at value if the title already exists in the table
  • It ignores any foreign key constraint errors

Q9. What do we generally avoid in a many-to-many junction table?

  • An AUTOINCREMENT primary key column
  • A logical key
  • Two foreign keys
  • Data items specific to the many-to-many relationship
Get All Course Quiz Answers of Python for Everybody Specialization

Course 01: Programming for Everybody (Getting Started with Python)

Course 02: Python Data Structures

Course 03: Using Python to Access Web Data

Course 04: Using Databases with Python

Course 05: Capstone: Retrieving, Processing, and Visualizing Data with Python

Team Networking Funda
Team Networking Funda

We are Team Networking Funda, a group of passionate authors and networking enthusiasts committed to sharing our expertise and experiences in networking and team building. With backgrounds in Data Science, Information Technology, Health, and Business Marketing, we bring diverse perspectives and insights to help you navigate the challenges and opportunities of professional networking and teamwork.

Leave a Reply

Your email address will not be published. Required fields are marked *