NPTEL The Joy of Computing using Python Week 10 Assignment Answers 2024
1. What will be the output of the following Python code?
s = “Hello, World!”
print (s[7:12 ])
- “World”
- “World!”
- “Worl”
- “orld”
Answer :- For Answers Click Here
2. Which string method would you use to remove all leading and trailing whitespace from a string in Python?
- strip()
- split()
- replace()
- join()
Answer :- For Answers Click Here
3. Given the string s = “PythonProgramming”, what does s [::2] return?
- “PythonProgramming”
- “Pto rgamn”
- “PyonPormig”
- “PtoPormig”
Answer :- For Answers Click Here
4. Why are names often converted to lowercase and spaces removed when implementing the FLAMES game in Python?
- To increase game difficulty
- To ensure consistent character comparison
- Because uppercase letters are not supported in Python strings
- To encrypt the names for privacy
Answer :-
5. Given the names “Alice” and “Bob”, what is the FLAMES result of their relationship according to the FLAMES game?
- Friends
- Love
- Affection
- Marriage
- Enemy
- Siblings
Answer :-
6. Given a = np.array ([1, 2, 3, 4, 5]), what does print(a[1:4]) output?
- [1 2 3]
- [2 3 4]
- [2 3 4 5]
- [1 2 3 4]
Answer :- For Answers Click Here
7. In the NumPy array arr = np.array ( [ [1,2,3],[4,5,6],[7,8,9] ] ), what is the value of arr [1,2]?
- 5
- 6
- 2
- 8
Answer :-
8. What is the output of the following Python code?
s = “abcdef”
print (s[1:5:2])
- “bd”
- “bcd”
- “ace”
- “be”
Answer :-
9. Can numpy be used when working with images in Python?
- Yes
- No
Answer :-
10. When comparing lossy and lossless compression methods, which of the following statements is true?
- Lossy compression reduces file size without any loss of quality.
- Lossless compression reduces file size without any loss of quality.
Answer :- For Answers Click Here