Quiz – Software Engineer – Python & XML

Quiz – Software Engineer – Python & XML

This quiz will be used to assess your knowledge and problem-solving ability.

Normally this quiz should take less than 30 minutes to complete.
Please start this quiz if you have the time, and complete it as soon as possible as the duration will also be an evaluation criteria.

 What will be the output of the following Python function when called with mystery(7, 3)?

def mystery(a, b): 
if b == 0:
return 1
if b % 2 == 0:
return mystery(a * a, b // 2)
return a * mystery(a * a, (b - 1) // 2)

 

 

Given the following XML document, what would be the correct XPath query to retrieve the price of the second book?
<library>
    <book>
        <title>Python Fundamentals</title>
        <author>John Doe</author>
        <price currency="USD">29.99</price>
    </book>
    <book>
        <title>Advanced XML Processing</title>
        <author>Jane Smith</author>
        <price currency="EUR">39.50</price>
    </book>
</library>
    
XML Code Display
Given the following XML structure, what is the correct interpretation of the document?
<store>
    <product id="001">
        <name>Laptop</name>
        <price currency="USD">1200.00</price>
        <availability>In Stock</availability>
    </product>
    <product id="002">
        <name>Smartphone</name>
        <price currency="USD">800.00</price>
        <availability>Out of Stock</availability>
    </product>
</store>