Final Exam for the Course :Python for Data Science, AI & Development (IBM Data Analyst Professional Certificate) Answers 2025
1. Question 1
In Python, which data type represents text?
-
❌ int
-
❌ float
-
❌ complex
-
✅ str
Explanation:
The str type is used for text in Python.
2. Question 2
Index returned from Name = “EMILY”
-
❌ Name.find(“I”)
-
❌ Name.find(“L”)
-
✅ Name.find(“E”)
-
❌ Name.find(“Y”)
Explanation:
“E” is at index 0 in "EMILY".
3. Question 3
Double slash // division result:
-
❌ Rounded up
-
❌ Fractional part only
-
✅ Truncated to integer part
-
❌ Same as division
Explanation:// gives integer (floor) division.
4. Question 4
How many identical keys can a dictionary have?
-
❌ 3
-
❌ 0
-
❌ No limit
-
✅ 1
Explanation:
Dictionary keys must be unique.
5. Question 5
What does A[0] return?
-
✅ The first element
-
❌ Second
-
❌ Last
-
❌ Third
Explanation:
Index 0 means the first element.
6. Question 6
‘1,2,3,4’.split(‘,’) →
-
❌ ‘1234’
-
❌ ‘1’,’2′,’3′,’4′
-
✅ [‘1′,’2′,’3′,’4’]
-
❌ (‘1′,’2′,’3′,’4’)
Explanation:split() returns a list.
7. Question 7
Which collection is unordered, unindexed, no duplicates?
-
❌ Dictionary
-
❌ Tuple
-
❌ List
-
✅ Set
Explanation:
A set is unordered and unique.
8. Question 8
If x = 1, output is:
Hi
Mike
Correct code:
-
❌ Option 1
-
❌ Option 2
-
❌ Option 3
-
✅ Last option
Explanation:if(x!=1) is false → goes to else → prints Hi, Mike.
9. Question 9
Forcing a program to show a pre-decided error message:
-
❌ Force out
-
❌ Error messages
-
✅ Exception handling
-
❌ Output errors
10. Question 10
Which add function returns 2?
-
❌ add(1) → 3
-
❌ add(‘1’) → ‘111’
-
✅ add(1) → (1+1) = 2
-
❌ add(‘1’) → “11”
Correct answer: third option.
11. Question 11
Output:
1
3
4
Correct code:
-
❌ if(i==2)
-
✅ if(i!=2)
-
❌ if(i!=5)
-
❌ if(i!=1)
12. Question 12
Rectangle height = ?
-
❌ ‘r’
-
❌ 2
-
❌ 0
-
✅ 3
Explanation:
Default value: height = 3.
13. Question 13
You cannot sort a list if it contains:
-
❌ concatenated strings
-
❌ only numeric values
-
❌ same case strings
-
✅ strings and numeric values
Explanation:
Mixed types cannot be compared in sorting.
14. Question 14
a*b →
-
❌ array([1,1,1,1,1])
-
❌ 0
-
❌ 1
-
✅ array([0,0,0,0,0])
Explanation:
Element-wise multiply:
0*1=0, 1*0=0 → all zeros.
15. Question 15
a+1 →
-
❌ [101,91…]
-
✅ [11,10,9,8,7]
-
❌ Other options
16. Question 16
Which headers selected?
-
❌ Artist, Length, y
-
❌ Does not select headers
-
✅ Artist, Length, Genre
-
❌ ‘df’, Artist, Length
17. Question 17
readline() does what?
-
❌ reads 10 lines
-
❌ entire file
-
✅ reads one full line
-
❌ always first line
18. Question 18
Mode to write text at end of file:
-
✅ Append “a”
-
❌ Write “w”
-
❌ Read “r”
-
❌ rb
19. Question 19
Scheme, internet address, route are parts of:
-
✅ URL
-
❌ Error message
-
❌ API
-
❌ Text file
20. Question 20
Function to extract table from webpage directly:
-
❌ read_xml
-
❌ read_json
-
✅ read_html
-
❌ read_csv
🧾 Summary Table
| Q | Correct Answer | Key Concept |
|---|---|---|
| 1 | str | Python text type |
| 2 | Name.find(“E”) | Indexing strings |
| 3 | Integer division (//) | Truncation |
| 4 | 1 | Dict unique keys |
| 5 | First element | Indexing |
| 6 | [‘1′,’2′,’3′,’4’] | split() |
| 7 | Set | Unordered/unique |
| 8 | Last option | if/else flow |
| 9 | Exception handling | Error control |
| 10 | add(1) returns 2 | Functions |
| 11 | If(i!=2) | Loop filtering |
| 12 | 3 | Constructor default |
| 13 | strings + numbers | Sorting rules |
| 14 | [0,0,0,0,0] | NumPy multiply |
| 15 | [11,10,9,8,7] | Broadcasting |
| 16 | Artist, Length, Genre | DataFrame columns |
| 17 | Read one line | File I/O |
| 18 | Append “a” | File modes |
| 19 | URL | Web structure |
| 20 | read_html | Web tables |