This article provided the solutions for NPTEL Joy Of Computing Using Python Week 3 Programming Assignment 2025. These programs passed all test cases. So, Come with us to know more about answers. If you didn't complete the week 3 quiz answers, the link is provided below.
Also Read: NPTEL Joy Of Computing Using Python Week 3 Quiz Answer
NPTEL Joy Of Computing Using Python Week 3 Programming Assignment 2025
Last Date: 13-02-2025
Q1. Create a Python program that finds the second smallest number in a list of positive integers (including zero). The program should prompt the user to input a list of numbers, then compute and print the second smallest number in that list.
Input Format:
- The input consists of a single list of numbers, separated by spaces.
- Hint: Use .split() function to convert input to list.
Output Format:
- The output consists of the second smallest number in the input list.Â
Example:Â
Input: 3 1 4 1 5 9 2 6 5 3 5Â
Output: 2
Program Code:Â
def find_second_smallest(numbers):Â Â unique_numbers = list(set(numbers))Â ÂÂ Â if len(unique_numbers) < 2:Â Â Â Â return "No second smallest number available"Â Â unique_numbers.sort()Â Â return unique_numbers[1]numbers = list(map(int, input().split()))print(find_second_smallest(numbers),end="") {codeBox}
Q2. Create a Python program that removes even duplicate positive integer numbers(includes zero) from a list and prints the unique numbers in the order they first appeared.Â
The program should prompt the user to input a list of numbers, then process the list to remove duplicates and print the resulting list of unique numbers.
Input Format:
The input consists of a single list of numbers, separated by spaces.
Output Format:
The output consists of the unique numbers, separated by spaces, from the input list, in the order they first appeared.
Example:
Input:
3 1 4 1 5 9 2 6 5 3 5
Output:
3 1 4 1 5 9 2 6 5 3 5
Program Code:
def remove_even_duplicates(numbers):Â Â seen = set()Â Â unique_numbers = []Â Â for num in numbers:Â Â Â Â if num % 2 != 0 or num not in seen:Â Â Â Â Â Â unique_numbers.append(num)Â Â Â Â Â Â seen.add(num)Â Â return unique_numbersnumbers = list(map(int, input().split()))print(" ".join(map(str, remove_even_duplicates(numbers))),end="") {codeBox}
Q3. Create a Python program that takes a list of integers, reverses the list, adds the values at even indices from both the original and reversed lists, and creates a new list with the result. The new list should be printed in the end.
Input Format:
The input consists of a single list of integers, separated by spaces.
Output Format:
The output consists of the new list of values, separated by spaces, obtained by adding values at even indices from both the original and reversed lists.
Example:
Input:
1 2 3 4 5
Output:
6 2 6 4 6
Program Code:
def process_list(nums):  reversed_nums = nums[::-1] Â  result = []  Â  for i in range(len(nums)):    if i % 2 == 0: # Only consider even indices      result.append(nums[i] + reversed_nums[i])    else:      result.append(nums[i]) Â  return resultnums = list(map(int, input().split()))result = process_list(nums)print(" ".join(map(str, result)), end="") {codeBox}
Conclusion
For any more Updates or Further Upcoming Assignments, Join the Telegram provided below.
           👉 CLICK HERE