Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

README.md

Assignment 7: Functions

  1. Sum Function:

    • Write a function named calculate_sum that takes two parameters (a and b) and returns their sum.
    • Call the function with different values and print the results.
  2. Factorial Function:

    • Write a function named calculate_factorial that takes an integer parameter (n) and returns its factorial.
    • Call the function with different values and print the results.
  3. Even/Odd Checker Function:

    • Write a function named is_even that takes an integer as a parameter and returns True if it's even and False otherwise.
    • Call the function with different values and print the results.

Assignment 8: Lists

  1. List Operations:

    • Create a list of your favorite colors.
    • Write a function named print_colors that takes a list as a parameter and prints each color on a new line.
    • Call the function with your list.
  2. List Manipulation:

    • Create a list of numbers.
    • Write a function named square_numbers that 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.
  3. List Sorting:

    • Create a list of random numbers.
    • Write a function named sort_numbers that 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.

Assignment 9: Tuples

  1. Tuple Operations:

    • Create a tuple of your favorite books.
    • Write a function named print_books that takes a tuple as a parameter and prints each book on a new line.
    • Call the function with your tuple.
  2. Tuple Concatenation:

    • Create two tuples of numbers.
    • Write a function named concatenate_tuples that takes two tuples as parameters and returns a new tuple by concatenating them.
    • Call the function with your tuples and print the results.
  3. Tuple Unpacking:

    • Create a tuple containing your name and age.
    • Write a function named unpack_tuple that takes a tuple as a parameter and prints the name and age separately.
    • Call the function with your tuple.

Instructions:

  • 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.

Tutorial Name: codeswithpankaj