Python If Statements

Python If Statements


If statements are used to test for particular conditions and respond approptiately.

#conditional tests

print(x == 42)

#not equal 
print(x != 42)

#greater than 
print(x > 42)

#or loss equal to 
print(x <= 42)

#less than  
print(x > 42)

#or equal to 

print(x >= 42)

#conditional test with lists
print('trek' in bikes)
print('surly' not in bikes)

#Assigning boolean values
game_active = True
can_edit = False

#A simple if test
if age >= 18:
 print("you can vote!")

#If-elif-else statements
if age < 4:
 ticket_price = 0
elif age < 18:
 ticket_price = 10
 ticket_price = 15



python if statement

Python Tuples

Python Tuples


#Making a tuple
dimensions = (1920, 1080)


python tuples


Python Lists(cont.)

Python Lists(cont.)


#List comprehensions
square = [x**2 for x in range(1,11)]

#slicing a list
finishers = ['sam', 'bob', 'ada', 'bea']

#copying a list
copy_of_square = square[:]


python list


Python List

Python Lists

python list


A list stores a series of items in a particular order. you access items using an index, or within a loop.

#Make a list
bikes =['trek', 'redline', 'giant']

#Get the first item in a lists
first_bike =bikes[0]

#Get the last item in a list
last_bike =bikes[-1]

#looping through a list
for bike in bikes:

#Adding item to list
bikes = []





#Making numerical lists
square = []
for x in range (1,11):



python list


Python Variables And String

Python Variables And String


Variables are used to store values. A string is a series of character, surrounded by single or double quotes.

#Hello world
print("hello world")
#Hello world with a variable
msg = "Hello world"
#Concentration (combining strings)
first_name = 'albert'
last_name = 'einstein'
full_name =first_name + '' + last_name

Python variables Assignment

Python variables Assignment

Variables in Python

Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory.

#assignment=binding of a name with a value 
#1. evaluation of right side expression value
#2. assignment in order with left side names
a=b=c=0 #assignment to some value
y, z, r=9.2, -7.6, 0 #multiple assignment
a, b=b, a #values swap
a, *b=seq #unpacking of sequence in
*a, b=seq #item and list
x+=3 #increment=x=+3
x-=2 #decrement=x=x-2
x=None #undefined (constant value)
del x #remove name x

Python Identifiers

Python Identifiers
Identifiers in Python

An identifiers is a name given to program element such as variables, array, class and function etc. An identifier is a sequence of letters, digits, and underscores, the first character of which cannot be a digit.

#for vaiables, functions, modules, classes... names
#followed by
#diacritics allowed but should be avoided
#language keywords forbidden
#lower/UPPER case discrimination

Python Container Types

Python Container Types

Container Types in python
  • Ordered sequences, fast index acess , repeatable values 
#ordered sequences, fast index access, repeatable values
list [1, 5, 9] ["x", 11, 8.9] ["mot"]
tuple (1, 5, 9) 11, "y", 7.4  ("mot",)
str bytes (ordered sequences of chars/bytes)
#Key container, no a priori order , fast key access, each key is unique

 dict {"key":"value"}
dict (a=3, b=4, k="v")
#(key/value associations)
{1:"one", 3:"three", 2:"two", 3.14:"n"}
set{"key1","key2"}  {1, 9, 3, 0}
#keys=hashable values (base types, immutables...)  frozenset immutable set


print a
print b
print c
print d
print e
print f
print g
print j
print k


python container

Python Base Types

Python Base Types

Base Types in Python

Every value in Python has a datatype. Since everything is an object in Python programming, data types are actually classes and variables are instance (object) of these classes.

Base Types

Integer, float, boolean, string, bytes.

int 783
int 0 #zero
int -192 #negative
int 0b010 #binary
int 0o642 #octal
int 0xF3 #hexa
float 9.23
float 0.0
bool True False
str "One\nTwo"
bytes b"toto\xfe\775"

Example :
a=10 #int
b=20.1 #float
abc="hello" #string
print a
print b
print abc


Android Studio

Android Studio

What is android?

Android is a mobile operating system currently developed by Google, based on the Linux kernel and designed primarily for touchscreen mobile devices such as smartphones and tablets. And as we said before, Android offers a unified approach to application development for mobile devices.

Android is an open-source operating system named Android. Google has made the code for all the low-level "stuff" as well as the needed middleware to power and use an electronic device, and gave Android freely to anyone who wants to write code and build the operating system from it. There is even a full application framework included, so third-party apps can be built and installed, then made available for the user to run as they like.

 Android has the largest installed base of all operating systems of any kind. Android has been the best selling OS on tablets since 2013, and on smartphones it is dominant by any metric. Android pie is latest version of Android.

What is android studio?

Android Studio is a popular IDE developed by Google for developing applications that are targeted at the Android platform. Note that Android Studio has replaced Eclipse as the IDE of choice for developing Android applications. This article presents a discussion on how to get started using the Android Studio for developing Android applications.

It’s an Android focused IDE, designed specially for the Android development. It was launched on 16th May 2013, during Google I/O 2013 annual event. Android studio contains all the Android sDK tools to design, test, debug and profile your app. By looking at the development tools and environment, we can its similar to eclispe with the ADT plug-in but as I have mentioned above its android focused IDE, there are many cool features available in Android Studio which can foster and increase your development productivity.
One great thing is that it depends on the IntelliJ Idea IDE which is proved itself a great IDE and has been using by most all the Android engineers.
Android Studio is Google’s recommended environment for developing Android applications, and plenty of new features were announced at Google I/O. Some of those improvements have now landed in the beta branch, with the release of Android Studio 3.2 Beta. The main new feature in Android Studio 3.2 is the ability to generate App Bundles.

Cool features of Android Studio

  • Powerful code editing (smart editing, code re-factoring)
  • Rich layout Editor (As you soon as you drag and drop views on the layout, it shows you preview in all the screens including Nexus 4, Nexus 7, Nexus 10 and many other resolutions. Layout designing can be done much faster way as compared to eclipse.)
  • Gradle-based build support
  • Maven Support
  • Templated based wizards
  • Lint tool analysis (The Android lint tool is a static code analysis tool that checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, accessibility, and internationalization.).
Android Api levels And Version

How To Install Android Studio.

Before you begin downloading Android Studio, create a labs parent directory for the labs you will create in this book. We use C:\androidBook\ as our labs’ parent directory throughout the book, but you may choose or create whatever directory you see fit. For that reason, we simply call it the labs parent directory. 

Downloading Android Studio is straightforward. Point your browser to this site:

 Now click the large green Download Android Studio for your OS button, Next, select the check box labeled I Have Read and Agree with the Above Terms and Conditions. Click Download Android Studio for your OS again, and your installation file should begin downloading. Once the download is complete, execute the file you just downloaded.

After the Installation Wizard begins, move through its screens by clicking the Next buttons until you reach the Choose Components screen. There, select all the component check boxes. Then click Next. Agree to the terms and conditions once again. When you reach the Configuration Settings: Install Locations screen, select the locations for Android Studio and the Android SDK. To be consistent, we chose to install Android Studio in C:\Java\astudio\ and the Android SDK in C:\Java\asdk\.

Click through several Next buttons as you install both Android Studio and the Android SDK. You should eventually arrive at the Completing the Android Studio Setup screen. The Start Android Studio check box enables Android Studio to launch after you click Finish. Make sure the check box is selected, and then go ahead and click Finish, and Android Studio will launch. Please note that from here on out, you will need to navigate to either the desktop icon or the Start menu to launch Android Studio.

When Android Studio starts for the very first time, the Setup Wizard, will analyze your system looking for an existing JDK (such as the one you installed earlier), as well as the location of the Android SDK. The Setup Wizard should download everything you need to begin developing apps in Android Studio. Click the Finish button to dismiss the Setup Wizard.

Starting a new project

Once Android Studio is up and running, you’ll want to dive in and create a new project. You can do this by launching Android Studio and then selecting New Project, or you can choose File > New > New Project at any time from the IDE itself.

You’ll then have the opportunity to choose from a number of different types of activity. Activities are effectively ‘screens’ in an app. In some cases, this will be the entire app or in others, your app might transition from one screen to the next. You’re free to start a new project with no activity (in which case, you would choose ‘Add No Activity’) but you’ll almost always want one, so it’s easier to let Android Studio set you up with something resembling a blank app template to begin with.

Often you’ll choose a ‘Basic Activity’, which is the default look and feel for a new Android App. This will include a menu in the top right corner, as well as a FAB button – Floating Action Button – which is a design choice that Google is trying to encourage. An ‘Empty Activity’ is the same thing but without the added chrome.
Pick the option that best suits the app you have in mind to build and this will impact on the kind of files you are presented with when you first start things up. You’ll also be able to choose your app’s name at this point, the minimum Android SDK you want to support and the package name. The package name is the final file name that the app will have when you upload it to the Play Store – a combination of the app’s name, along with the name of the developer.

Follow Tutorial

Web Socket

Web Socket 


What Is Websocket?

The WebSocket Protocol is a widely supported open standard for developing real-time applications. Previous methods for simulating full-duplex connections were based on polling, a synchronous method wherein the client makes a request to the server to see if there is any information available. The client receives a response from the server even if there is no information available.
websocket server

WebSocket is a communications protocol for a persistent, bi-directional, full duplex TCPconnection from a user’s web browser to a server.
A WebSocket connection is initiated by sending a WebSocket handshake request from a browser’s HTTP connection to a server to upgrade the connection. Along with the upgrade request header, the handshake request includes a 64-bit Sec-WebSocket-Key header. The server responds with a hash of the key in a Sec-Websocket-Auth header. This header exchange prevents a caching proxy from resending previous WebSocket exchanges.
WebSockets: how it works and 
how to use it

websocket work

WebSocket is an advanced technology that allows you to start bi-directional cummunication session between the browser and the server. Thanks to this protocol it is possibility to send request to the server and receive an answer as events, what means that you don't have to re-send the request to the server. WebSockets bring many benefits and it can be used in a various projects. Learn why you should and how to use this technology.

How it works?

websocket works

Websockets is a web technology, which allows bi-directional, real-time communications between web client and a server. As  part of the HTML5 specification it works with the newest web browsers (including Internet Explorer 10 and its latest versions).
Every connection begins as HTTP to provide full support for legacy solutions. Web client sends a request to the server and, if the server supports the WebSockets protocol, it sends a response, in which it overwrites the connection header. Since this moment a WebSockets-based connection is made.

Create a WebSocket Connection

To connect to a remote host, create a new WebSocket object instance and provide the new object with the URL of the target endpoint.
A WebSocket connection is established by upgrading from the HTTP protocol to the WebSocket Protocol during the initial handshake between the client and the server, over the same underlying TCP connection. An Upgrade header is included in this request that informs the server that the client wishes to establish a WebSocket connection. Once established, WebSocket messages can be sent back and forth using the methods defined by the WebSocket interface.

websocket connection in java

To create a connection, call Javascript’s WebSocket constructor, which returns the connection instance object. You can then listen for events on that object. These events are triggered when the connection opens or closes, messages arrive, or errors occur. You can interact with the WebSocket instance to send messages or close the connection.
The WebSocket constructor takes one required argument: the URL to which we want to connect. There is one optional argument that specifies a protocol.

WebSockets fast as lightning

According to some studies WebSockets protocol is three times faster than HTTP, what means the improvement of the speed of data exchange between applications. One of the biggest advantages of using WebSockets is that it doesn't interfere with firewalls and proxy servers, which was the bane of the most solutions.
The most common examples of the WebSockets protocol usage are real-time applications such as IM, collecting and analysing data, ducuments cooperation or browser games.
WebSocket for Developers and Architects
websocket server architecture
 Web Socket is an independent TCP-based protocol, but it is designed to support any other protocol that would traditionally run only on top of a pure TCP connection.
  Web Socket is a transport layer on top of which any other protocol can run. The Web Socket API supports the ability to define sub-protocols: protocol libraries that can interpret specific protocols.
  Examples of such protocols include XMPP, STOMP, and AMQP. The developers no longer have to think in terms of the HTTP request-response paradigm.
  The only requirement on the browser-side is to run a JavaScript library that can interpret the Web Socket handshake, establish and maintain a Web Socket connection.
  On the server side, the industry standard is to use existing protocol libraries that run on top of TCP and leverage a Web Socket Gateway.

What are the benefits of WebSockets?

benefits of websocket

WebSockets, part of the HTML5 specification, enables two-way communication between web pages and a remote host. The protocol is designed to achieve the following benefits:
  • Reduce unnecessary network traffic and latency using full-duplex through a single connection (instead of two).
  • Streaming through proxies and firewalls, supporting simultaneously upstream and downstream communication.
  • Backward compatible with the pre-WebSocket world by switching from an HTTP connection to WebSockets.

Laravel Introduction

Laravel Introduction

laravel framework

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, and caching.

Since its initial release in 2011, Laravel has experienced exponential growth. In 2015, it became the most starred PHP framework on GitHub and rose to the go-to framework for people all over the world. Laravel is a web application development framework for PHP. It makes the task of building a database-backed PHP app much easier than if you simply started from scratch. 

This framework is open source framework. It facilitates developers by saving huge time and helps reduce the thinking and planning to develop the entire website from scratch. Along with that security of the application is also Laravel take care of. Hence all its features can boost the web development pace for you. If anyone is familiar with the basics of PHP along with some intermediate PHP scripting, then Laravel can craft your work more easily.

History of laravel

History of laravel

Laravel was developed and created by Sir Taylor Otwell as an attempt for giving an excellent substitute for the older PHP framework named CodeIgniter. And this was because CodeIgniter did not offer such great features like support for built-in customer authentication and proper user authorization.

 On 9th of July, 2011 Laravel released its first beta version, and later in same month Laravel 1 got released. Other than authentication, Laravel also has built-in support for localization, views, dealing with sessions, routing the request to the specific controller and other amazing features. Since its initial release in 2011, Laravel has experienced exponential growth. In 2015, it became the most starred PHP framework on GitHub and rose to the go-to framework for people all over the world.

Top Six Features of Laravel Framework

It is the latest and best web application framework with advanced query syntax that makes web development very simple. It is helpful for developing web applications for different industries like tourism, finance, education etc. Here, are some most important features of 5.0.1 which make this PHP framework an ideal choice for developing various kinds of enterprise web applications.

features of laravel

1. Entirely new directory structure:

Laravel 5.0.1 comes with an entirely new directory structure. Laravel 5.0.1 uses PSR-4 autoloading standards that mean all the classes are fully namespaced now. In this version, config, storage, and database folders are moved from the app folder in the new structure. Additionally. It offers the new resources folder for containing language and template files.
2. Route caching:

Route caching feature speeds up the application route registration. This feature is ideal for such development projects that have large numbers of routes. However, once route caching is turned on, any changes that you make to the application routes will not take effect. Routing caching is generally implemented as a part of the deployment process.
3. Inbuilt Authentication System:

Authentication is very crucial part of any web application because developers are spending the lots of time for coding authentication of any enterprise system. Authentication made simpler with Laravel 5.1, as it comes with inbuilt authentication. Developers only need to configure database, controllers, models to make this system work.
4. Multiple file system support:

Laravel 5 offers great support for multiple file system for that it uses third party package Flysystem to provide support for multiple files. It provides an option for developers to use local or cloud-based storage to provide simple configuration. Moreover, developers can easily set storage options in config/filesystems.php file.
5. Improved method injection:

Method Injection has improved a lot with the Laravel 5.0.1. Until this update, web developers need to demand inversion of control to provide a class instance. But now they can declare the type hinted class instance in the controller method’s signature.
6. Contracts:

contracts are basically a set of interfaces that defines the core services. If developers wants caching in a package, they can easily do that by using Illuminate\Contacts\cache. It allows developers to do cache programming using the concrete cache class without needs to change the package code.

These are some of the most important features of Laravel 5.1 development. Apart from these, there are other features like queue and task scheduling, request object, Laravel socialite etc. With this version, Laravel framework has improved a lot from the architectural perspective.

Laravel: An efficient PHP web development framework

Laravel is a modern-age, open source, and highly flexible PHP-based web application development framework that is used for supporting faster and effective customized web development services. Developed in 2011, the PHP Laravel web development framework is comparatively new. However, with its plethora of attractive features and ease of use, it has managed to become a leading web development option for the web developers around the globe.
php web development framework
Right after its advent into the technology world, Laravel has emerged itself to be a colossal web development supportive community offering an array of important learning resources as well as tutorials towards helping out the web developers and programmers across the globe into designing and developing highly interactive web portals and applications. This is the reason why Laravel is used by most of the PHP developers and programmers out there towards shaping the diverse range of highly functional web applications.

Reasons why laravel the best PHP framework for web development

best php framework

• Effective authorization process.

• Presence of object-oriented libraries.

• Useful MVC support.

• Top-notch security.

• Seamless database migration.

• Amazing useful tutorials.

Laravel Web Development has the following advantages:

php framework advantage

  1. → This web application framework makes the development process quite easier. It takes very little time to complete the web project with the help of this software.
  2.  → This increases the number of online traffic in your website. Now the question is how? Well, this technology is applicable on any browser and device as well. 
  3.  → It incorporates certain flexible features in your applications. It also includes the modular packaging systems. Thus, it will help simplify the website. 
  4.  → You can also create different routes with the name of the same existing route. This is because Laravel can create unique URLs in regards to it. 
  5.  → The PHP does not need special inclusion paths and maintenance. It is due to an auto loading facility contained in this software.