Monday, 1 October 2018

Introduction to Computating & Problem Solving with Python



This book will help every student, teacher and researcher to understand the computing basics and advanced Python Programming language. The Python programming topics include the reserved keywords, identifiers, variables, operators, data types and their operations, flowcontrol techniques which include decision making and looping, modules, files and exception handling techniques. More than 300 solved lab exercises available in this book is tested in Python 3.4.3 version for Windows. The book covers syllabus for more than 35 International Universities and 45 Indian universities. 

Table of Contents 

1: Introduction to computers
2: Program Logic and flow Charts
3: Introduction to Python
4: Data Types and Operations
5: Flow Control
6: Functions
7: Modules and Packages
8: File Handling
9: Object Oriented Programming
10: Exception Handling
11: Regular Expressions
12: Database Programming





About the Author

Jeeva Jose completed Ph. D. in Computer Science from Mahatma Gandhi University, Kerala, India and is a faculty member at BPC College, Kerala. Her passion is teaching and areas of interests include world wide web, Data Mining and Cyber laws. She has been in higher education for the last 15 years and has completed three research projects funded by UGC and KSCSTE. She has published more than twenty research papers in various refereed journals and conference proceedings. She has edited three books and has given many invited talks in various conferences. She is a recipient of ACM-W Scholarship provided by Association for Computing Machinery, New York. P. Sojan Lal was awarded PH. D. from Cochin University of Science and technology, kerala, India. He is Professor, department of computer science and engineering, MBITS, kerala, India and Research supervisor for PH. D. programs of University of petroleum & Energy Studies, Dehardun, India as well as school of computer science, Mahatma Gandhi University, kerala, India. He has 29 Years of academic and industrial experience with 60 publications inclusive of two technical books. His joint publications are recorded with world records India (2014) for most number of papers in several international technical journals within short duration. He has also obtained MBA from starthclyde Business School, Scotland, UK and is a fellow of the Institution of engineers (FIE-India). He was the district Operationg Board member for ASME, Middle east and Africa region. He is a member of ISTE, ASME, IEEE, CSI and engineering Council (UK). He is listed in marquis who's who in the world since 2009 as the biographical reference representing the world's most accomplished individuals.

Core Python Programming by R. Nageswara Rao (Author)



At present, Java occupies number 1 rank as the most used programming language since almost all the projects are developed in Java. Python is already occupying 2nd to 4th position and will be the most demanded language after Java in near future. Python is used with other programming languages on Internet as well as for developing standalone applications. Python programmers are paid high salaries in the software development industry. Hence, it is time for beginners as well as existing programmers to focus their attention on Python.

.








Introduction_Command line_Data editor_Rstudio in R languages

Command Line versus Scripts



Execution of commands in R is not menu driven. (Not like Clicking over buttons to get outcome)

we need to type the commands.

Single line and multi line commands are possible to write.

When writing multi-line programs, it is useful to use a text editor rather than execute everything directly at the command line.

Option 1:
  • One way use R's own built-in editor.
  • It is accessible from the RGui menu bar.
  • Click File and then click on New script
 
At this point R will open a window entitled Untitled-R Editor.

We may type and edit in this.

It we want to execute a line or a group of lines, just highlight them and press Ctrl+R.


Option 2:

Use R studio software


Suppose we want to use following three functions:

Type them.
library (MASS)
attach (bacteria)
fix (bacteria)

Suppose we want to run only function: library (MASS)

Highlight it and click on Run.



Data Editor
  • There is a data editor within R that can be accessed from the menu bar by selecting Edit/Data editor.
  • Provide the name of the matrix or data frame that we want to edit and a Data Editor window appears.
  • Alternatively we can do this from the command line using the fix function. 
Example:
  library (MASS)
  attach (bacteria)
  fix (bacteria)


We can do it in R Studio as follows :




Cleaning up the Windows
  • We assign names to variables when analyzing any data.
  • It is good practice to remove the variable names give to any data frame at the end each session in R.
  • This way, variable with same names but different properties will not get in each others way in subsequent work.
  • rm ( ) command removes variable name
  • For example,
           rm (x, y, z) removes the variable x, y and z.
  • detach ( ) command detaches objects from the Search Path.
  • It removes it from the search ( ) path of available R objects.
  • Usually this is either a data.frame which has been attached or a package which was attached by library.
  • To get rid of everything, including data frames, type rm (list=1s( )  ).

Saturday, 29 September 2018

Array, Strings and Functions in R Languages

Array 
  • Used to store ordered list of values of same type.
We will see how to:
  • Create Array
  • Access Array
  • Modify Array





Functions :-
  •  Function is a set of statements combined together perform a specific Task.
  • Syntax:
                 functionName <- function(Arguments_optional)
                   {
                       //Statemnts.
                      }
  • We will see how to:
                 - Create a Function
                 - Call a Function




String :-  
  •  Values written inside single or double quotes are called strings. E.g. "Hello" , 'hello'
  • Quotes can't be mixed, if a string has double quote in beginning ending quotes should be same as well.
  • Example of  Valid strings and invalid strings.
  • "Hey", 'Hey', "Teacher's", 'Name" is' are valid strings.
  • 'Hey", "Hello" there", 'hey"there', are invalid strings.
  • We will see how to:
             - Create and manipulate strings using predefined functions.

Tuesday, 25 September 2018

Importing Data Files from Other Software in R Language

Importing Data Files

Spreadsheet (Excel) file data

The xlsx package has the function read.xlsx ( ) for reading Excel files.

This will read the first sheet of an Excel spreadsheet.

To read Excel files, we first need to install the package

install.packages ("xlsx")
library (xlsx)
data  <-  read.xlsx ("datafile.xlsx", sheet Index or sheet Name)

 To load other sheets with read.xlsx( ), we specify a number for sheetIndex or a name for sheetName:

data  <- read.xlsx("datafile.xlsx", sheetIndex=2)

data  <-  read.xlsx("datafile.xlsx",sheetName="marks")

For reeading older Excel files in .xls format, use gdata package and function read.xls ( )

This will read the first sheet of an Excel spreadsheet.
To read Excel files, we first need to install the package

install.packages ("gdata")
library (gdata)
data  <- read.xls ("datafile.xls", sheet Index or sheet Name) )  

SPSS data file

For reading SPSs data files, use foreign package and function read.spss ( )

To read SPSs files, we first need to install the package

install.packages ("foreign")
library (foreign)
data  <-  read.spss ("datafile.sav") 


Other data files

The foreign package also includes functions to load other formats, including:
  • read.octave ("<Path to file>") : Octave and MATLAB
  • read.systat ("<Path to file>") : SYSTAT
  • read.xport ("<Path to file>") " SAS XPORT
  • read.data ("<Path to file>") : Stata
  
Contents of working directory

The list.files function shows the contents of your working directory:
> list.files ( )   // List of all available files in the working directory.

> setwd  ("C:/RCourse/")
> list.files ( )

 Redirecting Output to a File

Issue:
We want to redirect the output from R into a file instead of your console.

Solution:
Redirect the output of the cat function by using its file argument:

> ans  <-  6 + 8
> cat ("The answer of 6 + 8 is", ans, "\n", file="filename")

The Output will be saved in the working directory with given filename. 

Use the sink function to redirect all the output from both print and cat.

Call sink with a filename argument to begin redirecting console output to that file.

When we are done, sink with no argument to close the file and resume output to the console.

> sink ("filename")  #Beign writing output to file 
.....other session work .....
> sink

The print and cat functions normally write the output to console.

The cat function redirects the output to a file if we supply a file argument.

The print function cannot redirect its output.

The sink function can force all output to a file. 


Redirecting Output to a File: Three steps

1. 
> sink ("output.txt")  # Redirect output to file

2.
 > source ("script.R")  # Run the script, capture its output

3.
> sink ( )   # Resume writing output to console

Other options like append=TRUE/FALSE,  split=TRUE/FALSE are available. 

Example :-

 

Java Basics for Android

  • Originated in late 1995, released to public in 1996 (called Oak)
  • Nine major release since the beginning
  • Current version is SDK 8.
  • More than a programming language, it is a execution platform
            - Java Virtual Machine (JVM)

Evaluation of Java Language



Java Features

As released in the "White Paper" by the authors of Java
  1. Simple
  2. Object-Oriented
  3. Distributed
  4. Robust
  5. Secure
  6. Architecture-Neutral
  7. Portable
  8. Interpreted
  9. High-Performance
  10. Multithreaded
  11. Dynamic

JVM (Java Virtual Machine)
  • "Compile once run any where"
  • Java bytecodes
           Java Program                             Java bytecodes
                                    Java Compiler
                                                             →
         Java bytecodes                               Execution
                                      JRE
                                                           →


Execution Path
  • Windows
            - Environment variables
  • Linux
           edit ~ ./bashrc or ~./ cshrs ...
                - set path
                - export PATH
  • To test your settings
            - java - version

Java Naming Conventions

           Java is case-sensitive:
              HelloWorld             ≠           Helloworld



Java Interfaces

Set of requirements
      Describes what a class should do
             E.g. Comparable interface
                 public interface Comparable{
                        int compare To (Object other)
                 }
  • All methods are automatically public
  • All fields are public and static
  • No instance fields
  • No implementation of methods
         - Classes implement the interface
  • Can not instantiate an interface
         - Can declare interface variable
         - Instance of to check

Interfaces & Abstract Classes
  • A class can extend only a single class
  • A class can implement as many interfaces as it likes
          - Provides similar functionality as C++ multiple inheritance.

Monday, 24 September 2018

Data Reshaping in R Language

Data reshaping means changing how data is represented in rows and column.

 Most of Data Processing in R is done on Data Frames.

 R has many functions that deal with Reshaping of Data, by splitting, meaning or interchanging the Rows and columns.Some 

Data reshaping functions are:
            

             - cbind( )
             - rbind( )
             - merge( ), etc.


Another Data Frames :-



Sunday, 23 September 2018

Introduction to Android

Android

  • Android is an Operating System Mainly for smartphones.
  • But now you can find Android in your Tab, Television, TV Set top Box, Watches and even in your Car.
  • Android is a rich application Framework that allows you to develop innovative apps and Games for your Mobile devices.
  • Java is the  official development language for android, but in Google I/O 2017 Google introduce another language Kotlin as an Official language.
  • Now we have two programming languages for Android development, Java & Kotlin.
  • In this blog We are going to use Java for the App development.
  • Android is developed by Open Handset Alliance led by Google
  • Android uses Linux as its Kernel.
  • Android is open source Operating System.
  • Anyone can be an App developer and the tools needed for the App development is freely available on the web.
  • Android uses a special virtual machine for run your apps called Dalvik virtual machine.
  • You can develop Android apps and make it available for users through Google Play Store.
  • You can earn money from your apps through in App purchases and by placing Ads on your App.
  • Every year Google Release a New version of Android.
  • This Android series use a (Version 8.0, API Level 26)
Android Stack





Saturday, 22 September 2018

Introduction to Angular JS

This is developed in 2009 by Misko and Adam Abrons.
It is a Open Source and completely free.
It is a Licensed under Apache and maintained by Google.
This is very powerful JavaScript Framework.
  • A client side JS framework.
  • Developed and being maintained by Google
  • Goals
             - Separate DOM manipulation from application logic
             - Separation of concerns (using MVC like pattern)
             - Make SPA development easier
             - Provide solid foundation for robust/enterprise-scale JS client-side applications
             - Extensibility & Customization
  • Steps to make available and test Angular JS on a web page:
             - Download/refer "angular-version-x.js" on your page
             - Define an angular module using "angular.module"
             - Decorate an element using "ng-app" and attach to the module.
             - Use an angular expression to test angular js

Angular's History
  • 2010  -  Angular JS
  • 2016  - Angular Version 2
  • 2016  Dec - Angular Version 4
  • 2017 Nov  - Angular Version 5

Features of Angular JS
  • Used to create RIA
  • Helps to write application using MVC architecture
  • Application in Angular JS is cross-browser compliant.
  •  Automatically handles JavaScript code as per browser.

Monday, 17 September 2018

Data management: Sequence in R Language

Sequences

A sequence is a set of related numbers, events, movements, or items that follow each other in a particular order.

The regular sequences can be generate in R.

Syntax :-
seq ( )

seq (from = 1, to = 1, by = ( ( to from) / (length.out - 1) ), length.out = NULL, along.with = NULL, ...)

Help for seq

> help ("seq")

The default increment is +1 or -1

> seq (from = 2, to = 4)
     [1]  2  3  4

> seq (from = 4, to = 2)
    [1]  4  3  2

>seq (from = -4, to = 4)
   [1]  -4  -3  -2  -1  0  1  2  3  4

 
 Sequence with constant increment:


  Generate a sequence from 10 to 20 with an increment of 2 units

> seq (from = 10, to = 20 , by = 2)
   [1]  10  12  14  16  18  20


Generate a sequence from 20 to 10 with a decrement of 2 units

> seq (from = 20, to = 10, by = -2)
  [1]  20  18  16  14  12  10



Downstream sequence with constant increment:

Generate a sequence from 3 to -2 with a decrement of 0.5 units

> seq (from = 3, to = -2, by = -0.5)
  [1]  3.0  2.5  2.0  1.5  1.0  0.5  0.0  -0.5  -1.0  -1.5  -2



Sequence with a predefined length with default increment +1

> seq (to = 10, length = 10)
  [1]  1  2 3 4  5  6  7  8  9  10



Sequence with predefined length with constant fractional increment.

> seq (from = 10, length = 10, by = 0.1)
  [1]  10.0  10.1  10.2  10.3  10.4  10.5  10.6  10.7  10.8  10.9




Sequence with a predefined length with constant decrement

> seq (from = 10, length = 10, by = -2)
  [1]  10  8  6  4  2  0  -2  -4  -6  -8



Sequences with a predefined length with constant fractional decrement

> seq (from = 10, length = 5, by = -.2)
  [1]  10.0  9.8  9.6  9.4  9.2



Sequence with a predefined variable and constant increment

> x <-2
> seq (1, x, x/10)
  [1]  1.0  1.2  1.4  1.6  1.8  2.0

> x<-50
> seq (0, x, x/10)
  [1]  0  5  10  15  20  25  30  35  40  45  50




Saturday, 15 September 2018

Basic calculations: Truth table and conditional executions

Example of standard logical operations

Truth table


 
> x = TRUE
> y = FALSE

> x & y       # x AND y
[1]   FALSE

> x | y        # x OR y 
 [1]  TRUE

> !x          # negation of x
 [1] FALSE 


Example

> x <- 5
> Logical1  <- (x > 2)
> is.logical (Logical1)
 [1] TRUE

> Logical2 <- (x < 10)
> is.logical (Logical2)
 [1] TRUE

Example

> x <- 5
> Logical3 <-  (2*x > 11)
> is.logical (Logical3)
[1] TRUE

> Logical4  <-  (3*x <20)
> is.logical (Logical4)
 [1] TRUE


Control structures in R :

control statements,
loops,
function
Conditional execution

1. Conditional execution

Syntax

if (condition) {executes commands if condition is TRUE}
if (condition) {executes commands if condition is TRUE}

else {executes commands if condition is FALSE}

please note: 
  • The condition in this control statement may not be vector valued and if so, only the first element of the vector is used.
  • The condition may be complex expression where the logical operators "and" (&&) and "or" (| |) can be used.
Example

> x <- 5
> if ( x == 3)  { x <- x-1} else { x <- 2*x}
Interpretation:
  • If x = 3, then execute  x = x - 1.
  • If x ≠ 3, then execute x = 2*x.
In this case, x = 5 so x ≠ 3. Thus x = 2*5.

> x
 [1]  10

Now choose x = 3 and repeat this example


Friday, 14 September 2018

Basic calculations: Logical operators in R Languages

Logical Operators and Comparisons

The following table shows the operations and functions for logical comparisons (True or False).




Examples :

> x = 1 : 6       # Generates x=1,2,3,4,5,6
> (x > 2) & (x < 5)  # Checks whether the values are greater than 2 and less than 5

[1]  FALSE  FALSE  TRUE  TRUE  FALSE  FALSE

> x [(x > 2) & (x < 5)]  # Finds which values are greater than 2 and smaller than 5.
[1]   3  4



Logical Operators and Comparisons 



  • The shoter form performs element-wise comparisons in almost the same way as arithmetic operators.
  • The longer from evaluates left to right examining only the first element of each vector. Evaluation proceeds only until the result is determined.
Example of   " The longer form evaluates left to right examining only the first element of each vector"
> x = 1 : 6           # Generates x = 1,2,3,4,5,6

> (x > 2)  && (x < 5) 
 [1]  FALSE

is equivalent to:

> (x[1] > 2) & (x[1] < 5)
  [1]  FALSE


Note that x[1] is only the first element in x.

> x[ (x > 2) && (x < 5) ] 
   integer(0)                # Finds which values are greater than 2 and smaller than 5
This statement is equivalent to 

> x [ (x[1] > 2) & (x[1] < 5) ]
integer (0)


Popular Posts

Categories

100 Python Programs for Beginner (49) AI (34) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (173) C (77) C# (12) C++ (82) Course (67) Coursera (226) Cybersecurity (24) data management (11) Data Science (128) Data Strucures (8) Deep Learning (20) Django (14) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Google (34) Hadoop (3) HTML&CSS (47) IBM (25) IoT (1) IS (25) Java (93) Leet Code (4) Machine Learning (59) Meta (22) MICHIGAN (5) microsoft (4) Nvidia (3) Pandas (4) PHP (20) Projects (29) Python (929) Python Coding Challenge (353) Python Quiz (22) Python Tips (2) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (3) Software (17) SQL (42) UX Research (1) web application (8) Web development (2) web scraping (2)

Followers

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