NPTEL Joy Of Python Using Python Week 2 Answers 2024

Hello Everyone, In this article we are going to see the Joy Of Computing Using Python Week 2 answers. I am sharing these answers to the best of my knowledge. Any change in the answers, visit the website on or before the last date.  

Join Telegram:  CLICK HERE 

Also Read: NPTEL JOY OF COMPUTING USING PYTHON WEEK 1 ASSIGNEMNT

NPTEL Joy Of Python Using Python Week 2 Answers 2024 

NPTEL Joy Of Python Using Python Week 2 Answers 2024


Last Date: 07-08-2024

Q1. 

Statement : If a variable is assigned multiple times, the latest value is not stored in the variable
 
A. False, the variable stores all values it was assigned
B. False, the variable stores the value from the latest assignment.
C. rue, the variable stores the value from the second-last assignment.
D. True, the variable stores value from the initial assignment

Answer: [ B ]  False, the variable stores the value from the latest assignment.

Q2. Which of the following code blocks print - ”Hello Ram Lakshman and Hanuman !” ?
 
Answer: [ A, C ] 

Q3. What aren’t the correct ways to inform python that input is an integer ?
 
A. in(input())
B. float(input())
C. int(input())
D. a = input()
E. a = int(a)

Answer: [ A, B]

Q4. The following program outputs 722 -

a = 7
result = 1
for i in range(a):
      if ( i > 0 ) : 
            result = result * i 
print ( result + 2 ) {codeBox}

For what value of a does the code output 8 ?

A.  2
B.  1
C.  4
D.  6

Answer: [ C ] 4

Q5. What does previous question calculate ?
 
A. Calculates the factorial of a.
B. Calculates the factorial of a and adds 2.
C. Calculates the a multiples of a starting from 1 and adds 2.
D. Calculates the factorial of a-1 and adds 2.

Answer: [ D ] Calculates the factorial of a-1 and adds 2.

Q6. Which loop is used to perform a set of repetitive tasks based on condition in Python?
 
A. while loop
B. for loop
C. do-while loop
D. while-range loop

Answer: [ A ]

Q7. What happens when the condition inside the if and while evaluate to false ?
 
A. Python interpreter ignores the if/while blocks, and halts the program.
B. Python interpreter ignores the if/while blocks, and proceeds the program from the lines after the if/while block.
 C. Python interpreter executes the if/while blocks, and rest of the program.
 D. Python interpreter executes the if/while, and the programs runs in an infinite loop.

Answer: [ B ] 

Q8. The following program might/might not have an infinite loop. Does the program have infinite     loop ?

 a = int ( input () ) 
 while ( a == 0 ): 
          if ( a < 0 ): 
                a = -1 
          if ( a > 0 ): 
                a = 1
  if ( a > 1): 
        a = 2
  if ( a < 1 ): 
        a = -2 
  print (a) { codeBox}

 A. No, the program doesn’t have infinite loop.
 B. Yes, it can be prevented by updating the value of a before the if block at line 3
 C. Yes, it can be prevented by removing both the if blocks inside the while loop.
 D. Yes, but it cannot be prevented

Answer: [ B ] 

9. For which of the following values of name and age variables does the following code print ”You are lucky”?


A.  aryan, 20
B. arjun, 19
C. aakash, 17
D. aatreya, 18

Answer: [ D ] 

10. For which of the options among the previous question, the program doesn’t print anything.
 
A. aryan, 20
B. arjun, 19
C. aakash, 17
D. aatreya, 18

Answer: [ C ] 

Conclusion

If any changes in the answer, please visit the website on or before to the last date. 


Join Telegram:  CLICK HERE  

One Comment Please !

Post a Comment (0)
Previous Post Next Post