Skip to content
CY-406 · Advance Python Programming/Important Questions

Advance Python Programming (CY-406) - Important Questions

  1. Unit 310 Marks High Priority

    Parse the provided XML and JSON data files and extract the required fields. Use ElementTree to parse the XML and the json module to parse JSON. Show the Python code, explain each step briefly, and display the exact program output for the given input.

    Core practical question repeatedly asked in past papers; tests parsing and extraction from both XML and JSON using standard Python libraries.

  2. Unit 37 Marks Medium Priority

    Write a Python program to fetch an HTML page (given URL), parse it using BeautifulSoup, and extract all hyperlinks (anchors) and image sources. Print the results in a tabular format and handle relative URLs correctly.

    Common practical task testing web-scraping and HTML processing skills using BeautifulSoup or html.parser.

  3. Unit 310 Marks Medium Priority

    Explain the differences between DOM-based parsing (e.g., ElementTree) and streaming parsing (SAX) for XML in Python. Implement a SAX or iterparse-based streaming parser to process a large XML file and extract specific element data without loading the entire file into memory. Provide code and brief explanations of memory and performance implications.

    Conceptual and coding question comparing parsing approaches; important for handling large XML files efficiently.

  4. Unit 37 Marks Medium Priority

    Demonstrate how to validate an XML document against an XSD schema in Python. Provide the code that performs validation, show how validation errors are reported, and give an example showing both a valid and an invalid XML instance.

    Practical validation task to ensure students know XML schema validation techniques available in Python.

  5. Unit 310 Marks Medium Priority

    Write a Python program to convert JSON data into an equivalent XML representation and vice versa. Discuss how JSON arrays, objects, and XML attributes are mapped, show code using standard/open-source libraries, and explain limitations or ambiguities in automated conversion.

    Interconversion between formats is a common practical requirement; tests understanding of structural mismatches and attribute handling.

  6. Unit 314 Marks Medium Priority

    Write a Python script to consume a paginated RESTful JSON API, handle HTTP errors and rate limiting, aggregate a specified field from all pages, and write the consolidated results to a CSV file. Include code, explanation of pagination handling, and error-recovery strategy.

    Integration and API consumption is essential for processing Internet data formats; assesses robustness and practical handling of real APIs.

  7. Unit 37 Marks Medium Priority

    Explain techniques to sanitize and escape HTML and JSON inputs in Python to prevent XSS and injection attacks. Provide short code examples demonstrating safe handling of user-supplied HTML content and safe JSON encoding for embedding in web pages.

    Security-focused practical question relevant when processing HTML/JSON inputs from untrusted sources.

  8. Unit 37 Marks Medium Priority

    Using lxml or an equivalent library, write Python code that applies XPath expressions to query a complex XML document and extract nodes matching given conditions (e.g., elements with a specific attribute value or nested structure). Show sample XPath queries and corresponding outputs.

    XPath proficiency is useful for concise queries on complex XML documents; often asked in practical form.

Go to where you left off?

Quick Add to Notes

Save questions, your own notes and screenshots into notes filed by unit. It takes a free account.

Create free account

Have an account? Log in