NPTEL The Joy of Computing using Python Week 4 Assignment Answers 2024

Join Our WhatsApp Group Join Now
Join Us On Telegram Join Now

NPTEL The Joy of Computing using Python Week 4 Assignment Answers 2024

1. Select the correct statements regarding Magic Square:

  • Magic Square of Order 1 is Trivial
  • Sum of 2 magic squares is a magic square
  • Magic Square of Order 2 is not possible
  • The magic constant (the sum of row/columns/diagonal elements) for a 7*7 possible magic square is 260
Answer :- For Answer Click Here 

2. For which of the matrices would the following code snippet return True?

NPTEL The Joy of Computing using Python Week 4 Assignment Answers 2024
  • 834159672
  • 276951438
  • 672159834
  • 294753618
Answer :- For Answer Click Here 

3. Suppose you want to simulate the Birthday Paradox by generating random birthdays for a group of people. Which library function would you most likely use to create random integers representing birthdays?

  • random.randint()
  • time.time()
  • random.random()
  • None of the above
Answer :- For Answer Click Here 

4. Which of the following are functions in the date-time module of Python?

  • datetime.now ()
  • datetime.present()
  • date.today()
  • date.now()
Answer :- 
NPTEL The Joy of Computing using Python Week 4 Assignment Answers 2024
Answer :- 

6. To implement a magic square, we use the concept of matrices. Select all the statements that are True in this context.

  • One possible Implementation of matrices is through nested lists in Python.
  • NumPy is one of the standard libraries associated with implementing matrices.
  • Implementation of matrices is only through lists in Python.
  • None of the above
Answer :- For Answer Click Here 

7. Consider the given dataset of 60 people born in 2000. Run your code using the given data to check the count of people whose birthdays fall exactly on a Tuesday.

NPTEL The Joy of Computing using Python Week 4 Assignment Answers 2024
  • 8
  • 9
  • 10
  • 11
Answer :- 

8. What is the output of the following snippet of code?
Hint:
If L = [1, 2, 3, 4, 5], then L[1: 3] is the list [2, 3]. Slicing a list is very similar to slicing a string. All the rules that you have learned about string-slicing apply to list-slicing.
If P = [1, 2, 3] and Q = [4, 5, 6] then P + Q is the list [1, 2, 3, 4, 5, 6]. Again, list concatenation is very similar to string concatenation.

NPTEL The Joy of Computing using Python Week 4 Assignment Answers 2024
  • [90, 47, 8, 18, 10, 7]
  • [7, 10, 18, 8, 47, 90]
  • [7, 8, 10, 18, 47, 90]
  • [90, 47, 18, 10, 8, 7]
Answer :- 

9. What does the random. choice () function do?

  • Generates a random integer.
  • Selects a random element from a sequence.
  • Chooses a random floating-point number.
  • Generates a random Boolean value.
Answer :- 

10. Identify the magic squares from the following:

NPTEL The Joy of Computing using Python Week 4 Assignment Answers 2024
Answer :- For Answer Click Here