NPTEL Joy of Computing Using Python

NPTEL Joy of Computing Using Python Week 11 Programming Assignment Solutions 2026 (Complete Code & Explanation)

Introduction

If you are currently enrolled in the NPTEL Joy of Computing Using Python course, Week 11 assignments can feel slightly challenging, especially if you are new to problem-solving with Python. But don’t worry—this guide is designed to make things simple.

In this blog, we will cover all three programming assignments in a clear, beginner-friendly way, along with correct Python code and short explanations. The goal is not just to help you submit your assignment, but also to understand the logic behind each solution.

Additionally, this guide is structured in a way that even beginners can follow without confusion. Each problem is broken down into simple steps so you can easily understand how the solution works. Instead of memorizing code, you will learn the concepts behind it, which is essential for long-term success in programming. By the end of this blog, you will have a better grasp of Python fundamentals and feel more confident while solving similar problems in exams or real-world scenarios.

Course Overview (Week 11 Focus)

Week 11 mainly focuses on:

  • String manipulation
  • Date handling in Python
  • Working with built-in modules
  • Writing clean and efficient logic

These concepts are important not only for exams but also for real-world programming.

✅ Q1. Character Reduction Game

❓ Question

You are given two strings. Remove all common characters (one from each string). Repeat the process until no common characters remain.

👉 Finally, print the total number of remaining characters.

💻 Python Code

s1 = input().strip()
s2 = input().strip()

from collections import Counter

c1 = Counter(s1)
c2 = Counter(s2)

for ch in c1:
if ch in c2:
common = min(c1[ch], c2[ch])
c1[ch] -= common
c2[ch] -= common

print(sum(c1.values()) + sum(c2.values()))

🧠 Explanation

  • Count characters in both strings
  • Remove common characters using minimum frequency
  • Add remaining characters

👉 This ensures all test cases pass correctly.

✅ Q2. Academic Date Gap Calculator

❓ Question

You are given two dates in YYYY-MM-DD format.

👉 Find the absolute number of days between them.

  • Order does not matter
  • Leap years should be handled
  • Same date → output 0

💻 Python Code

from datetime import datetime

d1 = input().strip()
d2 = input().strip()

date1 = datetime.strptime(d1, “%Y-%m-%d”)
date2 = datetime.strptime(d2, “%Y-%m-%d”)

print(abs((date2 date1).days))

🧠 Explanation

  • Convert string → date using datetime
  • Subtract dates → gives difference
  • Use abs() to ensure positive result

👉 Python automatically handles leap years.

✅ Q3. Monthly Calendar Generator

❓ Question

You are given a year and a month (1–12).

👉 Print the calendar in standard format:

  • Week starts from Monday
  • Ends on Sunday

💻 Python Code

import calendar

year = int(input().strip())
month = int(input().strip())

cal = calendar.TextCalendar(firstweekday=0)
print(cal.formatmonth(year, month))

🧠 Explanation

  • Use Python’s built-in calendar module
  • formatmonth() prints full calendar
  • firstweekday=0 ensures Monday start

👉 Output matches real calendar format.

Common Mistakes to Avoid

Many students lose marks due to small mistakes:

  • ❌ Wrong input format
  • ❌ Indentation errors in Python
  • ❌ Not using built-in modules properly
  • ❌ Overcomplicating simple logic

👉 Keep your code clean and simple.

Tips to Score Better

  • Practice similar problems
  • Understand logic instead of copying
  • Test your code with different inputs
  • Use Python built-in modules when needed

Final Conclusion

Week 11 assignments are designed to test your real understanding of Python basics. From string operations to date calculations and calendar formatting, these problems cover practical concepts.

If you go through each solution carefully and understand the logic, you will not only complete your assignment successfully but also improve your programming skills.

👉 Don’t just copy the code—try to run it, modify it, and learn from it.

In addition, practicing these types of problems regularly will help you build confidence in coding and improve your problem-solving ability. These questions are not only useful for exams but also for real-world applications where logical thinking and clean coding are important. Try experimenting with different inputs and edge cases to fully understand how the code works. Over time, this approach will make you more comfortable with Python and prepare you for advanced topics and technical interviews.

For more Opportunities Click Here