Page 215 - Computer Science V2.0 Class 11
P. 215
07 print(" * ")
08 print(" *** ")
09 print(" ***** ")
10 print(" ******* ")
11
12 def rhombus():
13 '''
14 Objective: To print the rhombus
15 Input Parameters: None
16 Return value: None
17 '''
18 print(" * ")
19 print(" *** ")
20 print(" ***** ")
21 print(" ******* ")
22 print(" ***** ")
23 print(" *** ")
24 print(" * ")
25
26 #main program segment
27 '''
28 Objective: To print a triangle, a rhombus, and a triangle again, separated by blank lines
29 '''
30
31 triangle()
32 print()
33 rhombus()
34 print()
35 triangle()
Sample Output:
Fig 8.2: Output on execution of Program 8.2b
Let's examine the mechanism to call a function using Python Tutor. A Python program is a global frame in which
functions and statements appear (see Fig 8.3a). When the code in the Python script pattern2.py is executed,
Python encounters the definitions of functions triangle() (lines 1–10) in the global frame and makes a note of it
(see Fig 8.3a).
Introduction to Functions 201

