databases and sql for data science with python coursera week 4 quiz answers
Practice Quiz
1. Which API do you use to connect to a database from Python?
- DB API such as ibm_db API
- Watson API
- REST API
- Census API
2. In the ibm_db API, what is the commit() method used for?
- The commit() method is used to close a database connection.
- The commit() method is used to commit any pending transaction to the database.
- The commit() method is used to reverse any transactions that fail.
- The commit() method is used to open a database for connection.
3. True or false: Resources used by the ibm_db API are released automatically when the program ends. There is no need to specifically close the connection.
- False
- True
4. To create a table from Python, you would use...
- An ibm_db.exec_immediate function that includes connection information and a SQL statement to create the table.
- You cannot create a table from Python.
- An ibm_db.exec_immediate function that includes a SQL statement to create the table.
- An ibm_db.exec_immediate function that includes connection information.
5. Which of the following is a correct example of the connect function?
- connect(‘username’, ‘password’)
- connect(‘database name’, ‘username’, ‘database type’)
- connect(‘database name’, ‘username’, ‘password’)
- connect(‘database port’, ‘username’, ‘password’)
Graded Quiz: Database access from Python
6. The ibm_db API provides a variety of useful Python functions for accessing and manipulating data in an IBM data server like Db2. Is this statement True or False?
- True
- False
7. A Dataframe represents a tabular, spreadsheet-like data structure containing an ordered collection of columns, each of which can be a different value type. Indicate whether the following statement is True or False:
A pandas dataframe in Python can be used for storing the result set of a SQL query.
- True
- False
8. Which of the following statement(s) about Python is NOT correct (i.e. False)?
- The Python ecosystem is very rich and provides easy to use tools for data science.
- Due to its proprietary nature, database access from Python is not available for many databases.
- There are libraries and APIs available to access many of the popular databases from Python.
- Python is a popular scripting language for connecting and accessing databases.