Posts

Showing posts with the label programming

Angular Overview and Basic Introduction

Image
  Angular Introduction Angular JS (Commonly knows as Angular)  is an exceptionally powerful front-end development framework for building sophisticated JavaScript apps. Angular has offers : Modularity that allows a team of developers to work on specific parts of an app concurrently Testability and maintainability of your app’s various pieces A big, thriving community of developers and organizations who love Angular Clean separation of the app’s UI from its logic, while still keeping them in sync Two-way data-binding — it’s pure magic (or sorcery?) — that updates the UI whenever a model changes (and vice versa) Useful out-of-the-box (as well as third-party-developed) modules such as Filters and Services that take the complexity out of stuff like data-processing, templating of UIs, dealing with HTTP requests, sanitizing and validating user inputs, animation, and (much, much) more Should you decide to learn Angular, you’ll be endowed with the skills required to develop cross-platf...

Angular : List of Topics

Image
We Start our new tutorial on Angular. In Angular we covers below topics in details: - Basic Introduction - Environment Setup - Project Setup - Components - Modules - Data Binding - Event Binding - Templates - Directive - Pipes - Routing - Services - Http Clients  - Use of Forms

OOP concept in Python - Part 2

Image
Methods  One way we can improve our use of classes is to add functions to them. These class functions are known by their more common name, methods. In Python, methods are defined as part of the class definition, but can be invoked only on an instance. In other words, the path one must take to finally be able to call a method goes like this: (1) define the class (and the methods), (2) create an instance, and finally, (3) invoke the method on that instance.  Here is an example class with a method class MyDataWithMethod(object):             # define the class  def printFoo(self):                                    # define the method  print 'You invoked printFoo()!' You will notice the self argument, which must be present in all method declarations. That argument, representing the instance object, is passed to the method implicit...

OOP concept in Python - Part 1

Image
Classes and Instances Classes and instances are related to each other: classes provide the definition of an object, and instances are "the real McCoy," the objects specified in the class definition brought to life. Here is an example of how to create a class:  class MyNewObjectType(bases):  'define MyNewObjectType class'   class_suite The keyword is class, followed by the class name. What follows is the suite of code that defines the class. This usually consists of various definitions and declarations. The biggest difference between declaring new-style classes and classic classes is that all new-style classes must inherit from at least one parent class. The bases argument is one (single inheritance) or more (multiple inheritance) parent classes to derive from. The "mother of all classes" is object. If you do not have any ancestor classes to inherit from, use object as your default. It must exist at the top of every class hierarchy. If you do n...

Python Global, Local and Nonlocal variables

Image
Global Variables In Python, a variable declared outside of the function or in global scope is known as global variable. This means, global variable can be accessed inside or outside of the function. Let's see an example on how a global variable is created in Python. Example 1: Create a Global Variable When we run the code, the will output be: x inside : global x outside: global In above code, we created  x  as a global variable and defined a  foo()  to print the global variable  x . Finally, we call the  foo()  which will print the value of  x . What if you want to change value of  x  inside a function? When we run the code, the will output be: UnboundLocalError: local variable 'x' referenced before assignment The output shows an error because Python treats  x  as a local variable and  x  is also not defined inside  foo() . To make this work we use  global  keyword, t...

Python Anonymous/Lambda Function

Image
What are lambda functions in Python? In Python, anonymous function is a  function  that is defined without a name. While normal functions are defined using the  def  keyword, in Python anonymous functions are defined using the  lambda  keyword. Hence, anonymous functions are also called lambda functions. How to use lambda Functions in Python? A lambda function in python has the following syntax. Syntax of Lambda Function in python lambda arguments: expression Lambda functions can have any number of arguments but only one expression. The expression is evaluated and returned. Lambda functions can be used wherever function objects are required. Example of Lambda Function in python Here is an example of lambda function that doubles the input value. In the above program,  lambda x: x * 2  is the lambda function. Here  x  is the argument and  x * 2  is the expression that gets evaluated and return...

Python Recursion

Image
What is recursion in Python? Recursion is the process of defining something in terms of itself. A physical world example would be to place two parallel mirrors facing each other. Any object in between them would be reflected recursively. Python Recursive Function We know that in Python, a  function  can call other functions. It is even possible for the function to call itself. These type of construct are termed as recursive functions. Following is an example of recursive function to find the factorial of an integer. Factorial of a number is the product of all the integers from 1 to that number. For example, the factorial of 6 (denoted as 6!) is 1*2*3*4*5*6 = 720. Example of recursive function In the above example,  calc_factorial()  is a recursive functions as it calls itself. When we call this function with a positive integer, it will recursively call itself by decreasing the number. Each function call multiples the number with the facto...