# HG changeset patch # User amit@shrike.aero.iitb.ac.in # Date 1271327573 -19800 # Node ID 9dffd11728d2a095fe13778194de914cad3a4532 # Parent 7d4ed969a94243cb9f008e07e793bef0a848eff2 Started on day2 . Adding a script on basic python diff -r 7d4ed969a942 -r 9dffd11728d2 basic-python.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/basic-python.txt Thu Apr 15 16:02:53 2010 +0530 @@ -0,0 +1,45 @@ +*Script + + +*Hello and welcome to this tutorial on Basic Python using Python. + +This tutorial formally introduces Python as a language . Through this tutorial we will be able to understand Basic Data types like number , Boolean and strings .Some basic operators , simple input/output and basic conditional flow . + +In numbers Python supports three kinds of data types , + +floats,integers and complex numbers + +An integer can be defined as follows : +a=13 + +This make a an integer variable with value 13 . + +You can also type 9 around 20 times + +a=99999999999999999999999 . as you can see Python does not have a limit on how long an integer has to be . Isn't that great . + +Now will try a float. + +let's type +p=3.141592 if you type out p now you will notice that it is not absolutely equal to p you typed in . The reason for that is how a computer saves decimal values . + +Apart from integer and float, Python has an in-built support for complex numbers. Now we try to assign a complex value to a variable . +Type: +c = 3+4j +As you can see ,the notation for complex numbers is similar to the one used in electric engineering. +We will now try some operations on complex numbers . First we will try to get the absolute value of the complex number . For this we will use the abs built in function . For this do : +abs in parenthesis c . + +Do get the imaginary part of c you can do : + +c.imag + +and similarly for real part do : + +c.real + +Python also has Boolean as a built-in type . + +Try it out just type .. + t=True , note that T in true is capitalized . +