Python Task4
Python Task4
2.
a. Write a function that takes two numbers as input and returns their sum.
3. Write a function that takes two numbers as input and returns their sum.
4. Write a function to calculate the factorial of a given number.
5. Write a function that filters out numbers less than 10 from a list.
6. Write a program that prints the numbers from 1 to 100. But for multiples of three,
print "Fizz" instead of the number, and for the multiples of five, print "Buzz." For
numbers that are multiples of both three and five, print "FizzBuzz."
7. Write a function that returns the maximum of three numbers.
8. Write a function to reverse a given string.
9. Write a function that checks whether a given number is prime.
10. Create a dictionary and write a program to print its keys and values
11. Write a program to print even numbers from 2 to 20
12. Write a program to calculate the sum of all numbers from 1 to 100
13. Write a program to calculate the average of a list of numbers using a loop.
14. Write a function called greet that takes a name as an argument and prints a greeting
message.
15. Write a function called multiply that takes two numbers as arguments and returns
their product. Include a default value of 1 for the second number.
16. Write a function called calculate_sum that can take any number of arguments and
returns their sum.
17. Write a function called calculate_stats that takes a list of numbers as input and
returns the sum, mean, and median of the numbers.
18. rite a function called square that takes a number as an argument and returns its
square. Include a docstring that explains the purpose of the function.
19. Write a lambda function that takes two numbers as arguments and returns the
maximum of the two.
20. rite a lambda function that takes three parameters and returns their product.
21. Given a list of numbers, use the filter function with a lambda function to filter out
the even numbers.
22. Given a list of numbers, use the map function with a lambda function to square each
number in the list.
23. Write a lambda function that returns "Even" if the input is even and "Odd" if the input
is odd.
24. Write a lambda function that returns "Positive" if the input is greater than 0,
"Negative" if it's less than 0, and "Zero" if it's equal to 0.
25. Write a program that takes a decimal number as input and prints its ceiling and floor
values using the math module.
26. Write a function that generates and returns a random integer between 1 and 100
using the random module.
27. Write a program that randomly selects and prints three elements from a list using the
random module.
28. Write a program that generates and prints 10 random numbers from a normal
distribution using the random module.
29. rite a program to input a number and print the sum of its digits using a loop.
30. Write a program to count down from 10 to 1 using a while loop.