Page 199 - AI Ver 1.0 Class 10
P. 199
• end it specify what to print at the end. Default is newline ‘\n’. It is optional.
For example:
The input() Function
The input() function is used to take an input from the user. When this statement executes then the flow of the
program stops and waits with the cursor blinking for the user to enter a value. The input given by the user is always
a string value. In case a user enters an integer or float and we need this for mathematical calculation then we have
to convert them explicitly by using int() or float(). Syntax for the input() function:
input(<prompt>)
Where <prompt> is optional. It is a string that works as a message for the user at the time of input of data.
If N1=23 and N2=61, then the output is Sum=2361.
The reason for the above is that by default the input statement always accepts a string value. If a “+” is used with
strings, it concatenates the 2 strings. In order to evaluate the expression mathematically, we must use int()
with an input statement to convert it into integer. For example:
Advance Python 197

