Download Here

Note : The Entire's Copyright And Credits Of the Above Material, Guide Or Question Paper is Owned by the Respected Owner and author of the Material. We had Uploaded This Only For Educational.

Top Corner Ads

Below Of Download Button

February 16, 2024

NPTEL Programming, Data Structures And Algorithms Using Python (Week 4 Quiz Assignment) 2024

4.5 Share It

Material Code -

Python Quiz

NPTEL Week 4 Quiz

1. Consider the following Python function.


def mystery(l, v):
    if len(l) == 0:
        return v
    else:
        return mystery(l[:-1], l[-1] + v)
        

What does mystery([22,14,19,65,82,55],1) return?

2. What is the value of triples after the following assignment?


triples = [(x, y, z) for x in range(2, 4) for y in range(2, 5) for z in range(5, 7) if 2*x*y > 3*z]
        

3. Consider the following dictionary.


runs = {"Test": {"Rahul": [90, 14, 35], "Kohli": [3, 103, 73, 42], "Pujara": [53, 15, 133, 8]},
        "ODI": {"Sharma": [37, 99], "Kohli": [63, 47]}}
        

Which of the following statements does not generate an error?

  • runs["ODI"]["Rahul"].append([74])
  • runs["ODI"]["Rahul"].extend([74])
  • runs["ODI"]["Rahul"][0] = 74
  • runs["ODI"]["Rahul"] = [74]

4. Assume that inventory has been initialized as an empty dictionary:


inventory = {}
        

Which of the following generates an error?

  • inventory["Amul"] = ["Mystic Mocha", 55]
  • inventory["Amul, Mystic Mocha"] = 55
  • inventory[["Amul", "Mystic Mocha"]] = 55
  • inventory[("Amul", "Mystic Mocha")] = 55

⚠️Disclaimer: The provided solutions are offered for reference purposes only, and we cannot guarantee their absolute accuracy. Students are encouraged to use these solutions as a learning aid and to verify their work independently. We emphasize the importance of understanding the concepts and completing assignments on your own.

Rating and Reviews

No comments:

Post a Comment