Graded Quiz: Importing Data Sets:Data Analysis with Python (Applied Data Science Specialization) Answers 2025
1. What Python library is primarily used for machine learning?
-
❌ pandas
-
❌ Numpy
-
❌ matplotlib
-
✅ scikit-learn
Explanation: scikit-learn is the standard library for machine learning algorithms in Python.
2. Which command correctly replaces the column headers of a DataFrame?
-
❌ df.tail() = headers_list
-
✅ df.columns = headers_list
-
❌ df.tail(headers_list)
-
❌ df.head(headers_list)
Explanation: df.columns holds the list of column names and can be reassigned directly.
3. Load “A.csv” into a DataFrame
-
❌ df.tail(“A.csv”)
-
✅ df = pandas.read_csv(“A.csv”)
-
❌ df.columns = “A.csv”
-
❌ pandas.load_data(“A.csv”)
Explanation: read_csv() is the correct function to import CSV files.
4. Best data type for cylinders (4, 6, 8)
-
❌ float64
-
❌ string
-
✅ int64
-
❌ object
Explanation: Cylinder values are whole numbers; integer type is most suitable.
5. Which shows descriptive stats for all columns?
-
❌ df.info()
-
✅ df.describe(include = “all”)
-
❌ df.summary(include = “all”)
-
❌ df.describe()
Explanation: include="all" ensures both numeric & object columns are included.
6. What type of variable is ‘price’?
-
❌ Independent variable
-
❌ Categorical variable
-
✅ Target variable
-
❌ Index variable
Explanation: Price is the output you want to predict → target/dependent variable.
7. Role of sqlite3.connect()?
-
❌ It exports the data to CSV
-
✅ It opens a connection to the specified database file
-
❌ It fetches query results
-
❌ It defines the SQL query
Explanation: connect() establishes a link between Python and the database.
8. Best library for visualizing trends?
-
❌ Numpy
-
❌ Pandas
-
❌ Scikit-learn
-
✅ Matplotlib
Explanation: Matplotlib is used for plotting and data visualization.
9. Assign a custom header list to DataFrame
-
❌ headers = df.columns()
-
❌ rename.columns(df, headers)
-
❌ df.labels = headers
-
✅ df.columns = headers
Explanation: df.columns is directly assigned a new list of headers.
10. First step after importing sqlite3
-
❌ Define cursor() directly
-
✅ Use connect() to establish connection
-
❌ Run SQL using execute()
-
❌ Apply fetchall()
Explanation: You must connect to the database before creating a cursor or executing queries.
🧾 Summary Table
| Q | Correct Answer | Key Concept |
|---|---|---|
| 1 | scikit-learn | ML library |
| 2 | df.columns = headers_list | Modify column names |
| 3 | pandas.read_csv | Load CSV |
| 4 | int64 | Numeric whole numbers |
| 5 | df.describe(include=”all”) | Full descriptive stats |
| 6 | Target variable | Prediction output |
| 7 | connect() | Connect to database |
| 8 | Matplotlib | Visualization |
| 9 | df.columns = headers | Assign headers |
| 10 | connect() | First DB step |