Basics of Python – Part 1

Download the python interpreter from this link . Choose either 3.0 or 2.0 version depending upon your compatibility. In this exercise version 2.0 was used for examples. Based on the current and future trends I would recommend 3.0.

Now let us look into some basic concepts in python programming language.

Variables:

As with most programming languages, assigning a value for a variable is as simple as:
a = 10

Booleans:

The two switch states True or False can be assigned to a variable.
a = True
(or)
a = False

Reassigning variable values:

A variable b = 10 can be given a value as b = 5 in the next line, and the value can be printed using
print b

Indentation:

Indentation is one of the most important aspect of python, either use a Tab space or 4 white spaces but not both. Here’s an example of a simple python function.

def example()
var = 15
return var
print example()

Single-line Comment:

Use # at the beginning of a line to give a single line comment.
# This is a single line comment in python.

Multi-line Comments:

If the comment is more than one line use double inverted comma’s thrice at the start and end of the comment.
“”” This is a multi-line
comment”””

Basic Math Operations:

All basic math operations such as addition(+), subtraction(-), multiplication(*) and division(%) can be performed similar to other programming languages.
>>print 36 + 64
100
>>print 200 – 100
100
>>print 10 * 10
100
>>print 1000 / 10
100

Exponentiation:

In python, the function of exponential can be performed using ** keys.
>> chairs = 10 ** 2
>> print chairs
100

Modulo:

Modulo operation can be performed using %.

Strings:

Assigning strings values and printing them.
python = “Hello world!”
print(“python”)

Escaping characters:

In python both single quotes and double quotes can be used for commenting. When using single quote, the interpreter doesn’t understands the code. In such cases we can use escape characters such as backslash(\).
‘Isn\’t it the python?’

Accessing by Index:

We can access any character of a string by indexing. Indexing starts from 0.
>>sixth_letter = “python”[5]
>>print sixth_letter
n

String methods:

We can calculate length of the string using len()
>>python = “Indian”
>>len(python)
>>print len(python)
6

We can convert lower case string to upper case string
>>python = “indian”
>>”indian”.upper()
>>print python.upper()
INDIAN

We can convert upper case string to lower case string
>>python = “INDIAN”
>>”INDIAN”.lower()
>>print python.lower()
indian

We can convert a variable to a string
>>pi = 3.14
>>print str(pi)
3.14

So, this concludes basics of python part-1.

Understanding Apache Spark

In my last blog post I had discussed about data, now let us understand a modern tool to process huge datasets(BigData) so as to extract insights from data.

Apache Spark – A fast and general engine for large-scale data processing. Spark is a more sophisticated version of data processing engine compared to engines using MapReduce model.

One of the key feature with Apache Spark is Resilient distributed datasets(RDD’s). These are data structures available in Spark.

Spark can run on Hadoop YARN cluster. The biggest advantage to keep large datasets in memory adds to the capability of Spark over MapReduce.

Applications types that find Spark’s processing model helpful are:

  1. Iterative algorithms
  2. Interactive analysis

Other areas which make Spark more adoptable are:

Spark DAG(Directed Acyclic Graph) – This component of the engine helps to convert variable number of operations into a single job.

User Experience – Spark makes user experience smooth by having a plethora of API’s to perform data processing tasks.

Spark has API’s in these languages: Scala, Java, Python and R.

Spark programming comprising of the Spark shell(also known as Spark CLI or Spark REPL) makes it simple to work on datasets. REPL stands for read-eval-print loop.

Spark on the other hand provides modules for:

  1. Machine learning(MLib) – Provides a framework for distributed machine learning.
  2. Graph processing(Graphx) – Provides a framework for distributed graph processing.
  3. Stream processing(Spark Streaming) – Helpful for streaming(real-time) analytics. Data ingestion takes place in mini-batches and RDD transformations are performed upon these mini-batches.
  4. SQL(Spark SQL) – Provides data abstraction known as SchemaRDD which supports structured and semi-structured data.

These components operate on Spark core. Spark core provides platform for in memory computing and referencing datasets in external storage systems.

Companies that are using Apache Spark – Google, Facebook, Twitter, Amazon, Oracle, et al.

Spark services are provided on notable cloud platforms such as Google Cloud Platform(GCP), Amazon Web Services(AWS) and Microsoft Azure.

Source: Apache Spark

 

Data: The new “OIL” of Information Era

Dataoil

Anything and everything that can be produced, which we can quantify is referred as data. In simple words granular information is data. Automobiles and machinery have been running on oil extracted from earth. In the Internet age devices, machines and all mundane activities shall be driven by data.

All data that exists can be classified into three forms:

  1. Structured Data
  2. Semi-structured Data
  3. Unstructured Data

Structured Data – Structured data is a standardized format for providing information. Examples: Sensor data, machine generated data, etc.

Semi-structured Data – Semi structured Data does not exist in standard form but can be used to derive structured form with little effort. Examples: JSON, XML, etc.

Unstructured Data – Unstructured Data is any data that is not organized but may contain data which can be extracted. Examples: Social media data, Human languages, etc.

Most global tech giants operate from data generated by their users. Google, Amazon, Facebook, Uber, et al. come under the same umbrella. The insights derived from structured and semi structured data can help us in decision making. The magnitude and scale at which these companies generate data is astounding.

Databases play a very important role in storing data. But traditional databases are no longer a choice to store data in today’s fast moving world. New age file systems and infrastructure have started operating to cater the demands of ever expanding Internet space.

In the human world, the voice, speech, text, walking speed, everything can be classified as unstructured data, since we can derive a lot of insights from them. A mobile device per individual is pretty much sufficient to analyse the behavior of a sizable population in a region.

Data collected from a population for a relatively considerable time can be used to derive patterns about the population. Hence, data is the driving force which will fuel innovation and economy from here.

Bengaluru and the spirit of Entrepreneurship

Here is a list of reasons for Bengaluru being a favorite location to start-up:

1 – Technology Infrastructure :- High end systems, high speed internet, ask for anything new in the field of technology, it’s usually first implemented in Bengaluru. That gets Bengaluru a premium tag.

2 – Workforce & Talent :- A plethora of highly qualified professionals makes it a easy choice for most of the entrepreneur’s to choose Bengaluru to kick-start their venture. Engineer’s and Business professionals are a new class of the neatly woven fabric in Bengaluru.

3 – Geographic location :- Weather in Bengaluru is usually pleasant with room temperature hovering between 23°C to 27°C throughout the year with summer being an exception. Bengaluru is the king among metropolitan cities of India, when it comes to weather.

4 – Koramangala :- The Heart of Entrepreneurship for the whole nation is located at koramangala. Visit any street in this locality of Bengaluru and you shall encounter a new venture or business being built. Koramangala is a place that every entrepreneur must visit at-least once in their lifetime.

5 – Government support :- The Karnataka Government has been one of the most proactive government in the country as far as Entrepreneurship is considered. Some of the highly successful Information Technology & Bio-technology ventures started off from Bengaluru by the initial support offered by Karnataka Government. ITPL and many SEZ’s in the city are examples for it.

6 – Cosmopolitan Nature :- This is the ultimate reason for Entrepreneurship to be cherished in Bengaluru. People from different parts of the country live and work in Bengaluru, surely Bengaluru is a “Melting pot”.

7 – Cost of living :- Of late the costs have been going up in Bengaluru considering inflation and other factors. But it’s still affordable for middle class to survive. Cost of living is comparatively cheaper than Delhi and Mumbai.

8 – Education :- The city hosts a series of exceptional institutions, IISc and IIM being the cream. Even at secondary and higher secondary level there are many noteworthy institutions.

9 – Law and Order :- Law & order is usually stable with few huff and puff at times. Law & order is one more reason to choose Bengaluru as a business location.

10 – Healthcare :- Many healthcare bodies are spread-out through the city, there are specialized units in the city where foreigner’s are addressed too. Healthcare facilities are cheaper in Bengaluru compared to International standards.

Bengaluru is the first Indian city to have it’s own logo.

BE”ngalur“U”, BE and U in Bengaluru stands for “Be You”.

Google Analytics for MOHANMA.COM : Launch(26th Jan) to 2nd March

Firstly, thanks to everyone who have visited mohanma.com. The above image shows the global footprint of mohanma.com.

The total number of sessions so far has been 563. India leads in web traffic with 493 sessions. Followed by United States of America, Australia and United Kingdom. Traffic has been flowing in from different parts of Europe, Canada, Peru, China, Japan, etc as well.

To be frank, I have been surprised with the kind of response that mohanma.com has been receiving from day 1. Thanks to all the readers, well-wishers who have been pouring in their feedback via WhatsApp, Facebook and the comments section on website.

Love,

Mohan M A