Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- """ This script showcases the different properties of functions """
- # Function definitions
- def show_str(my_str):
- "shows a specified string"
- print(my_str)
- return
- def my_age(age=35, my_age_str="My age is "):
- "prints a string with an associated age"
- print(my_age_str, age)
- return
- def print_all(*args):
- "prints all arguments passed to the function"
- for arg in args:
- print(arg)
- return
- # Running each function
- # Example 1
- show_str("Hello World!")
- # Example 2
- my_age(my_age_str="My new age is") # Example of keyword arguments | Output: My new age is 35
- my_age(age=50) # Output: My age is 50
- # Example 3
- print_all(1, 2, 3, 4, 70) # Output: 1, 2, 3, 4, 70
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement