The Joy Of Computing Using Python Week 4 Assignment 2023

The Joy of Computing Using Python Week 4 assignment answers ?  Also, we will discuss about the Programming assignment answers of week 4. In this article we will discuss about the answers of week 4 of joy of computing. The answers shared here will be on our own knowledge. I am answering these questions with Confident. Please use this answers as reference only.  

Also Read:  The Joy of Computing Using Python Week 3 answers

About Nptel 

Nptel ( National Programme on technology and enhancement Learning) is a  wonderful platform to Students and Professionals . This Nptel is initiated in 2003 by Ministry of Human and Resource Development ( MHRD )  with the combination of IIT (Indian Institue of technology) and IIT sc ( Indian Institue of Sciences ) . To get the certificate , Certain criteria has to be followed: 

Average Score of assignments = 25% of average of 8 assignments , best of 8 assignments out of 12 assignments. 

Exam Score = 75% of Protocored Exam 

You will be for certificate for the exam if and only if Average assignment score >=10/25 and Exam Score >=30/75 . If any one of the 2 Criteria is not met, 

You will not get Certificate even if the final score >=40/100.   

The Joy Of Computing Using Python Week 4 Assignment 2023


The Joy Of Computing Using Python Week 4 Assignment 2023  

Below you can find the answers of week 4 assignment and also programming assignment. 

Q1. Which of the following statements are true with regards to magic square?

a. The sum of each row should be m.

b. The sum of each column should be m.

c. The sum of each diagonal should be m.

d. None of the above 

Answer:  [ a, b, c] 

Q2. Which of the following statements hold true about N in the magic square? N denotes the 

      number of rows and columns in the square. 

a. N should be even.

b. N should be odd. 

c. N can be even or odd

d. N can take any value

Answer:  [ b ]  N should be odd.  

Q3. Which of the following statements are true regarding the Magic Squares? 

       (N = Number of rows or columns) 

a. A magic square is always a square matrix .

b. A magic square is can or cannot be  a square matrix . 

c. The Sum of each row and each column is N(N+1 )/2.

d. The Sum of each row and each column is N(N2+1 )/2. 

Answer:  [ a, d ] 

Q4. What will be the output of the which is given below?

       Code: 

                 ' ' ' '

                 This is a sentence 

                 ' ' ' ' 

a. This is a sentence.

b. Error

c. No output

d. The program will not run. 

Answer:  [ c ] No Output

Q5. Which of the following operator is used to raise the exponent to a number?

a. ^

b. *

c. **

d. ***

Answer:  [ c ]  **

Q6. Suppose there is a movie with 3 letters, how many combinations of names are possible?

a. 26

b. 676

c. 17576

d. 456976

Answer:  [ c ]  17576

Q7. What should be the value of the a,b,c,d respectively?

                                       

What should be the value of the a,b,c,d respectively? 

a. 1, 3, 9, 7

b. 9, 3, 7, 1

c. 1, 7, 3, 9

d. 7, 3, 9, 1

Answer:  [ c ]  1, 7, 3, 9

Q8. What is the output of the given code?

Print unique movies of list L1

a.  Print unique movies of list L1

b.  Print unique movies of list L2

c.  Print unique movies of list L1 and L2

d.  It shows an error

Answer:  [ a ] Print unique movies of list L1

Q9. What is the output of the given code below?

      Code: 

                  for i in range (5, 20 ) : 

                        if ( i%5 == 0) : 

                            print( i**2 ) 

a. Print all perfect squares with square roots between 5-20 and divisible by 5.

b. Print all perfect squares with square roots between 5-20 and not divisible by 5.

c. Print all perfect squares with square roots between 5-19 and not divisible by 5.

d. Print all perfect squares with square roots between 5-19 and divisible by 5.

Answer:  [ d ]  Print all perfect squares with square roots between 5-19 and divisible by 5.

Q10.  A perfect number is a positive integer that is equal to the sum of its positive divisors, 

         excluding the number itself. For example, 6 is a perfect number as the sum of its 

         divisors 1,2,3 is equal to 6.

         Which function will return True if the number is a perfect number? 

Answer:  [ a ] 

           def perfect_number(num): 

                  ans=0

                  for i in range (1, num) : 

                        if ( num% i ==0 ) : 

                            ans = ans + i 

                  if ( ans == num ) : 

                      return True 

                  else : 

                       return False: 

 Programming Assignment : 

 Q1. Write a program that takes a number `n` as input and prints the sum of the squares of 
        the first `n` positive integers.

       Example:

       If n = 4, the program should output 30 (1^2 + 2^2 + 3^2 + 4^2 = 30) 

CODE: 

n=int(input())
 ans=0
for i in range(1,n+1):
 ans+=i**2
print(ans,end=""){codeBox}

Q2. Write a program that takes a number `n` as input and prints the nth power of 2.

       Example:
       If n = 4, the program should output 16 (2^4 = 16) 

CODE: 
                       
 n=int(input())
 print(2**n, end="") {codeBox}


Q3. Write a program that takes a number `n` as input and prints a pyramid of numbers 
      with `n` rows.

     Example:

    If n = 5, the program should output the following 
 
                       1 
                     232  
                   34543 
                 4567654 
               567898765 


   CODE: 

n=int(input())
max_row=1
max_row1=1

for row in range(1,n+1):
    b=0
    for space in range(1,n-row+1):
        print(" ",end="")

    a=row
    Left=list()
    while(a!=max_row1):
        
        if a>9:
            Left.append(str(b))
            b=b+1
        else:    
            Left.append(str(a))
        a=a+1
    if row==n:    
      print(("".join(Left)+str(max_row)+"".join(Left[::-1])),end="") 
    else:
      print(("".join(Left)+str(max_row)+"".join(Left[::-1]))) 
    if (max_row+2>9):
        max_row=-1
    max_row+=2
    max_row1+=2         {codeBox}         

Conclusion: 

I Request everyone to revisit the website on/before to last date for any re-verification of answers.

If you have any queries, contact us. I am very thankful to answer you.

NOTE: I'm answering these questions to the best of my knowledge.

One Comment Please !

Post a Comment (0)
Previous Post Next Post