Skip to content

Commit b142f06

Browse files
committed
Types_of_Arguments.py
1 parent 4f701b7 commit b142f06

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Types_of_arguments.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
def greet(name,dept):
2+
print(f"Hi,{name}")
3+
print(f"Are you from {dept} department?")
4+
greet("Jenny","CS") #Positional Arguments
5+
6+
def greet(name,dept):
7+
print(f"Hi,{name}")
8+
print(f"Are you from {dept} department?")
9+
greet(dept="CS",name="Jenny")#Keyword Argument
10+
11+
def greet(name,dept):
12+
print(f"Hi,{name}")
13+
print(f"Are you from {dept} department?")
14+
greet("Jenny",dept="CS")#mixed positional and keyword arguments
15+
#- All positional arguments must come before keyword arguments.
16+
17+
def greet(name,subject,dept="CS"):
18+
print(f"Hi,{name}")
19+
print(f"Do you teach {subject}?")
20+
print(f"Are you from {dept} department?")
21+
greet("Jenny","Python","ME")#Override Default Arguments DEPT
22+
23+
#default argument should be provided after the non default argument
24+
25+
def add(*numbers):#Arbitrary /Variable Length Arguments
26+
c=0
27+
for i in numbers:
28+
c=c+i
29+
print(f"sum is {c}.")
30+
add(5,8,8)
31+
add(1,10,20,80,5)

0 commit comments

Comments
 (0)