NPTEL The Joy of Computing using Python Week 2 Assignment Answers 2024
1. Statement : If a variable is assigned multiple times, the latest value is not stored in the variable
- False, the variable stores all values it was assigned
- False, the variable stores the value from the latest assignment.
- True, the variable stores the value from the second-last assignment.
- True, the variable stores value from the initial assignment
Answer :- For Answer Click Here
2. Which of the following code blocks print – ”Hello Ram Lakshman and Hanuman !” ?
Answer :- For Answer Click Here
3. What aren’t the correct ways to inform python that input is an integer ?
- in(input())
- float(input())
- int(input())
- a = input() a = int(a)
Answer :-
4. The following program outputs 722 –
For what value of a does the code output 8 ?
- 2
- 1
- 4
- 6
Answer :-
5. What does previous question calculate ?
- Calculates the factorial of a.
- Calculates the factorial of a and adds 2.
- Calculates the a multiples of a starting from 1 and adds 2.
- Calculates the factorial of a-1 and adds 2.
Answer :- For Answer Click Here
6. Which loop is used to perform a set of repetitive tasks based on condition in Python?
- while loop
- for loop
- do-while loop
- while-range loop
Answer :-
7. What happens when the condition inside the if and while evaluate to false ?
- Python interpreter ignores the if/while blocks, and halts the program.
- Python interpreter ignores the if/while blocks, and proceeds the program from the lines after the if/while block.
- Python interpreter executes the if/while blocks, and rest of the program.
- Python interpreter executes the if/while, and the programs runs in an infinite loop.
Answer :- For Answer Click Here
8. The following program might/might not have an infinite loop. Does the program have infinite loop ?
- No, the program doesn’t have infinite loop.
- Yes, it can be prevented by updating the value of a before the if block at line 3
- Yes, it can be prevented by removing both the if blocks inside the while loop.
- Yes, but it cannot be prevented
Answer :-
9. For which of the following values of name and age variables does the following code print ”You are lucky”?
- aryan, 20
- arjun, 19
- aakash, 17
- aatreya, 18
Answer :-
10. For which of the options among the previous question, the program doesn’t print anything.
- aryan, 20
- arjun, 19
- aakash, 17
- aatreya, 18
Answer :- For Answer Click Here