Showing posts with label a l ict notes sri lanka. Show all posts
Showing posts with label a l ict notes sri lanka. Show all posts

Saturday, May 18, 2013

Python Basics 01

Table of Content 

Python is very easy to use and  it can be used for arithmetic operations. in this section lets look how we can use python as a calculator. This section is described three sections.

Python Basics 01 :- Python Oprerators
Python Basics 02 :- Python Data types, Variables and other basics (This will be discussed in next section)

Python Basics 01 :- Python Operators

An operator is a symbol that is used for calculations. In simple 3 + 5  3 and 5 are operands and + is the operator.Python language supports following type of operators.

  • Arithmetic Operators
  • Comparision Operators
  • Logical (or Relational) Operators
  • Assignment Operators 
  • Conditional (or ternary) Operators


Python Arithmetic Operators



Operator
Description
Example
+
Addition - Adds values on either side of the operator
a + b will give 30
-
Subtraction - Subtracts right hand operand from left hand operand
a - b will give -10
*
Multiplication - Multiplies values on either side of the operator
a * b will give 200
/
Division - Divides left hand operand by right hand operand
b / a will give 2
%
Modulus - Divides left hand operand by right hand operand and returns remainder
b % a will give 0
**
Exponent - Performs exponential (power) calculation on operators
a**b will give 10 to the power 20
//
Floor Division - The division of operands where the result is the quotient in which the digits after the decimal point are removed.
9//2 is equal to 4 and 9.0//2.0 is equal to 4.0

Now let's see some examples in python IDE. (click here to see how the python GUI is opened)

Saturday, May 11, 2013

Python Introduction


 

What is Python

 Python is a High Level Language. And it is also an Interpreted and Object Oriented Language. Since this is an interpreted language you do not need to compile your program before executing. The program will process at the runtime. Since python is an Object Oriented Programming language we can use Inheritance, Encapsulation, and Polymorphism. [These are described in Object Oriented Concept Topic]
Why Python
Python is refers as a scripting language. But it can also used as non scripting programming language also. Python is very easy to learn language and easy to read and understand language. It has lot of in build libraries that helps programmers easy to program. It has capability of connecting to any kind of databases and do programming.

Install Python (Windows)

Thursday, May 2, 2013

Number System (Fraction Number Conversion)

Hope you have gone through Number System (Decimal Number Conversion)
and have a good Idea. Now let's look how the fractions are converting to binary and octal.

Fraction to Binary

Examples for fraction numbers are 123.525, 12.123. When converting these numbers first we take the fraction part and multiply it by 2. The portion which is come before decimal point write it as it is. then write it from up to bottom. see the example.

example 1:- 0.0625




 


 

example 2 : - 121. 8125







 



Fraction to Octal

Wednesday, May 1, 2013

Number System (Decimal Number Conversion)

Decimal To Binary

 The decimal number system (base ten) has ten possible values ​​(0,1,2,3,4,5,6,7,8 or 9) for each place value. In contrast, the binary number system (base two) has two possible values​​, often represented as 0 or 1 for each place-value
To convert Decimal to binary we divide the decimal number from 2 until we get 0  and remain is written in front of the number as following example.
Then we write the number from below to above as shown in that example. Conversion 


Decimal To Octal