NPTEL Joy Of Computing Using Python Week 4 Assignment 2025

Hey, In this article, we will see the answers to NPTEL Joy of Computing Using Python Week 4 Assignment 2025.

Also Read: NPTEL Joy Of Computing Using Python Week 3 Assignment Answers 2025

Join us on Telegram 👉 CLICK HERE

NPTEL Joy Of Computing Using Python Week 4 Assignment 2025

NPTEL Joy Of Computing Using Python Week 4 Assignment 2025


In this Week 4, the following lectures are discussed:
  • Magic Square
  • Dobble Game
  • Birthday Paradox
  • Guess the Favourite Movie Name
Let's Start with the Assignment now,

Last Date: 19-02-2025

Q1. Which of the following options provides the general formula for the magic constant of a magic square of size n, where all elements are distinct numbers from 1 to n^2?

A. n (n^2+1) / 2
B. ( n^3 ) /2
C. (n^3+2n)/2
D. (n^4+n^2) /2n

Answer: [ A ] [ D ]

Which of the following options provides the general formula for the magic constant of a magic square of size n, where all elements are distinct numbers from 1 to n^2?

The formulas of  ' A' and ' D ' are the same. 

Which of the following options provides the general formula for the magic constant of a magic square of size n, where all elements are distinct numbers from 1 to n^2?


Q2. What would the magic constant be for a magic square of size 7, given that all elements in the square are distinct numbers from 1 to 49?

A. 260
B. 111
C. 175
D. 165

Answer: [ C ] 175 

We know that, Magic Constant Formula. 

Substitute n=7, in that 
  = (n*n*n  + n ) / 2 
  = (7*7*7 + 7 ) / 2
  = ( 343+7 ) / 2
  = ( 350 ) / 2
  = 175

Q3. Does transposing any magic square change the sum across some rows/columns/diagonal?

A. Yes
B. No

Answer: [ B ] No

If we transpose the matrix and add the sum across row,  column or diagonal, the sum won't change. 
Does transposing any magic square change the sum across some rows/columns/diagonal?


Q4. Which of the following are valid magic squares? 

Answer: [ A ] [ C ] [ D ]  

The sum of the matrices which we add up in a row or column is same, so we can say it is a magic square. 

eg: Option 1 
       ( 10+3+13+8 ) = 34  
       ( 10+5+4+15 ) = 34

Which of the following are valid magic squares?


Q5. What is the minimum number of people required to ensure that at least three of them share the same 30-minute birth interval? The intervals start from 12:00 AM and each interval lasts for half an hour.

Answer: 97

Q6. Calculate the magic constant for 5x5 square, where all elements are distinct numbers from 1 to 25, is it same as the magic constant for Ramanujan’s magic square? 

If yes, enter 0, else enter the absolute difference between the two.
Hint: Search the about Ramanujan’s magic square.

Answer: 74

We know that, Magic Constant Formula. 

Substitute n=5, in that 
  = (n*n*n  + n ) / 2 
  = (5*5*5 + 5 ) / 2
  = (125+5) /2 
  = (130) / 2
  =  65 

The sum of Ramanujan Magic Square is 139. 

The difference between them is 139-65 = 74. 

Calculate the magic constant for 5x5 square, where all elements are distinct numbers from 1 to 25, is it same as the magic constant for Ramanujan’s magic square?


Q7. What task does mystery1() perform?

def mystery1(number):
    list1 = []
    for i in range(1, number):
        if number % i == 0:
            list1.append(i)
    return list1

def mystery2(n1, n2):
    flag = False
    list2 = []
    for i in mystery1(n1):
        for j in mystery1(n2):
            if i == j:
                flag = True
                list2.append(i)
    if len(list2) > 1:
        print("Completed") {codeBox}

A. Calculate factorial of number n.
B. Calculate factors of number n.
C. Calculate factors of number n+1 excluding n.
D. Calculate factors of number n excluding n.

Answer: [ D ] Calculate factors of number n excluding n.

Q8. For what n1, n2 will the variable flag inside mystery2() be equal to True?

A. 1,2
B. 2,3
C. 3,4
D. 0,0

Answer: [ B, C ] ( 2, 3 ) ( 3, 4 )

Q9. If all possible pairs of prime numbers between 0 and 10, are given to n1 and n2, for how many pairs would 2 print ”Completed”?

A. It will print ”Completed” only for pairs (2,3)(7,2),(2,5), and for the remaining it would not print ”Completed”.
B. It will print ”Completed” only for pair (2,3), and for the remaining other pairs of primes it would not print ”Completed”.
C. It will print ”Completed” for all pairs of primes between 0 and 20.
D. It will not print ”Completed” for any pair.

Answer: [ D ] It will not print ”Completed” for any pair.

Q10. If numbers of pairs of primes which result in mystery2 to print ”Completed” are lesser than 1, Can we edit the code in mystery2() so that ”Completed” is always printed for any pair of primes?

A. Yes, we can change the logic for setting flag variable to False.
B. No, it is logically not possible.
C. Yes, we can change/decrease the threshold for length of list2 in the last if block.
D. Yes, we can change the initial value of flag to False, instead of True.

Answer: [ C ] Yes, we can change/decrease the threshold for length of list2 in the last if block.

Conclusion

If any changes in answer,  visit the website on or before to last date. For any Queries, mail us at [email protected] 

Join us on Telegram 👉 CLICK HERE

One Comment Please !

Post a Comment (0)
Previous Post Next Post