The Joy of Computing using python -Week 2
Quiz Week 2: Assignment 2
Solution
1. Statement: If a variable is assigned multiple times, the latest value is not stored in the variable
Answer: [Option 2] False, the variable stores the value from the latest assignment.
2. Which of the following code blocks print - "Hello Ram Lakshman and Hanuman!"?
Answer: [Option 1] and [Option 3]
3. What aren't the correct ways to inform Python that input is an integer?
Answer: [Option 1] in(input())
[Option 2] float(input())
4. The following program outputs 722 - For what value of a
does the code output 8?
Answer: [Option 3] 4
5. What does the previous question calculate?
Answer: [Option 4] Calculates the factorial of a-1
and adds 2
6. Which loop is used to perform a set of repetitive tasks based on a condition in Python?
Answer: [Option 1] While loop
7. What happens when the condition inside the if
and while
evaluates to false?
Answer: [Option 2] Python interpreter ignores the if/while
blocks and proceeds with the program from the lines after the if/while
block.
8. The following program might/might not have an infinite loop. Does the program have an infinite loop?
Answer: [Option 2] Yes, it can be prevented by updating the value of a
before the if
block at line 3
9. For which of the following values of name
and age
variables does the following code print "You are lucky"?
Answer: [Option 4] aatreya, 18
Answer: [Option 3] aakash, 17
Nice !!! week 3 solution too
ReplyDeleteStay tuned !! :)
Deletehttps://randomruminationswithme.blogspot.com/2024/08/programming-assignment-week-2-joy-of.html
DeleteProgramming Assignment