Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views1 page

Practice Questions On Def Function

The document contains a series of practice questions focused on defining various functions in programming. Each question specifies a function that performs a specific task, such as greeting, mathematical operations, and list manipulations. The questions cover a range of topics including conditionals, loops, and data structures.

Uploaded by

swapnajakka3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

Practice Questions On Def Function

The document contains a series of practice questions focused on defining various functions in programming. Each question specifies a function that performs a specific task, such as greeting, mathematical operations, and list manipulations. The questions cover a range of topics including conditionals, loops, and data structures.

Uploaded by

swapnajakka3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Practice Questions on Def function

1. Define a function greet that takes a name as an argument and prints a personalized greeting
message.

2. Define a function add that takes two numbers as arguments and returns their sum.

3. Define a function hello_world that prints "Hello, World!" to the console.

4. Define a function square that takes a number as an argument and returns its square.

5. Define a function cube that takes a number as an argument and returns its cube.

6. Define a function is_even that takes a number as an argument and returns True if it's even,
False otherwise.

7. Define a function is_odd that takes a number as an argument and returns True if it's odd, False
otherwise.

8. Define a function max_of_two that takes two numbers as arguments and returns the maximum
of the two.

9. Define a function min_of_two that takes two numbers as arguments and returns the minimum
of the two.

10. Define a function abs_diff that takes two numbers as arguments and returns the absolute
difference between them.

11. Define a function is_prime that takes a number as an argument and returns True if it's prime,
False otherwise.

12. Define a function greet_multiple that takes a list of names as an argument and prints a
personalized greeting message for each name.

13. Define a function sum_of_squares that takes a list of numbers as an argument and returns the
sum of their squares.

14. Define a function filter_even that takes a list of numbers as an argument and returns a new list
containing only the even numbers.

15. Define a function find_max_min that takes a list of numbers as an argument and returns a
tuple containing the maximum and minimum values.

16. Define a function sort_by_length that takes a list of strings as an argument and returns a new
list sorted by the length of the strings.

17. Define a function merge_sorted_lists that takes two sorted lists of numbers as arguments and
returns a new sorted list containing all the numbers.

18. Define a function find_common_elements that takes two lists of numbers as arguments and
returns a new list containing the common elements.

19. Define a function group_by_category that takes a list of dictionaries as an argument and
returns a new dictionary grouped by a specific category.

20. Define a function calculate_standard_deviation that takes a list of numbers as an argument


and returns the standard deviation.

You might also like