Type the following text to the right of the Python prompt and press the Enter key:
Here print evaluates each expression in turn and writes the resulting value to standard output (in the screen). If you would like to print a blank line, use print "\n"
>>>print "Hello welcome to python programming"
>>>#this is a comment
Now lets start with variables. Try x=5 in the IDLE
>>>x=5 >>>x 5
Here, we have created a variable called 'x' and associated it with the value 5. Note that in Python there is no need to declare the variable or its type before using them. Everything is a object here!!! Also it is possible to convert type of variables.
Variable can only contain ascii characters, digits and underscores (no spaces or other symbols) also its should not start with a digit or cannot be any words from a list of reserved keywords of Python.
Try the following
>>>k=52.3E-4 >>>n=complex (3,4) >>>n.real >>>n.imag
Based on the data type of a variable, the interpreter allocates memory and decides what can be stored in the reserved memory. Therefore, by assigning different data types to variables, you can store integers, decimals, or characters in these variables.
Here we have used a simple assignment operator,('=') Assigns values from right side operands to left side operand. For example, c = a + b will assign value of a + b into c.
Numeric Types in Python