Page 85 - Code & Click - 6
P. 85
Print( ) Function
The Print( ) function is used to display the value of a variable, an expression, or text messages on the
screen. The syntax of the print( ) function is:
print(text message/variable name/expression)
The print( ) function can display multiple values also. Commas (,) are used to separate the different
values. The following examples illustrate the use of the print( ) function.
Input( ) Function
The Input( ) function is used to accept data from the user and store it in a variable. The syntax for
the input( ) function is:
<variable name> = input(“Message to display”)
The input function always treats every input as text or string. We use int( ) function alongwith
input( ) function to convert the input into numeric value.
Experiential Learning
Lab Activity 1
Let us create a program to accept the name, class, and age of a student in three variables – Name,
Class, and Age – and display their values.
1. Open a new file.
2. Type the code as shown in the image.
3. Execute the script.
The given images display the code and the output of the program.
COMMENTS IN PROGRAMS
Comments are statements that are included in a program to make the code understandable. These are
non-executable statements and are ignored by the Python interpreter or compiler. Comments are usually
added to a program as documentation notes or to make others understand what a part of code does.
83