Welcome back, everyone! In this article, we'll walk you through the solutions for the Week 10 programming assignment of the NPTEL course "Joy of Computing Using Python." These answers are provided for reference, so feel free to use them as a guide. If you have any doubts or questions, don't hesitate to ask in the comments section below. Ready to dive in? Let's solve these problems together!Â
Join Telegram:Â Â CLICK HEREÂ Â
NPTEL Joy Of Computing Using Python Week 10 Programming Assignment 2024
Last Date: 03-10-2024Â
Q1.Â
Q2.Â
Write a program that accepts the string `para` and a positive integer `n` as input. The program should print `1` if there is at least one word in `para` that occurs exactly `n` times, and `0` otherwise.
Input Format:
- The input consists of two lines.
 - The first line contains the string `para`, which is a sequence of space-separated words.
 - The second line contains a positive integer `n`.
Output Format:
- A single integer, either `1` or `0`.
 - Print `1` if there is at least one word that occurs exactly `n` times.
 - Print `0` otherwise.
Example:
Input:
apple orange apple banana orange banana banana
2
Output:
1
Program Code:Â
Program Code:Â
# Input the paragraph and the integer npara = input().strip()n = int(input())# Split the paragraph into wordswords = para.split()# Create a dictionary to count the occurrences of each wordword_count = {}for word in words:Â Â word_count[word] = word_count.get(word, 0) + 1# Check if any word occurs exactly n timesfound = 0for count in word_count.values():Â Â if count == n:Â Â Â Â found = 1Â Â Â Â break# Output the resultprint(found,end="") {codeBox}
Q2.Â
Write a program that accepts a string of space-separated float numbers. The program should print the number of long tail numbers, where a float number is said to have a long tail if the number of digits after the decimal point is greater than the number of digits before the decimal point.
Input Format:
The input consists of a single line containing space-separated float numbers.
Output Format:
A single integer representing the number of long tail numbers.
Example:
Input:
12.3214 123.56 3.14159 100.1 45.6789
Output:
3
Program Code:Â
# Input the space-separated float numbersnumbers = input().strip().split()# Initialize a counter for long tail numberslong_tail_count = 0# Iterate over each float numberfor num in numbers:  # Split the number at the decimal point  before_decimal, after_decimal = num.split(".")  Â  # Check if digits after the decimal are greater than those before  if len(after_decimal) > len(before_decimal):    long_tail_count += 1# Output the count of long tail numbersprint(long_tail_count, end="") {codeBox}
Q3.
Write a program that accepts a space-separated string of integers representing a sequence of even length. The program should determine whether the sequence is left-heavy, right-heavy, or balanced. It should print:
- -1 if the sequence is left-heavy (left half sum > right half sum).
- 1 if the sequence is right-heavy (right half sum > left half sum).
- 0 if the sequence is balanced (both sums are equal).
Input Format:
The input consists of a single line containing space-separated integers.
Output Format:
A single integer: -1 for left-heavy, 1 for right-heavy, or 0 for balanced.
Example:
Input:
1 2 3 4 5 6
Output:
1
Program Code:Â
# Input the space-separated integerssequence = list(map(int, input().split()))# Calculate the middle index to split the sequencemid = len(sequence) // 2# Calculate the sum of the left half and the right halfleft_sum = sum(sequence[:mid])right_sum = sum(sequence[mid:])# Determine if the sequence is left-heavy, right-heavy, or balancedif left_sum > right_sum:Â Â print(-1,end="")elif right_sum > left_sum:Â Â print(1,end="")else:Â Â print(0,end=""){codeBox}