Wednesday, 30 September 2015

Interesting and Basic Programming facts in Python


1. Higher order functions: 

Such functions that takes  at least one or more functions as arguments, returns a function as its result are called as Higher Order functions.
Programme of calculator using Higher order function.

calculations: 

1.Addition
2.Subtraction
3.Multiplication
4.Division
5.Modulus

Programme:


def add(a,b):
 return a+b
def sub(a,b):
 return a-b
def mul(a,b):
 return a*b
def div(a,b):
 return a/b
def modu(a,b):
 return a%b
 
def apply(fucn,a,b): #here it takes a function as argument
 return fucn(a,b)

operatn = [add,mul,div,sub,modu]

for i in operatn:
 print apply(i,5,2)
Output:7 10 2 3 1


2.  Return keyword in function 
if in a function we are using return without any value then it gives a None value. In the below example we can see the output of a programme.

Programme:
def car():
print("car is running")
return
print car()
output:
car is running
None

Keywords In Python Using program

Using Programme:

>>> import keyword
>>> print(keyword.kwlist)
['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']

List of Keywords in Python

                           Keywords in Python programming language

Falseclassfinallyisreturn
Nonecontinueforlambdatry
Truedeffromnonlocalwhile
anddelglobalnotwith
aselififoryield
assertelseimportpass 
breakexceptinraise


Thursday, 10 September 2015

Best Top 10 Websites to learn Python for Beginners

There are Top Sites to learn Python:

1. The Official Python Tutorial https://docs.python.org/2/tutorial/
2. Learn Python    http://www.learnpython.org/
3. Try Python        http://www.trypython.org/
4. Codecademy     https://www.codecademy.com/
5. Python course   http://www.python-course.eu/
6 Tutorialspoint   http://www.tutorialspoint.com/
7. Pyschool           http://www.pyschools.com/
8. Programiz         http://www.programiz.com/
9. Dotnetperls       http://www.dotnetperls.com/

and to learn and understand the execution of Python follow this site:

10. Python Tutor http://www.pythontutor.com/