Page 120 - Trackpad_V1_Book 6_Flipbook
P. 120
INPUT AND OUTPUT
Python provides two commonly used functions input() and print() for input and output respectively.
THE INPUT() FUNCTION
We use the input() function to take the user’s input while a program is being executed. (This
function also evaluates the expression whether the user has entered a string number or list right
after receiving input.) The general syntax of the input() function is as follows:
Variable_name = input(<message to be displayed>)
name = input(“Enter your name: “)
>>> Enter your name: “Trackpad”
THE PRINT() FUNCTION
We use the print() function to display the result on the screen. The content is written within the
parenthesis. To get the output, follow the given steps:
Step 1 Open the Python Shell window.
Step 2 In front of the command prompt, type print("Hello Class") and press the Enter key.
Do not forget to include the double quotes (" ").
Step 3 The output is displayed in the next line in the same Python Shell window.
Tick ( ) if you know this.
▶ Python is an interpreted language that executes code line by line.
▶ The Python Shell window executes one command at a time.
VARIABLES IN PYTHON
A Variable is the name of the memory location that is used to store data values which can be
accessed or changed later. The names given to the variables are known as identifiers. In Python,
we do not need to specify the type of variable because Python is a dynamic language and it also
identifies the variable type automatically.
118 Trackpad (Version 1.0)-VI

