Friday 15 February 2019

First Program in Python

Open your favorite text editor and type the following program.

Python Code :
def printMessage( ):
  print("The Quick Brown Fox Jumps Over The Lazy Dog!")
if_name_=="_main_":
printMessage( )

Let us look at the program line by line to understand what it is doing.

Python Code :
def printMessage( ):
  print("The Quick Brown Fox Jumps Over The Lazy Dog!")

The above line is a function in Python.The function is printing a message to the screen.

Python Code :
if_name_=="_name_":

The above line checks if the module is running as main.
When python runs the module, it sets _name_variable to the value_main_.
Main check is the entry point for a Python Program.

Python Code:
printMessage( )

The above line is a function call in Python.
The function call printMessage was defined above.

We can call function defined in other modules by importing them.We can use import keyword to import other functions.Similarly other modules can import printMessage function by importing from our file.

We can save the file to a favorite location. 
Name the file: HelloWorld.py. We can run the file using the following command .

Command:
python HelloWorld.py

Output:
The Quick Brown Fox Jumps Over The Lazy Dog!

Thursday 14 February 2019

Range and Xrange in Python

Range function in Python can be used to generate a range of values.

Example if we call range(10), we will get values 0 to 10 in a list.

If we call range (1,11), we will get values 1 to 10 in a list.

Let us look at a few examples to understand better.

Python Code :
range(5)

Output :
[1,2,3,4]

Python Code :
range(2,7)

Output :
[2.3,4,5,6]

Python Code :
range(1, 10, 2)

Output:
[1,3,5,7,9]

In above example, we only printed odd numbers. We could do that by passing a third increment parameter to range.

xrange function is similar to range function. But it is very efficient for large sets.When range is invoked, it creates a static list and returns the result.

However with xrange, it gives a pointer and only gives the next value on demand when iterating over the list. This can prevent out of memory errors.

Python Code :
list(xrange(5))

Output :
[1,2,3,4]

Monday 11 February 2019

Programming with C++ Book

Programming with C++ 

The book is intended to provide an introduction to Programming with C++. In keeping with the basic approach of all schaums series books, this book aims to help the students develop their problem solving skills. The plethora of solved examples and practice questions in the book enables the stiudents to get a intutive grasp on the subject.

Programming with C++ 

 Programming with C++

Object-Oriented Programming with C++

Object-Oriented Programming with C++ 

The book aims at providing an all-round enrichment of knowledge in the area of object-oriented programming with C++ as the implementation of language. The author has used simple language to explain critical concepts of object-oriented programming and for better understanding of the readers. The same concepts have been implemented in solved examples using C++ programming language. 
 Object-Oriented Programming with C++

Object-Oriented Programming with C++ 
 
Retaining is original style of lucid writing, the books has ample solved examples, programming exercises and new practice questions. This revised edition has new projects and incorporates a couple of new elements like Learning Objectives and Limitations. The topic on Polymorphism has been revised and expanded for better understanding.
Object-Oriented Programming with C++ 

Learn R in a Day Kindle Edition

Learn R in a Day

'Learn R in a Day' provides the reader with key programming skills through an examples-oriented approach and is ideally suited for academics, scientists, mathematicians and engineers. The book assumes no prior knowledge of computer programming and progressively covers all the essential steps needed to become confident and proficient in using R within a day. 

Learn R in a Day


 Learn R in a Day
Topics include how to input, manipulate, format, iterate (loop), query, perform basic statistics on, and plot data, via a step-by-step technique and demonstrations using in-built datasets which the reader is encouraged to replicate on their computer. Each chapter also includes exercises (with solutions) to practice key skills and empower the reader to build on the essentials gained during this introductory course.
Learn R in a Day  

Saturday 9 February 2019

Deep Learning with Python by Francois Chollet

Deep learning is applicable to a widening range of artificial
intelligence problems, such as image classification, speech recognition,
text classification, question answering, text-to-speech, and optical
character recognition.

Deep Learning with Python is structured around a series of practical
code examples that illustrate each new concept introduced and
demonstrate best practices. By the time you reach the end of this book,
you will have become a Keras expert and will be able to apply deep
learning in your own projects.

KEY FEATURES

• Practical code examples
• In-depth introduction to Keras
• Teaches the difference between Deep Learning and AI

ABOUT THE TECHNOLOGY
Deep learning is the technology behind photo tagging systems at
Facebook and Google, self-driving cars, speech recognition systems on
your smartphone, and much more.

AUTHOR BIO
Francois Chollet is the author of Keras, one of the most widely used
libraries for deep learning in Python. He has been working with deep neural
networks since 2012. Francois is currently doing deep learning research at
Google. He blogs about deep learning at blog.keras.io.

Buy:Deep Learning with Python Paperback – Import, 30 Nov 2017 by Francois Chollet (Author)

Pdf download:Deep Learning with Python

The Quick Python Book by Naomi R Ceder

Buy: The Quick Python Book, 3E Paperback – Import, 31 May 2018 by Naomi R Ceder (Author)

Pdf download: The Quick Python Book, 3E

Numerical Python by Robert Johansson

Numerical Python by Robert Johansson shows you how to leverage the numerical and mathematical modules in Python and its Standard Library as well as popular open source numerical Python packages like NumPy, FiPy, matplotlib and more to numerically compute solutions and mathematically model applications in a number of areas like big data, cloud computing, financial engineering, business management and more. 

After reading and using this book, you'll get some takeaway case study examples of applications that can be found in areas like business management, big data/cloud computing, financial engineering (i.e., options trading investment alternatives), and even games. Up until very recently, Python was mostly regarded as just a web scripting language. Well, computational scientists and engineers have recently discovered the flexibility and power of Python to do more. Big data analytics and cloud computing programmers are seeing Python's immense use. 

Financial engineers are also now employing Python in their work. Python seems to be evolving as a language that can even rival C++, Fortran, and Pascal/Delphi for numerical and mathematical computations.

Pdf Download:


Python Continuous Integration and Delivery: A Concise Guide with Examples by Moritz Lenz

Gain the techniques and tools that enable a smooth and efficient software development process in this quick and practical guide on Python continuous integration (CI) and continuous delivery (CD). Based on example applications, this book introduces various kinds of testing and shows you how to set up automated systems that run these tests, and install applications in different environments in controlled ways. Python Continuous Integration and Delivery tackles the technical problems related to software development that are typically glossed over in pure programming texts.

After reading this book, you’ll see that in today's fast-moving world, no software project can afford to go through development, then an integration phase of unpredictable length and complexity, and finally be shipped to the customer -- just to find out that the resulting application didn't quite fill their need. Instead, you’ll discover that practicing continuous integration and continuous delivery reduces the risks by keeping changes small and automating otherwise painful processes.

What You Will Learn
  • Carry out various kinds of testing, including unit testing and continuous integration testing, of your Python code using Jenkins

  • Build packages and manage repositories

  • Incorporate Ansible and Go for automated packaging and other deployments

  • Manage more complex and robust deployments
Who This Book Is For
Python programmers and operating staff that work with Python applications.

Buy:Python Continuous Integration and Delivery: A Concise Guide with Examples Kindle Edition by Moritz Lenz (Author)

PDF Download:
Python Continuous Integration and Delivery: A Concise Guide with Examples

Wednesday 6 February 2019

R language by Michael J. Crawley


R language by Michael J. Crawley 
 
The R language is recognized as one of the most powerful and flexible statistical software packages and it enables the user to apply many statistical techniques that would be impossible without such software to help implement such large data sets. R is becoming essential both to carry out research and to understand it, as more and more people present their results in the context of R. This edition introduces the advantages of the R environment, in a user-friendly format, to beginners and intermediate users in a range of disciplines, from science and engineering to medicine and economics. The format enables it to be either read as a text, or dipped-into as a reference manual.
 
R language by Michael J. Crawley 

Thursday 31 January 2019

Random forest in R Language

In the random forest approach, a large number of decision trees are created. Every observation is fed into every decision tree. The most common outcome for each observation is used as the final output. A new observation is fed into all the trees and taking a majority vote for each classification model.
An error estimate is made for the cases which were not used while building the tree. That is called an OOB (Out-of-bag) error estimate which is mentioned as a percentage.
The R package "randomForest" is used to create random forests.
Install R Package
Use the below command in R console to install the package. You also have to install the dependent packages if any.
install.packages("randomForest)
The package "randomForest" has the function randomForest() which is used to create and analyze random forests.

SYNTAX
The basic syntax for creating a random forest in R is −
randomForest(formula, data)
Following is the description of the parameters used −
  • formula is a formula describing the predictor and response variables.
  • data is the name of the data set used.

INPUT DATA
We will use the R in-built data set named readingSkills to create a decision tree. It describes the score of someone's readingSkills if we know the variables "age","shoesize","score" and whether the person is a native speaker.
Here is the sample data.
# Load the party package. It will automatically load other required packages.
library(party)

# Print some records from data set readingSkills.
print(head(readingSkills))
When we execute the above code, it produces the following result and chart −
  nativeSpeaker   age   shoeSize      score
1           yes     5   24.83189   32.29385
2           yes     6   25.95238   36.63105
3            no    11   30.42170   49.60593
4           yes     7   28.66450   40.28456
5           yes    11   31.88207   55.46085
6           yes    10   30.07843   52.83124
Loading required package: methods
Loading required package: grid
...............................
...............................

EXAMPLE
We will use the randomForest() function to create the decision tree and see it's graph.
# Load the party package. It will automatically load other required packages.
library(party)
library(randomForest)

# Create the forest.
output.forest <- randomForest(nativeSpeaker ~ age + shoeSize + score, 
           data = readingSkills)

# View the forest results.
print(output.forest) 

# Importance of each predictor.
print(importance(fit,type = 2)) 
When we execute the above code, it produces the following result −
Call:
 randomForest(formula = nativeSpeaker ~ age + shoeSize + score,     
                 data = readingSkills)
               Type of random forest: classification
                     Number of trees: 500
No. of variables tried at each split: 1

        OOB estimate of  error rate: 1%
Confusion matrix:
    no yes class.error
no  99   1        0.01
yes  1  99        0.01
         MeanDecreaseGini
age              13.95406
shoeSize         18.91006
score            56.73051

CONCLUSION
From the random forest shown above we can conclude that the shoesize and score are the important factors deciding if someone is a native speaker or not. Also the model has only 1% error which means we can predict with 99% accuracy.

Saturday 26 January 2019

XPath in Selenium Webdriver


Automation 
involves identifying the elements on the UI and performing actions on them, so in order to identify the UI elements there are various locators available on the HTML DOM  by means of which Selenium WebDriver is able to identify and automate them.
In some cases if these elements are not found using other locators such as Id, Class, Css etc then Xpaths are used.

What is Xpath?

XPath (XML Path Language) is a query language for selecting nodes from an XML document.
Xpath language provides the ability to navigate around XML tree and select the  nodes by various criteria.
Below is an example of XML tree:




In this example Product is the Root Element of the tree and the two child nodes of Product are Name and Detail

Understanding HTML Dom
Whenever a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM is a standard object model and programming interface for HTML. It defines:
The HTML elements as objects
The properties of all HTML elements
The methods to access all HTML elements
The events for all HTML elements

In other words: The HTML DOM is a standard for how to get, change, add, or delete HTML elements.
The HTML DOM is constructed as a tree of objects:


In order to start studying about xpath it is very important to have some basic knowledge about the DOM structure.

Consider the below HTML DOM of facebook signup page.



Let us concentrate on the highlighted portion of the DOM:
Here "input" is a tag and "class,data-type,name,aria-required,placeholder aria-label and id" are known as attributes.Each of these attributes have some values which are used for creating the html page.

When should xpath be used:

Elements on any UI can be located using various html attributes such as ID,Class,name etc,but many a times it happens that:
1. The attributes that are supported by selenium webdriver are not present 
2. The attributes that are available are not unique.

In such cases xpaths can be used to locate the UI elements. Xpaths can easily traverse through the HTML nodes and this feature provides a lot of flexibility to create unique identifiers
.

Basic syntax of xpath:

//tagname[@attribute_name='attribute_value']

Explanation:
//-Selects nodes in the document from the current node that match the selection no matter where they are

@-Selects attribute

Let us look at a simple example below






We have created an xpath for locating first name text box by using the basic syntax-//tagname[@attribute_name='attribute_value']

In the above created xpath input is the tag name,name is the attribute and 'firstname' is the value of the attribute name.

Typing the above xpath in the html dom highlights the HTML element that points to firstname textbox on the UI which assures that the created xpath is a correct one.

 


Popular Posts

Categories

AI (27) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (114) C (77) C# (12) C++ (82) Course (60) Coursera (176) coursewra (1) Cybersecurity (22) data management (11) Data Science (87) Data Strucures (6) Deep Learning (9) Django (6) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (5) flutter (1) FPL (17) Google (19) Hadoop (3) HTML&CSS (46) IBM (25) IoT (1) IS (25) Java (92) Leet Code (4) Machine Learning (44) Meta (18) MICHIGAN (5) microsoft (3) Pandas (3) PHP (20) Projects (29) Python (740) Python Coding Challenge (188) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (40) UX Research (1) web application (8)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses