Need help with this week’s assignment? Get detailed and trusted solutions for The Joy of Computing using Python Week 1 NPTEL Assignment Answers. Our expert-curated answers help you solve your assignments faster while deepening your conceptual clarity.
✅ Subject: The Joy of Computing using Python
📅 Week: 1
🎯 Session: NPTEL 2025 July-October
🔗 Course Link: Click Here
🔍 Reliability: Verified and expert-reviewed answers
📌 Trusted By: 5000+ Students
For complete and in-depth solutions to all weekly assignments, check out 👉 NPTEL The Joy of Computing using Python Week 1 NPTEL Assignment Answers
🚀 Stay ahead in your NPTEL journey with fresh, updated solutions every week!
NPTEL The Joy of Computing using Python Week 2 Assignment Answers 2025
1. What is the most appropriate data type to take customer input, calculate final price, and print the savings?
- int
- float
- bool
- str
Answer : See Answers
2. What is the correct Python syntax to take customer purchase amount as input?
- input(float())
- float(input())
- input = float()
- float = input()
Answer :
3. Which of the following correctly applies a 20% discount on the purchase amount stored in a variable amount?
- discounted = amount * 0.2
- discounted = amount – (amount * 0.2)
- discounted = amount / 20
- amount = amount*0.8
Answer :
4. If a customer spends more than ₹5000, they get a 20% discount. Which of the following is the correct if statement to check this?
- if amount > 5000:
- if amount >= 5000:
- if amount = 5000:
- if amount => 5000:
Answer :
5. What will be the output of the following code if the amount entered is 6000?

- 6000
- 4800
- 5000
- 1200
Answer :
6. Ria wants to show the customer how much they saved. Which line of code correctly prints both the original price and the savings using f-strings?
- print(“Original: ₹”, amount, “Saved: ₹”, saved)
- print(f”Original: ₹{amount}, Saved: ₹{saved}”)
- print(f’Original = ₹amount, Saved = ₹saved’)
- print(“Original ₹f{amount}, Saved ₹f{saved}”)
Answer : See Answers
7. Identify the error in the following code:

- Missing else block
- input cannot be used with float
- Colon is missing after if condition
- float should be int
Answer :
8. What is the final price after applying the following logic?

- 4000
- 3600
- 3200
- 3500
Answer :
9. Which of the following best implements nested if logic to apply 20% discount if amount > 5000 and is a loyalty customer? Assume: is_loyal = True




Answer :
10. What will be the output of the following program if the user inputs 4500?

- Final Price: 4050.0
- Final Price: 4499.9
- Final Price: 4500.0
- Final Price: 4499.9
Answer :
11. Which Python loop is most suitable to print the multiplication table of a number from 1 to 10?
- while loop
- for loop
- if loop
- do-while loop
Answer :
12. Ravi writes the following code to print the multiplication table of 5. What will be the output of the first line?

- 5 x 0 = 0
- 5 x 1 = 5
- 1 x 5 = 5
- 5 x 11 = 55
Answer :
13. What will be the output of range(1, 11) inside a for loop?
- 1 to 10 (inclusive)
- 0 to 10 (inclusive)
- 1 to 11 (inclusive)
- 1 to 9 (inclusive)
Answer :
14. Which of the following loops will correctly continue asking the user for a number until they enter 0?




Answer :
15. What is the total number of lines printed by the following code ?

- 7
- 10
- 11
- 0
Answer : See Answers
16. Ravi wants to track how many tables were generated before the student exited. Which of the following variables and logic should be used?
- Use count = 0, increment count by 1 inside the loop each time a table is printed
- Use count = 1, decrement each time
- Use count = 10, multiply inside the loop
- No counter is needed
Answer :
17. What will be the output of the following code?

- Prints multiples of 3 up to 15
- Prints an error
- Infinite loop
- Prints nothing
Answer :
18. Ravi wants the output to look like: 5 x 1 = 5 but accidentally writes:

For input num = 5, i = 1, what will be printed?
- 5 x 1 = 5
- 1 x 5 = 5
- x 5 = 5
- i x num = result
Answer :
19. Which keyword is used to skip the current iteration of a loop and continue with the next one?
- stop
- break
- continue
- pass
Answer :
20. What will this code output if the user enters the following numbers sequentially in the terminal: 3, 4, 5, 0?

- 3 tables printed, followed by: “You practiced 3 tables.”
- Infinite loop
- Error due to missing condition
- 4 tables printed
Answer :
In the quiet village of Phulera, the computer in the Panchayat office starts displaying strange numbers. Abhishek Sir, the village secretary, thinks it might be a software glitch. But his close friends Vikas and Prahlad suspect something else — maybe it’s a secret code!
They notice the numbers follow some strange patterns:
. Armstrong numbers (like 153)
. Neon numbers (like 9 → 9² = 81 → 8 + 1 = 9)
. Palindrome numbers (like 121)
So, the team writes a Python program to check if a number is an Armstrong number — one of the patterns they suspect is being used.
21.

What is the role of the first while loop in the program?
- It checks whether the number is divisible by 10
- It calculates the cube of digits
- It finds how many digits are in the number
- It stores the reverse of the number
Answer : See Answers
22. What will be the output when the input is 9474?
- Armstrong Number
- Not an Armstrong Number
- Error due to integer overflow
- Infinite loop
Answer :
23. How many times does the body of each while loop execute when the input is 1000?
- 3
- 4
- 5
- It never executes
Answer :
24. What is the value of sum immediately after the second while loop finishes when the input is 370?
- 0
- 370
- 3700
- 27
Answer :
25. If the line temp = num that appears just before the second loop is deleted, what will the program output for input 9474?
- Armstrong Number
- Not an Armstrong Number
- The program hangs
- Raises NameError
Answer :
26. During execution with input 1000, what is the value of digit in the third iteration of the second while loop?
- 0
- 1
- 10
- The loop has no third iteration
Answer :
27. Which replacement for the line if sum == original: will make the program print “Armstrong Number” for every positive input but “Not an Armstrong Number” for zero?
- if sum >= original:
- if original != 0:
- if original > 0:
- if True:
Answer :
28. What final value does count take when the input is 1634?
- 3
- 4
- 5
- 6
Answer :
29. Which single-line change will guarantee that no input at all (including 0) is reported as an Armstrong number?
- Initialize sum to 1 instead of 0
- Initialize count to 1 instead of 0
- Replace digit = temp % 10 with digit = abs(temp % 10)
- Change the condition to if sum >= original:
Answer :
30. What does the program print when the user enters -153?
- Armstrong Number
- Not an Armstrong Number
- Infinite loop
- Raises ValueError
Answer : See Answers
NPTEL The Joy of Computing using Python Week 2 Assignment Answers 2024
1. At any given point during a program’s execution, what value is held within a variable?
- The value it was initially assigned when it was created.
- The sum of all values that have ever been assigned to it.
- The most recent value that was assigned to it.
- The average of all values that have ever been assigned to it.
Answer: c
Explanation: A variable always holds the most recently assigned value during program execution, replacing any previous values.
2. What will be the output of the following Python code snippet?

Which of the following represents the correct output if the user inputs “25”?
- The value is: 25
- 25
- The value is:
- None of the above
Answer: a
Explanation: If the code includes a print statement like print("The value is:", value) and user inputs “25”, the output will be "The value is: 25".
3. What are the possible loop values that can be specified in the range argument of a for loop in Python, and why are these values used?
- Integers, representing the starting and ending points of the loop, allowing iteration through a specified range of numbers.
- Floating-point numbers, enabling iteration through decimal ranges with precise steps.
- Strings, facilitating iteration through characters in a specified string
- Tuples, allowing iteration through multiple sequences simultaneously.
Answer: a
Explanation: The range() function in Python works only with integers, which specify where to start and stop iteration.
4. What values can be used in the argument of a while loop in Python, and why are these values used?
- Integers, representing the starting and ending points of the loop, allowing iteration through a specified range of numbers
- Boolean expressions or conditions, enabling the loop to execute until the condition becomes False.
- Floating-point numbers, allowing iteration through decimal ranges with precise steps.
- Strings, facilitating iteration through characters in a specified string.
Answer: b
Explanation: A while loop in Python continues running as long as its Boolean condition evaluates to True.
5. What types of conditional entries can be used in a Python if statement, and why are these entries used?
- Integers, representing specific numeric values to check against a variable, ensuring a match for equality
- Boolean expressions or conditions, evaluating to True or False and determining the path of execution in the code.
- Strings, enabling comparison of text values for exact matches in the condition
- Floating-point numbers, allow range-based conditions to check if a variable falls within a specific numerical range.
Answer: b
Explanation: Python if statements depend on Boolean expressions to decide whether a block of code should be executed.
6. Consider the following code snippet:

What does the code do?
- Takes an input n, computes the multiplication table of n from 1 to 10, and prints each multiplication.
- Takes an input n, computes the multiplication table of n from 1 to 11, and prints the final product.
- Takes an input n, computes the multiplication table of n from 1 to 10, and prints the final product.
- Takes an input n, initializes i to 1, and prints the multiplication of n and i without any loop.
Answer: a
Explanation: A loop running from 1 to 10 will multiply n with each i and print the result, forming a multiplication table.
7. Consider the following code snippet:

What does the code do?
- Takes an input number, computes the multiplication table of numbers from 1 to 10, and prints each multiplication
- Takes an input number, computes the multiplication table of numbers from 1 to 11, and prints the final product.
- Takes an input number, computes the multiplication table of numbers from 1 to 10, and prints the final product.
- Takes an input number, initializes i to 1, and prints the multiplication of number and i without any loop.
Answer: a
Explanation: This loop prints each step of the multiplication table one by one from 1 to 10.
8. Consider the following code snippet:

What does the code do?
- Takes an input num, computes the factorial of num, and prints the factorial value.
- Takes an input num, computes the product of numbers from 1 to num, and prints the final product.
- Takes an input num, computes the sum of numbers from 1 to num, and prints the final sum.
- Takes an input num, initializes the result to 1, and prints the value of the result without any factorial computation.
Answer: a, b
Explanation: Computing factorial involves multiplying numbers from 1 to num, which matches both the first and second options.
9. An Integrated Development Environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. Which of the following are IDEs?
- PyCharm
- Spyder
- Visual Studio Code (VS Code)
- C# (pronounced “C sharp”)
Answer: a, b, c
Explanation: PyCharm, Spyder, and VS Code are all IDEs. C# is a programming language, not an IDE.
10. A Python distribution is a software bundle, which contains a Python interpreter and the Python standard library. What is Anaconda being discussed in lectures?
- A species of snake
- A type of programming language
- An integrated development environment (IDE)
- A Python distribution for scientific computing and data science
Answer: d
Explanation: Anaconda is a Python distribution that includes tools like Jupyter, NumPy, Pandas, and is widely used in data science.


