Showing posts with label tisacademy. Show all posts
Showing posts with label tisacademy. Show all posts

Tuesday, 28 February 2017

Top Interview Questions and Answers for Python


1) What is Python?
Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is designed to be highly readable which uses English keywords frequently where as other languages use punctuation, and it has fewer syntactical constructions than other languages.
2) Mention five benefits of using Python?
·          Python comprises of a huge standard library for most Internet platforms like Email, HTML, etc.
·          Python does not require explicit memory management as the interpreter itself allocates the memory to new variables and free them automatically
·          Provide easy readability due to use of square brackets
·          Easy-to-learn for beginners
·          Having the built-in data types saves programming time and effort from declaring variables

3) What is pickling and unpickling?
Pickle module accepts any Python object and converts it into a string representation and dumps it into a file by using dump function is called pickling.  While the process of retrieving original Python objects from the stored string representation is called unpickling.

Friday, 3 February 2017

Python Database Access

Python Database Access

The Python standard for database interfaces is the Python DB-API. Most Python database interfaces adhere to this standard. Python Database API supports a wide range of database servers such as −
·        GadFly
·        MySQL
·        MySQL
·        PostgreSQL
·        Microsoft SQL Server 2000
·        Informix
·        Interbase
·        Oracle
·        Sybase
The DB API provides a minimal standard for working with databases using Python structures and syntax wherever possible. The MySQLdb module explains all concepts using MySQL. This API includes the following:
·        Importing the API module.
·        Acquiring a connection with the database.
·        Issuing SQL statements and stored procedures.
·        Closing the connection.
What is MySQL db?
MySQLdb is an interface for connecting to a MySQL database server from Python which implements the Python Database API v2.0 and it is built on the top of the MySQL C API.
How do I Install MySQLdb?
Before proceeding, make sure the MySQLdb is installed on the machine. Just type the following in Python script and execute it:
#!/usr/bin/python
Import MySQLdb
If it produces the below result, it means MySQLdb module is not installed:
           Traceback (most recent call last):
                       Import MySQLdb
           ImportError: No module named MySQLdb
Database Connection
Before connecting to the MySQL database, check the followings −
·        Create a database TESTDB.
·        Create a table EMPLOYEE in TESTDB.
·        This table has fields such as FIRST_NAME, LAST_NAME, AGE, SEX and INCOME.
·        User ID "testuser" and password "test123" are set to access TESTDB.
·        Python module MySQLdb is installed properly on the machine.
While running this script, the below result would be produced.
           Database version: 5.0.45
Creating Database Table
Once a database connection is established, we are ready to create tables or records into the database tables using execute method of the created cursor.
INSERT Operation
It is required when we want to create the records into a database table.
READ Operation
Fetch some useful information from the database. Once our database connection is established and then makes a query into this database.
·        fetchone() -  Fetches the next row of a query result set. A result set is an object that is returned when a cursor object is used to query a table.
·        fetchall() - Fetches all the rows in a result set. If some rows have already been extracted from the result set, then it retrieves the remaining rows from the result set.
·        Rowcount -  This is a read-only attribute, returns the number of rows that were affected by an execute() method.
Update Operation
Used to update one or more records that are already available in the database.
DELETE Operation
Used to delete some records from the database.
Performing Transactions
It is a mechanism that ensures data consistency having the following properties:
·        Atomicity - Either a transaction completes or nothing happens at all.
·        Consistency - A transaction must start in a consistent state and leave in a consistent state.
·        Isolation - Intermediate results of a transaction are not visible outside the current transaction.
·        Durability - Once a transaction was committed, the effects are persistent, even after a system failure.
The Python DB API 2.0 provides two methods to either commit or rollback a transaction.
COMMIT Operation
It gives a green signal to database to finalize the changes, and after this operation, no change can be reverted back.
ROLLBACK Operation
Revert back the changes completely by using use rollback() method.
Disconnecting Database
By using the close() method to disconnect the Database connection.
Handling Errors
There are many sources of errors. The DB API defines a number of errors that must exist in each database module. The exceptions are mentioned below.
·        Warning – Used for non-fatal issues.
·        Error – Base class for errors.
·        Interface Error – Used for errors in the database module not for the database itself.
·        Database Error – Used for errors in database.
·        Data Error – Subclass of database error which refers the errors in the data.
·        Operational Error – Refers the loss of connection to the database that are outside of control of the python scripter.
·        Integrity Error – Damage the relational integrity such as uniqueness constraints or foreign keys.
·        Internal Error – Refers to the errors internal to the database module.
·        Programming Error - Refers to the errors such as bad table name.
·        Not Supported Error – Refers that trying to call unsupported functionality.


Friday, 27 January 2017

Python Keywords and Identifiers

Keywords in Python

Keywords in python are the reserved words that cannot be used as variable name or function name or ordinary identifiers; they must be spelled exactly as they are written.

Explanation of Keywords

print – Used to print to console.

while – Used for controlling the flow of the program.

for – Used to iterate over times of a collection in order that they present.

break – Used to interrupt the loop or cycle when they are needed.

continue – Used to interrupt the current cycle without jumping out of the whole cycle.

if – Used to determine which statements are to be executed.

elif – This stands for else if. In this the first test evaluates to false then it continues with the next one.

else – It is an optional one, the else keyword is executed, unless the condition is true.

is – Used for testing the object identity.

not – This is used to negates the Boolean value.

and -  By using this all conditions in the Boolean expressions are met.

or – By using this atleast one condition must meet.

import – With this import the other python modules into a python script.

as – By using this give module in different alias.

from -  Used for importing a specific variable, class or a function from a module.

def – Used for creating an new user defined function.

return – Used for exits the function and returns a value.

lambda – Used to create a new anonymous function.

global – Used to define the outside functions and access the variables.

try – With the help of this find the exception handlers.

expect – Used for executing the code and then catches the exception.

finally – With this clean up resources and its always executed at the end.

raise – Used to create an user defined exception.

del – Used to delete objects.

pass – It does nothing.

assert – Its used for the debugging process.

class – This is used for creating the new user defined objects. 

exec – Used for executing the python code dynamically.

yield – This is used along with the generators.  

Python Identifiers

Identifier is the name given to the entities like class, functions, variables etc. which helps differentiating one entity from another.

Rules for Writing Identifiers

1) Identifiers is a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore (_). Names like myClass, var_1 and print_this_to_screen, are valid examples.

2)An identifier cannot start with a digit.1variable is invalid, but variable is perfectly fine.

3)Keywords cannot be used as identifiers.

>>>global = 1
File “<interactive input>”, line 1
global = 1
^

Syntax Error: invalid syntax

4)Does not use special symbols like !, @, #, $, % etc. in our identifier.

>>> a@ = $
File “<interactive input>”, line 1
a@ = $
^

Syntax Error: invalid syntax

5)Identifier can be of any length.


Saturday, 24 December 2016

SEO Training


What is Search Engine Optimization?
SEO is the process of getting traffic from free, organic, editorial or natural search results on the search engine. It is a marketing discipline focused on growing visibility in organic (non-paid) search engine results and encompasses on both the technical and creative elements required to improve rankings, drive traffic, and increase awareness in search engines.
SEO Tools
Online Reputation Management Audit Tool - Depends on reviews which search for the business in all of the major review sites at the same time and also get a comprehensive report detailing the online reputation stats.

Free Alternative to Google Keyword Planner - Best Alternative to Google Keyword Planner and other Keyword Research Tools.

Keyword Density Checker - This tool will crawl the specified URL, extract text as a search engine, remove common stop words and displays the density of the keywords.

Free Keyword Ranking Tool - Our free website ranking and keyword research tool allows uncovering high volume keywords to boost SERP’s.ss

Similar Page Checker Tool - Determine the percentage of similarity between two pages. Search engines are known to penalize websites that containduplicate or similar content.

Search Engine Spider Simulator - Simulates a search engine crawler by displaying the contents of a webpage exactly how a search engine would see it. It also displays the links that a search engine would follow when it visits the webpage.

Backlink Anchor Text Analysis - Determine the link text used by the backlinks to link to the website.

Backlink Builder Tool – Helps to build a lot of quality backlinks and searches for websites to specify keyphrases like Add link, Add site, Add URL, Add URL, Submit URL and so on.

Backlink Summary Tool - Gives the summary of competitor’s backlinks.

Redirect Check Tool - Looks at a number of different URLs for the homepage, and reports back on the response code given by each.

Link Price Calculator Tool – Help to provide SEO Services by determining the appropriate amount you should be paying (or charging) per month for a text link (ad) on the specified URL.

Reciprocal Link Check Tool - Ensure the link partners that are linking back to the website and determines the anchor text used by the link partners to link the website.

Cloaking Checker Tool - Detect whether a website is cloaking for search engines.

Domain Age Tool - Displays the approximate age of a website on the Internet and allows viewing how the website looked when it first started and also to find out the age of your competitor’s domains.

Keyword Suggestions Tool - Determine relevant and popular keywords related to the website.

Website Keyword Suggestions ToolDetermine the theme of the website and provides keyword suggestions along with keyword traffic estimates.

URL Rewriting Tool - Convert dynamic URLs into static looking HTML URLs.

Keyword-Rich Domain Suggestion Tool – It is an important factor for Search Engine Optimization and suggests keyword rich domain names.

Alexa Rank Checker - This tool is used to get Alexa traffic rankings of you and your competitors.

SEO Training in Chennai