basic-data-type/script.rst
changeset 457 68813d8d80fb
parent 412 bb45826efe74
--- a/basic-data-type/script.rst	Mon Nov 08 02:12:28 2010 +0530
+++ b/basic-data-type/script.rst	Thu Nov 11 02:28:55 2010 +0530
@@ -16,8 +16,6 @@
    External Reviewer   :
    Checklist OK?       : <put date stamp here, if OK> [2010-10-05]
 
-.. #[Puneeth: Fill in pre-requisites.]
-
 Hello friends and welcome to the tutorial on Basic Data types and operators
 in Python.
 
@@ -27,7 +25,7 @@
 
 In this tutorial, we shall look at
 
- * Datatypes in Python
+* Datatypes in Python
     * Numbers
     * Boolean
     * Sequence
@@ -35,19 +33,15 @@
   * Arithmetic Operators
   * Boolean Operators
 
-* Manipulating Sequence datatypes
-
-.. #[Puneeth: Use double colon only for code blocks.]
-.. #[Puneeth: include more details in the outline.]
-
-with a little hands-on on how they can be applied to the different data types.
-
-
+* Python Sequence Data types
+  * list
+  * string
+  * tuple
 
 First we will explore python data structures in the domain of numbers.
 There are three built-in data types in python to represent numbers.
 
-{{{ A slide to make a memory note of this }}}
+{{{ A slide to make a memory note of the different datatypes }}}
 
 These are:
 
@@ -55,12 +49,6 @@
   * float 
   * complex 
 
-.. #[Puneeth: Changed to  int, float and complex.]
-
-.. #[Puneeth: Loss of consistency. You talk of built-in data types, but
-.. then you were calling them integers, floats and complex. Clean up
-.. required.]
-
 Lets first talk about int. ::
 
    a = 13
@@ -75,38 +63,21 @@
    type(a)
    <type 'int'>
 
-This means that a is a type of int. Being an int data structure in python
-means that there are various functions that this variable has to manipulate
-it different ways. You can explore these by doing,
+This means that a is a type of int. There are lot of functions associated
+with the int datatype, to manipulate it in different ways. These can be
+explored by doing, ::
 
   a.<Tab>
 
-.. #[Puneeth: Why are we suddenly talking of limits?
-.. Something like this would be better. 
-.. int data-type can hold integers of any size. for example - ]
-
-*int* datatype can hold integers of any size lets see this by example.
+*int* datatype can hold integers of any size lets see this by an example.
+::
 
   b = 99999999999999999999
   b
 
 As you can see even when we put a value of 9 repeated 20 times python did
-not complain. However when you asked python to print the number again it
-put a capital L at the end. Now if you check the type of this variable b,
-::
-
-  type(b)
-  <type 'long'>
-
-
-The reason for this is that python recognizes large integer numbers by the
-data type long. However long type and int type share there functions
-and properties.
-
-.. #[Puneeth: again, the clean-up that I talked of above. Decide if you are
-.. talking about the different type of numbers and the datatypes that are
-.. used to represent them or if you are talking of the data-types and what
-.. kind of numbers they represent. I think you should choose the former.]
+not complain. This is because python's int data-type can hold integers of any
+size.
 
 Let us now look at the float data-type. 
 
@@ -115,10 +86,10 @@
   p = 3.141592
   p
 
-If you notice the value of output of p isn't exactly equal to p. This is
-because computer saves floating point values in a specific format. There is
-always an aproximationation. This is why we should never rely on equality
-of floating point numbers in a program.
+If you notice the value of output of ``p`` isn't exactly equal to ``p``.
+This is because computer saves floating point values in a specific format.
+There is always an approximation. This is why we should never rely on
+equality of floating point numbers in a program.
 
 The last data type in the list is complex number ::
 
@@ -126,7 +97,7 @@
 
 as simple as that so essentialy its just a combination of two floats the
 imaginary part being defined by j notation instead of i. Complex numbers
-have a lot of functions specific to them. Lets check these ::
+have a lot of functions specific to them. Let us look at these ::
 
   c.<Tab>
 
@@ -142,8 +113,25 @@
   abs(c)
 
 
+Following is are exercises that you must do. 
 
-{{ Slide for memory aid }} 
+%% %% Find the absolute value of 3+4j 
+::
+
+        abs(3+4j)
+
+%% %% What is the datatype of number 999999999999999999? Is it
+not int?
+::
+
+        Long
+        Big integers are internally stored in python
+        as Long datatype.  
+
+Please, pause the video here. Do the exercises and then continue. 
+
+
+{{ Slide for showing Boolean datatypes }} 
 
 Python also has Boolean as a built-in type.
 
@@ -163,10 +151,6 @@
 
 The results are self explanatory.
 
-.. #[Puneeth: Why does booleans bring us to precedence? I don't see the
-.. connection. Am I missing something?]
-
-
 What if you want to apply one operator before another.
 
 Well you can use parenthesis for precedence.
@@ -178,8 +162,6 @@
   c=True
 
 
-.. #[Puneeth: Consistency. In[]: is not present at other places.]
-
 To check how precedence changes with parenthesis, we will try two
 expressions and their evaluation.
 
@@ -199,14 +181,12 @@
 Let's now look at some operators available in Python to manipulate
 these data types.
 
-.. #[Puneeth: A mention of other operators would be good? Starting
-.. with % and ** is a bit weird.]
-
 Python uses '+' for addition ::
 
   23 + 74
 
 '-' for subtraction ::
+
   23 - 56
 
 '*' for multiplication ::
@@ -216,8 +196,16 @@
 '/' for division ::
     
   384/16
+  8/3 
+  8.0/3
 
- '%' for modulo operation ::
+When we did 8/3 the first case results in am integer 
+output as both the operands are integer however when 
+8.0/3 is used the answer is float as one of the operands is
+float. 
+
+
+'%' for modulo operation ::
 
     87 % 6
 
@@ -245,13 +233,27 @@
 
    a=a/23
 
+Following is are exercises that you must do. 
+
+%% %% Using python find sqaure root of 3?
+
+%% %% Is 3**1/2 and 3**0.5 same
+
+Please, pause the video here. Do the exercises and then continue.
+
+::
+
+   3**0.5
+
+::
+    No,One gives an int answer and the other float        
+
+
 Lets now discuss sequence data types in Python. Sequence data types
 are those in which elements are kept in a sequential order and all the 
-elements accessed using index numbers.
+elements are accessed using index numbers.
 
-.. #[Puneeth: fix the last sentence - it sounds incomplete]
-
-{{{ slide for memory aid }}}
+{{{ slide introducing sequence datatype }}}
 
 The sequence datatypes in Python are ::
 
@@ -277,8 +279,6 @@
  var_list = [1, 1.2, [1,2]]	
  var_list
 
-.. #[Puneeth: some continuity, when jumping to strings?]
-
 Lets look at another sequence data type, strings
 
 type :: 
@@ -288,7 +288,7 @@
 
 greeting_string is now a string variable with the value "hello"
 
-{{{ Memory Aid Slide }}}
+{{{ All the different types of strings shown }}}
 
 Python strings can actually be defined in three different ways ::
 
@@ -296,12 +296,8 @@
    l="Let's see how to include a single quote"
    m='''"Let's see how to include both"'''
 
-.. #[Puneeth: Contain's? That's not a word!]
-
 As you can see, single quotes are used as delimiters usually.
 
-.. #[Puneeth: Thus?]
-
 When a string contains a single quote, double quotes are used as
 delimiters. When a string quote contains both single and double quotes,
 triple quotes are used as delimiters.
@@ -365,17 +361,15 @@
    max(num_tuple)
    min(greeting_string)
 
-Get a sorted list and reversed list using sorted and reversed function ::
+Get a sorted list  ::
 
    sorted(num_list)
-   reversed(greeting_string)
+   
 
-As a consequence of there order we can access a group of elements of sequence,
-together. This is called slicing and striding.
+As a consequence of their order, we can access a group of elements in a
+sequence, together. This is called slicing and striding.
 
-.. #[Puneeth: Fix the sentence above. ]
-
-First Slicing 
+First lets discuss Slicing, 
 
 Given a list ::
 
@@ -507,7 +501,31 @@
 
 With this we come to the end of this tutorial .
 
-In this tutorial we have discussed 
+Following is an (are) exercise(s) that you must do. 
+
+
+
+%% %% Check if 3 is an element of the list [1,7,5,3,4]. In case
+it is change it to 21.
+::
+        l=[1,7,5,3,4]
+        3 in l
+        l[3]=21
+        l
+
+%% %% Convert the string "Elizabeth is queen of england" to 
+"Elizabeth is queen"
+::
+
+           s="Elizabeth is queen of england"
+           stemp=s.split()
+           ' '.join(stemp[:3])
+   
+Please, pause the video here. Do the exercise(s) and then continue. 
+
+
+This brings us to the end of the tutorial. In this tutorial we have
+discussed
 
 1. Number Datatypes , integer,float and complex 
 2. Boolean and datatype and operators
@@ -517,16 +535,6 @@
 6. Finding length , sorting and reversing operations on sequences.
 7. Immutability.
 
-
-
-
-.. #[Nishanth]: string to list is fine. But list to string can be left for
-                string manipulations. Just say it requires some string 
-                manipulations and leave it there.
-
-.. #[Nishanth]: Where is the summary
-                There are no exercises in the script
-
 {{{ Show the "sponsored by FOSSEE" slide }}}
 
 This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India