Week - 10 Quiz Assignment

Quiz Week 10 : Assignment 10

1. What will be the output of the following Python code?

s = "Hello, World!"
print (s[7:12])
  • "World"
  • "World!"
  • "Worl"
  • "orld"

2. Which string method would you use to remove all leading and trailing whitespace from a string in Python?

  • strip()
  • split()
  • replace()
  • join()

3. Given the string s = "PythonProgramming", what does s [::2] return?

  • "PythonProgramming"
  • "Pto rgamn"
  • "PyonPormig"
  • "PtoPormig"

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

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

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]

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

8. What is the output of the following Python code?

s = "abcdef"
print(s[1:5:2])
  • "bd"
  • "bcd"
  • "ace"
  • "be"

9. Can numpy be used when working with images in Python?

  • Yes
  • No

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.

Discussion makes the solution more accurate (social computing). Discuss the solution in comments. Do share this with your friends! Comment the queries, I will reach out to you.
Week 10 programming assignment solution coming soon

Comments

Popular posts from this blog

The Joy of Computing using python -Week 1