basic-python.txt
changeset 74 12729a0a1893
parent 73 9dffd11728d2
child 78 099a2cc6c7d2
equal deleted inserted replaced
71:bc3f351aeec9 74:12729a0a1893
       
     1 *Script
       
     2 
       
     3 
       
     4 *Hello and welcome to this tutorial on Basic Python using Python.
       
     5 
       
     6 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 . 
       
     7 
       
     8 In numbers Python supports three kinds of data types ,
       
     9 
       
    10 floats,integers and complex numbers
       
    11 
       
    12 An integer can be defined as follows :
       
    13 a=13
       
    14 
       
    15 This make a an integer variable with value 13 .
       
    16 
       
    17 You can also type 9 around 20 times 
       
    18 
       
    19 a=99999999999999999999999 . as you can see Python does not have a limit on how long an integer has to be . Isn't that great . 
       
    20 
       
    21 Now will try a float.
       
    22 
       
    23 let's type 
       
    24 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 . 
       
    25 
       
    26 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 .
       
    27 Type:
       
    28 c = 3+4j
       
    29 As you can see ,the notation for complex numbers is similar to the one used in electric engineering. 
       
    30 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 :
       
    31 abs in parenthesis c . 
       
    32 
       
    33 Do get the imaginary part of c you can do :
       
    34 
       
    35 c.imag
       
    36 
       
    37 and similarly for real part do :
       
    38 
       
    39 c.real
       
    40 
       
    41 Python also has Boolean as a built-in type .
       
    42 
       
    43 Try it out just type ..
       
    44  t=True , note that T in true is capitalized .    
       
    45