-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamplemix.py
More file actions
22 lines (16 loc) · 765 Bytes
/
examplemix.py
File metadata and controls
22 lines (16 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Define multi positional arguments and after it multi keyword arguments
def func(*args, **kwargs):
print(args)
print(kwargs)
func("arg1", "arg2", arg3="Three", arg4="Four")
"""
we can see the output as below
('arg1', 'arg2') --> You see the many positional arguments is converted to tuple data type
{'arg3': 'Three', 'arg4': 'Four'} --> You see the multi keywords arguments is converted to a dictionary data type
"""
# -----------------------------------------------------
def student_info(*args, **kwargs):
print("Subjects:", args) # Positional arguments
print("Details:", kwargs) # Keyword arguments
# Passing subjects as *args and details as **kwargs
student_info("Math", "Science", "English", Name="Alice", Age=20, City="New York")