Assignments on Functions & Modules
Assignments on Functions & Modules
Write a function greet that takes a name as an argument and prints a greeting message.
For example, greet("Alice") should print "Hello, Alice!".
Write a function add that takes two numbers as arguments and returns their sum.
Write a function multiply that takes two numbers as arguments and returns their
product.
Default Arguments
Write a function power that takes two arguments, base and exponent, and returns the
result of raising base to the power of exponent. The exponent should have a default
value of 2.
Keyword Arguments
Write a function introduce that takes two arguments, name and age, and prints a
message introducing the person. Use keyword arguments to call this function.
Variable-Length Arguments
Write a function average that takes any number of numerical arguments and returns
their average.
Assignment 2: Modules
1. Write a script that uses the random module to generate a random integer between 1
and 100 and print it.
2. Use the datetime module to print the current date and time.
3. Use the os module to print the current working directory.