📖 generic · 12th TN - English Medium · COMPUTER SCIENCE · Page 53question

PYTHON – VARIABLES AND OPERATORS · Part 3

Chapter 2: 3 · COMPUTER SCIENCE

to interact with the user to accomplish the desired task; this can be achieved using Input-Output functions . The input() function helps to enter data at run time by the user and the output function print() is used to display the result of the program on the screen after execution. . .

The print() function In Python, the print() function is used to display result on the screen. The syntax for print() is as follows: Example print (“string to be displayed as output ” ) print (variable ) print (“String to be displayed as output ”, variable) print (“String1 ”, variable, “String ”, variable, “String ” ……) Example >>> print (“Welcome to Python Programming”) Welcome to Python Programming >>> x = >>> y = >>> z = x + y >>> print (z) >>> print (“The sum = ”, z) The sum = >>> print (“The sum of ”, x, “ and ”, y, “ is ”, z) The sum of and is The print ( ) evaluates the expression before printing it on the monitor. The print () displays an entire statement which is specified within print ( ). Comma ( , ) is used as a separator in print ( ) to print more than one item.

. . input() function In Python, input( ) function is used to accept data as input at run time. The syntax for input() function is, Variable = input (“prompt string”) 12th Computer Chapter - - Where, prompt string in the syntax is a statement or message to the user, to know what input can be given.

If a prompt string is used, it is displayed on the monitor; the user can provide expected data from the input device. The input( ) takes whatever is typed from the keyboard and stores the entered data in the given variable. If prompt string is not given in input( ) no message is displayed on the screen, thus, the user will not know what is to be typed as input. Example :input( ) with prompt string

Related topics

Have a question about this topic?

Get an AI answer grounded in your actual textbook — with the exact page reference.

Ask AI about this topic →