-
Set Operations:
- Create two sets of your favorite fruits.
- Write a function named
print_unique_fruitsthat takes two sets as parameters and prints the unique fruits present in both sets. - Call the function with your sets.
-
Set Intersection:
- Create two sets of numbers.
- Write a function named
common_numbersthat takes two sets as parameters and returns a new set containing the common numbers. - Call the function with your sets and print the results.
-
Set Difference:
- Create two sets of animals.
- Write a function named
unique_animalsthat takes two sets as parameters and returns a new set containing the animals unique to each set. - Call the function with your sets and print the results.
-
Dictionary Operations:
- Create a dictionary of your favorite movies with movie names as keys and release years as values.
- Write a function named
print_moviesthat takes a dictionary as a parameter and prints each movie along with its release year. - Call the function with your dictionary.
-
Dictionary Manipulation:
- Create a dictionary of cities and their populations.
- Write a function named
calculate_total_populationthat takes a dictionary as a parameter and returns the total population. - Call the function with your dictionary and print the result.
-
Dictionary Update:
- Create a dictionary representing a person's information (name, age, city).
- Write a function named
update_citythat takes a dictionary as a parameter and updates the city information. - Call the function with your dictionary and print the updated dictionary.
-
String Concatenation:
- Create two strings containing your first and last names.
- Write a function named
full_namethat takes two strings as parameters and returns the full name. - Call the function with your strings and print the result.
-
String Length:
- Create a string containing a sentence.
- Write a function named
sentence_lengththat takes a string as a parameter and returns the length of the sentence. - Call the function with your string and print the result.
-
Substring Search:
- Create a string containing a paragraph.
- Write a function named
search_substringthat takes a string and a substring as parameters and checks if the substring is present in the string. - Call the function with your string and a few substrings.
- Encourage students to use meaningful variable names and provide comments explaining their code.
- Remind students to call the functions with different values to test their implementations.
- Emphasize the importance of code readability and efficiency.
- Encourage experimentation with different scenarios to ensure the correctness of the code.
- Provide feedback on the usage of sets, dictionaries, and strings in their solutions.