-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter_06.py
More file actions
120 lines (76 loc) · 2.3 KB
/
chapter_06.py
File metadata and controls
120 lines (76 loc) · 2.3 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# ============= > Function < ===============
# def Display():
# print("Hello World")
# call the display function
# Display()
# Display()
# Display()
# Display()
# Display()
# Display()
# Display()
# Display()
# Display()
# for i in range(10):
# Display()
# ========== > Function Parameters < ============
# def Display_Name (name):
# print("Hello, ", name)
# call the display_name function
# Display_Name("Ishfaq")
# Display_Name("Hammad")
# Display_Name("Ali")
# Display_Name("Ahmad")
# ========= > Return Values < =============
# def Addition (num1, num2) :
# reuslt = num1 + num2
# return reuslt
# reuslt1 = Addition(23, 25)
# print(reuslt1)
# print(Addition(45, 50))
# print(Addition(15, 50))
# print(Addition(235, 500))
# print(Addition(41, 10))
# ========== > Default parameters < ===============
# def Display (name="Ishfaq"):
# print("Hello, ", name)
# Display("Hammad")
# x = 10
# x = 5
# ============= > Keyword Arguments < ===============
# def Display_Student_Data (name, age):
# print(f"Student name is {name} and student age is {age}.")
# Display_Student_Data(age=20, name="Ishfaq")
# ============= > Vataible Numbers of Arguments < =================
# ============== > non-keywords arguments < =============
# def addition (*num):
# total = sum(num)
# return total
# print(addition(10, 20, 30, 40, 50))
# ============ > keywords arguments < =============
# def Display_Student_Data (**info) :
# for key, value in info.items(): # [(key, value), (key. value), (key, value)]
# print(f"Key : {key} and value : {value}")
# Display_Student_Data(name="Ishfaq", age=20, country="Pakistan")
# ======== > Scope of the variables < ==============
# student_marks = 30
# def Display_Student_Marks (Marks):
# student_Num = Marks
# global x
# x = 25
# print("Local Varibale Student Marks : ", student_Num)
# print("Global Variable Student Marks : ", student_marks)
# # call the function
# Display_Student_Marks(student_marks)
# print(x)
# ============ > Lambda Function < ============
# def square (x):
# return x*x
# square = lambda x: x*x
# print(square(6))
# ============ > Docstring < ==========
# def Display ():
# """This function display string."""
# print("Hello World")
# print(Display())
# print(Display.__doc__)