1) Write the function name for the following task:
a) Function to add a list element at the end of the existing list.
b) Function to remove all the elements of the dictionary.
c) Function to count the number of characters in a string.
d) Function to find the ASCII code of given character.
e) Function to find the index value of an element of the list.
2) Name the function/method required to
(i) Check if a string contains only alphabets.
(ii) Give the total length of the list.
3) Name the function/method required to
a) Function to remove the last element from a list.
b) Function to return the number of elements in a tuple.
c) Function to get all keys from a dictionary.
d) Function to convert a tuple into a list.
e) Function to check if a key exists in a dictionary.
4) Name the function/method required to:
a) Sort a list in ascending order.
b) Merge two dictionaries into one.
c) Count the number of times a value appears in a tuple.
d) Remove an element from a specific index in a list.
e) Get the value associated with a key from a dictionary without causing an error if the
key is missing.
5) Identify the correct function/method for the given scenarios:
a) I have a list, and I want to insert an element at a specific position.
b) I have a dictionary, and I want to get a list of all its values.
c) I have a tuple, and I want to find the position of a specific element.
d) I want to join all elements of a list into a single string with spaces between them.
e) I want to create a copy of a dictionary instead of modifying the original one.
6) Fill in the blanks with the correct method name:
a) my_list.________(value) → Adds an element to the end of the list.
b) my_dict.________() → Returns a list of key-value pairs as tuples.
c) my_tuple.________(value) → Returns the number of times value appears in the tuple.
d) my_list.________() → Removes and returns the last element of the list.
e) my_dict.________(key, default) → Returns the value for key, or default if the key is not
found
7) Fill in the blanks with the correct method name for lists:
a) my_list.________(index, value) → Inserts an element at a specific position in the list.
b) my_list.________() → Removes all elements from the list.
c) my_list.________(old_value, new_value) → Replaces the first occurrence of old_value with
new_value.
d) my_list.________() → Returns a copy of the list.
e) my_list.________(value) → Removes the first occurrence of value in the list.
8) Fill in the blanks with the correct method name for tuples:
a) my_tuple.________(value) → Returns the number of times value appears in the tuple.
b) my_tuple.________(value) → Returns the index of the first occurrence of value in the
tuple.
c) my_tuple = ________(my_list) → Converts a list into a tuple.
d) my_tuple = ________(item,) → Creates a tuple with a single element.
e) new_tuple = tuple1 __ tuple2→ Concatenates two tuples.
9) Fill in the blanks with the correct method name for strings:
a) my_string.________(old, new) → Replaces all occurrences of old with new in a string.
b) my_string.________() → Converts all characters of a string to uppercase.
c) my_string.________() → Removes whitespace from the beginning and end of a string.
d) my_string.________(separator) → Splits the string into a list using separator.
e) my_string.________(substring) → Returns True if the string contains substring, otherwise
returns False.
10) my_list.________(index, element)
Hint: Inserts an element at the specified index of the list.
11) my_list.________(value)
Hint: Returns the number of times value occurs in the list.
12) my_dict.________()
Hint: Returns a list of all keys in the dictionary.
13) my_dict.________()
Hint: Removes all items from the dictionary.
14) my_tuple.________(value)
Hint: Returns the index of the first occurrence of value in the tuple.
15) my_list.________()
Hint: Sorts the list in place in ascending order.
16) my_list.________()
Hint: Returns a shallow copy of the list.
17) my_dict.________(key)
Hint: Returns the value for key from the dictionary, raising an error if the key does not exist.
18) my_list.________()
Hint: Returns a new list that is the reverse of the original list.
19) my_dict.________(key, default_value)
Hint: Returns the value for key if it exists; otherwise, it returns default_value.
Real-World Use Case Questions
(Scenario-Based Questions)
1. You are creating a student database where you need to store student names and their
corresponding marks. Which data structure would you use, and which function can add a new
student to this database?
2. You have a list of customer reviews containing both uppercase and lowercase letters. Which
function would you use to make all reviews lowercase for consistency?
3. In an online shopping website, you need to maintain a list of products and their prices. What
data structure would be best, and which function can help you remove a product from the
database?
4. You are implementing a chat application, and the user messages are stored in a list. Which
function helps in sorting messages in alphabetical order?
5. A sensor system records temperature values in a tuple. Which method can you use to find the
highest recorded temperature?
6. In a gaming leaderboard, players’ names and scores are stored in a dictionary. Which function
can retrieve the top player’s name and score?
7. You are working on a data entry form, and the user sometimes enters extra spaces before and
after their name. Which string method would you use to clean the input?
8. You have a list of email addresses, and you need to check if a particular email exists in the list.
Which method should you use?
9. In a machine learning dataset, you need to convert a list of numerical values into a tuple for
data integrity. Which function will help you do this?
10. You are building a search feature for a dictionary application, where users enter a word and
get its meaning. Which function helps you check if the word exists in the dictionary?