Page 155 - Plus_V2.2_C8_Flipbook
P. 155
For example,
Program 9: To call a function.
Name of a function
def my_function():
print (“Hello”) Body of a function
my_function()
Function call
Program 10: To print a string by calling a function.
You will get the following output:
LIST
A list is a sequence of multiple values in a specific order. In a list, each element or value is called an
item. A list is mutable, which means the items in a list can be modified by assigning new values. It
is heterogeneous in nature, which means a list can contain numeric as well as textual data. In this
chapter, you will learn about creating a list, operations performed on the list and the functions of the
list.
Creating a List
Python uses lists to store different kinds of data in specific order. Because Python lists are changeable
types, we can change their elements after they’ve been generated.
To create a list, you need to place all the elements separated by a comma inside a square bracket [
]. The list can contain any number of elements of different data types such as integer, float, character
and so on.
Functions and String in Python 153

