Programmers Arena: The Input statements

The Input statements

The input function in python is used to take the value of a user defined variable. The regular input function does not support string data. The input command is then modified to raw input command. The raw input command assigns the variable a string value.

THE INPUT FUNCTION :
>>> a=input()
69
>>> print a
69

THE RAW INPUT FUNCTION:
>>> a=raw_input()
Hello world!
>>> print a
Hello world!

The input function can further be used in the arithmetic operations such as:
>>> a=input()
10
>>>b= a*a+1
>>>print b
101

The raw input can also be used in arithmetic operations but it needs another addon. That addon is another function which would be discussed later.



No comments:

Post a Comment

Copyright © Programmers Arena