@@ -42,3 +42,64 @@ def isACSTSFFB(name: str) -> bool:
4242 else :
4343 return False
4444```
45+
46+ ### Creating a Function with positional args
47+
48+ ``` python
49+ def persninfo (name , job ):
50+ print (" \n My name is " + name + " . " )
51+ print (" and I am a(n) " + job + " . " )
52+ persninfo(" ftnfanb" , " 429 TA" )
53+
54+ ```
55+
56+
57+ ### Creating a Function with default value
58+
59+ ``` python
60+ def persninfo (name , job = " developer" ):
61+ print (" \n My name is " + name + " . " )
62+ print (" and I am a(n) " + job + " . " )
63+ persninfo(" ftnfanb" )
64+
65+ ```
66+
67+
68+ ### Using a keyword argument
69+
70+ ``` python
71+ def petsAndInfo (name , numOfPets ):
72+ print (" My name is " + name + " and I have " + numOfPets + " pet(s)." )
73+ ```
74+ ### Making the argument optional
75+
76+ ``` python
77+ def petsAndInfo (name , numOfPets = None ):
78+ print (" My name is " + name)
79+ if (numOfPets):
80+ print (" and I have " + numOfPets + " pet(s)." )
81+ petsAndInfo(" Bob" , str (5 ))
82+ petsAndInfo(" Tracy" )
83+ ```
84+
85+ ### Returning A Dictionary
86+
87+ ``` python
88+ def myFullName (fName , lName ):
89+ individ = {" First Name" : fName, " Last Name" : lName }
90+ return individ
91+ bookfb = myFullName(" Angela" , " Cao" )
92+ print (bookfb)
93+ ```
94+
95+ ### Taking A List as an argument
96+
97+ ``` python
98+ def sayHiToGuests (people ):
99+ for person in people:
100+ message = " Hi, " + person + " !"
101+ print (message)
102+ peeps = [" Joey" , " DJ" , " Pascal" ]
103+ sayHiToGuests(peeps)
104+ ```
105+
0 commit comments