The Joy of Computing using Python Week-5
Quiz Week 5: Assignment 5
Solution
1. Which of the following is the correct way to add data with key as CS101 and value as "Web Programming" to a dictionary named courseData?
?Answer: [Option 4] courseData["CS101"] = "Web Programming"
2. What is the probability of Monty opening the door with goat, given the hypothesis that you initially chose the door which has car ?
Answer: [Option 4] 1
3. Does transposing the magic square give us a new magic square ?
Answer: [Option 1] True
[Option 2] (2**90) % 2 == 0
[Option 3] 3*((3**89) + 3 ) % 3 == 0
[Option 4] (2**90 ) % len(doors) == 1
4. Given that you have a sorted list of 1024 elemets, what is the maximum number of comparisons required to find the target element using binary search ? Also what is the number of comparisons to search such an element using linear search ?
Answer: [Option 2]Binary: 11, Linear: 1024
5. What type of data is contained in a file with a .wav or .wave extension?
Answer: [Option 2]Audio Data
6. What does this program print in the end ?
Answer: [Option 3]Fraction of throws where both players showed same symbol(rock/paper/scissors)7. In binary search, what happens if the target value is greater than the middle element of the array?
Answer: [Option 2] The search continues in the right half of the array.
8. Which of the following is a requirement for binary search to work correctly?
Answer: [Option 1]The list must be sorted.
Discussion Improves Accuracy in Social Computing
Engaging in discussions helps refine solutions, making them more accurate and reliable. If you have any questions or thoughts, feel free to share them in the comments. Your input is valuable, and I'll be sure to address your queries.
Apologies for the Mistake
I made an error in one of the previous questions, and I apologize for that. I appreciate your understanding and am here to correct it.
Comments
Post a Comment