-
Sum Function:
- Write a function named
calculate_sumthat takes two parameters (a and b) and returns their sum. - Call the function with different values and print the results.
- Write a function named
-
Factorial Function:
- Write a function named
calculate_factorialthat takes an integer parameter (n) and returns its factorial. - Call the function with different values and print the results.
- Write a function named
-
Even/Odd Checker Function:
- Write a function named
is_eventhat takes an integer as a parameter and returnsTrueif it's even andFalseotherwise. - Call the function with different values and print the results.
- Write a function named
-
List Operations:
- Create a list of your favorite colors.
- Write a function named
print_colorsthat takes a list as a parameter and prints each color on a new line. - Call the function with your list.
-
List Manipulation:
- Create a list of numbers.
- Write a function named
square_numbersthat takes a list as a parameter and returns a new list containing the squares of each number. - Call the function with your list and print the results.
-
List Sorting:
- Create a list of random numbers.
- Write a function named
sort_numbersthat takes a list as a parameter and returns a new list with the numbers sorted in ascending order. - Call the function with your list and print the results.
-
Tuple Operations:
- Create a tuple of your favorite books.
- Write a function named
print_booksthat takes a tuple as a parameter and prints each book on a new line. - Call the function with your tuple.
-
Tuple Concatenation:
- Create two tuples of numbers.
- Write a function named
concatenate_tuplesthat takes two tuples as parameters and returns a new tuple by concatenating them. - Call the function with your tuples and print the results.
-
Tuple Unpacking:
- Create a tuple containing your name and age.
- Write a function named
unpack_tuplethat takes a tuple as a parameter and prints the name and age separately. - Call the function with your tuple.
- 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 functions, lists, and tuples in their solutions.