-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay21.py
More file actions
52 lines (33 loc) · 1 KB
/
Day21.py
File metadata and controls
52 lines (33 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Function Arguments and return statement
# There are four types of arguments that we can provide in a function
# Default Arguments
# Keyword Arguments
# Variable length arguments
# Required Arguments
# Default Arguments
def average(a=10, b=1):
print("The average is :", (a + b) / 2)
print("Arguments passed")
average(4, 6)
print("only one Arguments passed")
average(6)
# Keyword Arguments
print("no order req Arguments passed")
average(b=10, a=12)
# Required Arguments
def average1(a, b, c=10):
print("The average is :", (a + b + c) / 2)
print("\nRequired Arguments passed")
average1(b=10, a=12)
# Variable length arguments Examples
def average2(*numbers): # Tuple
sum = 0
for i in numbers:
sum = sum + i
print("Average is: ", sum / len(numbers))
print("\nVariable length argumments ")
average2(5, 6, 7, 7)
def name(**name): # Dictionary
def name(**name): # Dictionary
print("Hello", name["fname"], name["mname"], name["lname"])
name(mname="X", lname="Dark", fname="Light")