Tuesday, February 14, 2012

Python Programming for Beginers

Python is a general-purpose, high-level programming language. It's design is emphasized by code readability. Python has a very clear syntax with a large and comprehensive standard library.

Python multiple programming paradigms object-oriented and functional programming styles. It has a dynamic type system and automatic memory management (dynamic languages).
 
Python is often used as a scripting language, and also used in non-scripting contexts. Using third-party tools, Python code can be packaged into standalone executable programs. Python interpreters are available for many operating systems.



Day 1 Download Python , Installing, Basic Mathwww.python.org under GNU GPL. It was first

Python is FOSS (Free and Open Source Software) available from

Day 2
Variables and ProgramsVariables are containers in memory used by programs to keep run time data, edit them and strore new value. They can be accessed with names assigned to them. Variables have different types numeric, strings and logical are the basic data types.
The program is a rows of programming instructions to the computer to store data, recall data, calculate, perform operations and test certain conditions etc. It can be re used when saved in hard disk and re-loaded to memory to run its task.
Day 3
Strings and their Uses
Day 4
  • Python Programming Tutorial - Raw Input

Day 5Conditions help you compare data to help branching of the programming flow. They make you switch between different instruction paths based on condition.

  • Python Programming Tutorial - else and elif 
    • Python Programming Tutorial -  If Statement

    Day 6
    Comparing numbers, strings and or conditions. Different comparison operators let you compare numbers and conditions during run time to switch to different conditions and options to run different code.

    Day 7Nested Statements and Looping
    You can run code inside another code block to execute different instruction lines. Each nested code are is a code block.
    • Python Programming Tutorial - Nesting Statements
    Day 8LoopingPython lets you run a code block repeated until a certain condition is met. For ...Next and Do .... Loop repetitions can be used in python.

    Day 9Lists and List Functions Python Programming Tutorial - Sequences and Lists Python
    Programming Tutorial - List Slicing

    Lists are like arrays which keeps multiple data items in a single variable. Each data item is referenced by its element id. Consider a list as a container of containers with each container can hold more containers. This is a very strong data structure in python compared to other programming languages. Slicing is getting a desired set of elements from a list. Lists have list processing Functions.

    Day 10 Methods Python Programming Tutorial - Introduction to Methods

    Day 11 Python Programming Tutorial - Sort and Tuples
    Tuples are simple lists. But not editable during run time.

    Day 12 Python Programming Tutorial - Dictionaries
    Dictionaries are lists where element id is a keyword or alphanumeric identifier.
    Day 13
    Files Operations , data Reading and Writing

    Day 14

    Day 15 Functions can have default set of variables called parameters that can be used to pass variable data. Parameters can make functions to act on different Data sets and return results.

    Python Programming Tutorial - Default Parameters

    Day 16 Parameters can have different types and you can pass tuples , lists and dictionaries as paramerters. Python Programming Tutorial - Parameter Types

    Day 17OOP uses objects with properties , and events and methods. OOP helps you create objects and store data as properties. Objects responds to events executing their methods.
    Python Programming Tutorial - Object Oriented Program


    Day 18
    Classes as objects and they can be referenced as Self inside objects.


    Python Programming Tutorial - Classes and Self

    Python Programming Tutorial - Subclasses Superclasses

    Day 19
    Sub classes are created from Classes. Super classes are parents of sub classes. Sub classes created from Super classes can have common as well as different properties, events and methods which help them behave differently.


    Day 20
    In OOP you can override variables in sub classless

    Python Programming Tutorial - Overwrite Variable on Sub

    Day 21Classes can have multiple parents.

    Python Programming Tutorial - Multiple Parent Classes


    Day 22
    Creating Classes and Initializing their properties with data.
    Python Programming Tutorial - Constructors


    Modules are separate programs that can be used in multiple programs as different code units. Much effiecient way than using functions. Help programs to be modular and efficeient. Modules make programming easy and sharable by multiple programmers to provide specific functionality in a program.

    Day 24Python Programming Tutorial - Reload Modules
    Python Programming Tutorial - Getting Module InfoPython Programming Tutorial - Building Functionsfunctions help us develop smaller programs by repeated using a code block as a procedure that can be called as one instruction. Then the code block runs as a re-usable unit of code. Python Programming Tutorial - For and While Loops Data Inputs are two different types in Python. You can input data as numbers or raw. If you enter numeric data as raw you need to convert type to numeric before using in calculations. String  are input as raw. Strings help us keep alphanumeric data as a sequence of characters with varying length.

  • Python Programming Tutorial - More Methods

  • Python Programming Tutorial - Strings n Stuff

  • Python Programming Tutorial - String Methods 


  • Python Programming Tutorial - Infinite Loops and Break


  • Python Programming Tutorial - And and Or


  • developed by Guido van Rossum of Netherlands as a successor to the ABC programming languageas. Python is a object oriented programming language. Python runs on all platforms including mobiles. Python is an interpreter language and also can be used as compiled. Handing numbers and math is important in programming.  Numbers have different types integer, long, double and float etc for different accuracy needs in calculations.

    Thursday, February 9, 2012

    Unified Modeling Language (UML)

    UML is an industry standard modeling language which uses visual diagrams and elements to create software documentation and design. 


    Build detailed UMLmodels.
    Manage project complexity.
    Reverse engineer legacy code and database schema.
    Produce reports.
    Track changes
    Involve the whole design team.


    UML defines following diagrams 
    Package diagrams
    Class or Structural diagrams
    Object diagrams
    Composite Structure
    Component diagrams
    Deployment diagrams
    Use Case Diagrams
    Activity diagrams
    State Machine diagrams
    Communication diagrams
    Sequence diagrams
    Timing diagrams
    etc.


    UML used in scientific and business worlds. The UML is a tool for specifying software systems. Standardized diagram types to help you describe and visually map a software system's design and structure. UML is independent of target platform. UML is naturally oriented towards Object-Oriented programming.
    The  UML is a tool for defining the structure of a system to manage large, complex systems. Building up libraries of UML Patterns simplifies the re-use of models and code.


    UML defines the notation and semantics for the following domains:


    Use Case Model - Describes boundary and interaction between the system and users. 


    The Interaction Model - describes how objects in the system will interact with each other.


    The State Model - Describe states /conditions of classes change over time. 


    The Class Model - describes the classes and objects 


    The Physical Component Model- describes the software and hardware components


    The Physical Deployment Model - describes the physical architecture and the deployment of components on a hardware architecture.

    Thursday, January 26, 2012

    SQL Training Questions

    1.Which of the following is true?
    a.TRUNCATE TABLE is identical to DELETE statement without WHERE clause and both remove all rows in a table.
    b.TRUNCATE TABLE has to be used along with a WHERE clause
    c.TRUNCATE TABLE deletes table from a database


    2. We refer to a join as a self-join when…
    a. we are joining more than 2 tables
    b. we are joining table to itself.
    c. we are using left and right join together


    3. What does SQL stand for?
    a. Standard Query Language.
    b. Strong Query Language
    c. Strict Query Language
    d. Structured Query Language.


    4. Which of the following SQL statements deletes all rows in table called SalesData?


    a. DELETE FROM SalesData
    b. DELETE SalesData
    c. DELETE ALL SalesData
    d. DELETE * FROM SalesData




    5. If you don't specify ASC or DESC after a SQL ORDER BY clause, the following is used by default:


    a. There is no default value.
    b. DESC
    c. ASC


    6. If you join a table to itself, what kind of join are you using?


    a. You can't join a table to itself.
    b. Selective Join.
    c. Self Join


    7. Can the SELECT clause list have a computed value like in the example below? SELECT CustomerName, UnitPrice * NumberofUnits FROM Sales 


    a. Yes.
    b. No


    8. When inserting data in a table do you always have to specify a list of all column names you are inserting values for?


    a. Yes
    b. No


    9. Which of the following SQL clauses is used to enter data into a SQL table?


    a. WRITE
    b. ENTER
    c. SELECT
    d. INSERT INTO


    10. Which of the following SQL clauses is used to select data from 2 or more tables?


    a. JOIN
    b. HAVING
    c. WHERE


    11. The FROM SQL clause is used to…
    a. specify search condition
    b. specify what table we are selecting or deleting data from.
    c. specify range for search condition


    12. Can you use both HAVING and WHERE SQL clauses in one SQL statement?
    a. No.
    b. Yes.


    13. Can you join a table to itself?
    a. Yes.
    b. No.


    14. Which of the following 3 SQL statements is correct?


    a. SELECT Username, Password FROM Users
    b. SELECT Username, Password WHERE Username = 'user1'
    c. SELECT Username AND Password FROM Users


    15. What does the ALTER TABLE clause do?


    a. used to delete a database table.
    b. modifies a table definition by altering, adding, or deleting table columns.
    c. used to insert data into database table.
    d. deletes data from database table.


    16. Which SQL keyword is used to retrieve a minimum value?


    a. MIN
    b. DOWN
    c. LOW
    d. LOWER

    Friday, January 6, 2012

    Database Models

    Flat-File  Database Model

    • ideal for small amounts of data
    • human readable or edited by hand
    • good for simple lists
    • more costly in time and processing power
    • data split up using a common delimiter like comma or TAB
    • one line per records
    • very prone to corruption
    • no inherent locking mechanisms


    Relational Database Model

    • MySQL, Microsoft SQL Server ,  Oracle, Access , Portgress SQL 
    • Tables represent real world objects, 
    • each field is an attribute of the object
    • table - students
    • field - firstname. lastname, Class, Age, Village
    • record- Nimal, Perera, 12A, 17, Penideniya


    • tables can be linked to each other (students --> subjects  , subjects > teachers,  students ---> marks <----Subjects <---- Teachers
    • databases designed efficiently
    • no duplication of any data; 
    • maintain database integrity.
    • Can be huge saving in file size, 
    • deals with large volumes of data. 
    • have  "built in" functions to help retrieve, sort and edit the data 
    • RDBMS - relational database management system
    • developed by E.F. Codd. 
    • A relational database allows the definition of data structures, storage and retrieval operations and integrity constraints. 
    • data and relations between them are organised in tables. 
    • A table is a collection of records and each record in a table contains the same fields. 
    • based on the Relational Algebra and set theory


    Hierarchical  Database Model
    • Organizes data in a tree structure (parent and child data)
    • Data in a series of records, which have a set of field values attached to it. 
    • have record types. These record types are the equivalent of tables in the relational model,
    • individual records is the equivalent of rows. 
    • To create links between these record types,uses Parent Child Relationships. 
    • 1:N mapping between record types. 
    • uses Binary trees, like 


    • an organization  stores information on an employee ( name, employee number, department, salary) 
    • an store information about an employee's children, (name and date of birth)
    • The employee and children data forms a parent, child hierarchy
    • If an employee has three children, three child segments associated with one employee segment.
    • restricts a child segment to having only one parent segment. 
    • popular in late 1960s - 1970s.  (IBM)


    Network Database

    • Some data modeled with more than one parent per child. 
    • permitts modeling of many-to-many relationships in data.
    • The data model is a simple network 
    • The CODASYL network model is based on mathematical set theory. 



    Object/Relational Databases

    • ORDBMSs
    •  adds new object storage capabilities to the relational systems at the core of modern information systems. 
    • to integrate management of traditional fielded data with complex objects 
    • (geospatial data, audio, video, images, and applets)
    •  tabular structures and data definition languages (DDLs) w
    • SQL3, ODBC, JDBC (IBM, Informix, Sun and Oracle )


    Object-Oriented Database Model


    • adds database functionality to object programming languages. 
    • useful when we have complex relationships between data
    • C++, Smalltalk and Java 
    • The power of the OODB comes from persistent data in databases, and transient data in executing programs.
    • object DBMSs have no performance overhead to store or retrieve interrelated objects.
    • mapping of object programming language objects to database objects 
    • provides higher performance
    • better management of the complex interrelationships between objects. 
    • financial portfolio risk analysis systems
    • telecommunications service applications
    • world wide web document structures, 
    • design and manufacturing systems
    • hospital patient record systems