0
0
Prompt Engineering / GenAIml~20 mins

Document loading and parsing in Prompt Engineering / GenAI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Document Parsing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this document parsing code?
Consider the following code that loads and parses a JSON document string. What will be the value of parsed_data after running this code?
Prompt Engineering / GenAI
import json
json_string = '{"name": "Alice", "age": 30, "skills": ["Python", "ML"]}'
parsed_data = json.loads(json_string)
A{'name': 'Alice', 'age': 30, 'skills': ['Python', 'ML']}
B{"name": "Alice", "age": 30, "skills": ["Python", "ML"]}
C{'name': "Alice", 'age': 30, 'skills': ["Python", "ML"]}
D{"name": 'Alice', "age": 30, "skills": ['Python', 'ML']}
Attempts:
2 left
💡 Hint
Remember that json.loads converts JSON strings into Python dictionaries with single quotes.
🧠 Conceptual
intermediate
1:30remaining
Which format is best for loading structured text documents for ML?
You want to load a large collection of structured text documents for machine learning. Which document format is most suitable for easy parsing and extracting fields?
ABinary files with custom encoding
BPlain text files with no structure
CEncrypted PDF files
DCSV files with columns for each field
Attempts:
2 left
💡 Hint
Think about formats that clearly separate data fields for easy extraction.
Metrics
advanced
1:00remaining
How to measure parsing success rate on a document dataset?
You have a dataset of 1000 documents to parse. Your parser successfully extracts data from 920 documents without errors. What is the parsing success rate?
A100%
B8%
C92%
D90%
Attempts:
2 left
💡 Hint
Success rate = (number of successful parses / total documents) * 100
🔧 Debug
advanced
2:00remaining
Why does this XML parsing code raise an error?
This code tries to parse an XML document but raises an error. What is the cause?
Prompt Engineering / GenAI
import xml.etree.ElementTree as ET
xml_string = '<root><item>Value</item></root>'
root = ET.parse(xml_string)
AET.parse expects a file path or file object, not a string of XML content
BThe XML string is malformed and missing closing tags
CET.parse cannot parse XML with nested tags
DThe xml.etree.ElementTree module is not imported correctly
Attempts:
2 left
💡 Hint
Check the expected input type for ET.parse.
Model Choice
expert
3:00remaining
Which model is best for extracting structured data from scanned document images?
You have scanned images of invoices and want to extract structured fields like date, total, and vendor name. Which AI model type is best suited for this task?
AConvolutional Neural Network (CNN) for image classification
BOptical Character Recognition (OCR) combined with Named Entity Recognition (NER)
CGenerative Adversarial Network (GAN) for image generation
DRecurrent Neural Network (RNN) for time series prediction
Attempts:
2 left
💡 Hint
Think about models that convert images to text and then extract information.