1) Define function with syntax and example.
A function is a group of related statements that performs a specific
task which executes only when it is called.
Ex:
Def greet(name):
Print(“Hello, “ + name + “. Good morning!”)
Greet(“John”)
Output:
Hello, John .Good morning!
2) List any five advantages of using functions in python.
• Code readability: Functions can make code easier to understand and
maintain.
• Code consistency: Functions can help maintain code consistently.
• Reusability: Functions can be called from other functions or
programs, increasing.
• Code modularity: Functions can make code modular.
3) Define anonymous function with syntax and example.
These functions are called anonymous because they are not declared
in
the standard manner by using the def keyword. You can use the
lambda keyword to.
Create small anonymous functions
6) List the features of files.
Here are the key features of files:
Name: Unique identifier for the file.
Extension: Indicates file type (e.g., .txt, .jpg, .docx).
Size: File size in bytes, kilobytes, megabytes, etc.
Type: Text, image, audio, video, executable, etc.
Location: File path and directory.
7) Define modules. Write an example for creation of modules.
• Consider a module to be the same as a`code library.
A function is a group of related statements that performs a specific
task which executes only when it is called.
Ex:
Def greet(name):
Print(“Hello, “ + name + “. Good morning!”)
Greet(“John”)
Output:
Hello, John .Good morning!
2) List any five advantages of using functions in python.
• Code readability: Functions can make code easier to understand and
maintain.
• Code consistency: Functions can help maintain code consistently.
• Reusability: Functions can be called from other functions or
programs, increasing.
• Code modularity: Functions can make code modular.
3) Define anonymous function with syntax and example.
These functions are called anonymous because they are not declared
in
the standard manner by using the def keyword. You can use the
lambda keyword to.
Create small anonymous functions
6) List the features of files.
Here are the key features of files:
Name: Unique identifier for the file.
Extension: Indicates file type (e.g., .txt, .jpg, .docx).
Size: File size in bytes, kilobytes, megabytes, etc.
Type: Text, image, audio, video, executable, etc.
Location: File path and directory.
7) Define modules. Write an example for creation of modules.
• Consider a module to be the same as a`code library.