The joy of computing using Python Week - 8
Quiz Week 8: Assignment 8
1. Which of the following is a valid way to create a tuple in Python?
- t = [1, 2, 3]
- t = (1, 2, 3)
- t = {1, 2, 3}
- t = 1, 2, 3
2. Which of the following operations is valid on a tuple?
- t[1] = 4
- t.append(4)
- t = t + (4,)
- del t[1]
3. What will the following code output?
t = [1, 2, 3] print(type((t, t)))
- <class 'list'>
- <class 'set'>
- <class 'tuple'>
- Error
4. What is the primary purpose of the matplotlib.pyplot module in Python?
- To perform matrix operations.
- To handle file I/O operations.
- To generate and customize visualizations like plots and graphs.
- To manipulate and process images.
5. Which of the following statements is true about anagrams?
- Two strings of different lengths can be anagrams.
- Two strings are anagrams if they contain the same characters in the same order.
- Two strings are anagrams if they contain the same characters in different orders.
6. Every character, whether an alphabet, digit, or special character, has an ASCII value. Which of the following methods is used to find the ASCII value?
- ASCII('a')
- ord('a')
- int('a')
- ASC val('a')
7. Which of the following libraries is commonly used to determine the intensity of emotions in sentiment analysis?
- VADER
- NumPy
- Pandas
- Matplotlib
8. Which of the following Python code snippets correctly checks if two strings are anagrams?
-
def are_anagrams(str1, str2):
return sorted(str1) == sorted(str2) -
def are_anagrams(str1, str2):
return set(str1) == set(str2) -
def are_anagrams(str1, str2):
return str1 == str2[::-1] -
def are_anagrams(str1, str2):
return len(str1) == len(str2)
9. Why is gambling generally a bad decision?
- Because you will lose more money than you win over time.
- Because the probability of winning is always 0.
- Because you will always win.
- Because the amount of money you can win is always greater than the amount you lost over time.
10. True or False: A significant amount of information can be extracted from an image by applying the appropriate image enhancement techniques.
- True
- False
Comments
Post a Comment