Data Structures and Algorithms Implementation in Python:

Found an interesting Python’s third party module for implementing Data Structures and Algorithms in Python.

But it may not apt for real time production.

Get the module from below location

https://pypi.python.org/pypi/algorithms/1.0

Get the Usage documentation from the below link

http://algorithms.readthedocs.io/en/latest/

Advertisements

API Testing with Python (Requests Module).

What is API Testing?

API testing is a type of software testing which involves testing application programming interface or software resource as part of product integration testing to determine if they meet expectations or functionality, reliability, performance, and security.

What are types of API?

Simple Object Access Protocol (SOAP)

Remote Procedure Call (RPC)

Representational State Transfer (REST)

Out of above three, last one has become now industry standard API implementation with many feature ready standards and also it has support for many programming languages.

Python Request Module for testing API

Request is a Python Module for testing application programming interface with features of get , post, put and delete.

The Requests module is a an elegant and simple HTTP library for Python.

Simple Example:-

Make a Request

import requests

r = requests. get (‘https://api.github.com/events’)

r = requests.post (‘https: //httpbin.org/post’, data = {‘key’:’value’})

r = requests. put (‘https://httpbin.org/put’, data = {‘key’:’value’})

r = requests. delete (‘https://httpbin.org/delete’)

r = requests. head (‘https://httpbin.org/get’)

r = requests. options (‘https://httpbin.org/get’)

r = requests. options (‘https://httpbin.org/get’)

Passing Parameters in URL:

payload ={‘key1’:’value1’,’key2’:’value2’}

r = requests. get (‘https://api.github.com/events’, params=payload)

Response Content:

r = requests. get (‘https://api.github.com/events’)

r.text

[{u’repository’: {u’open_issues’: 0, u’url’: ‘https://github.com…..

r.encoding

utf-8

r.encoding = ‘ISO-8859-1’

JSON Response Content:

r = requests. get (‘https://api.github.com/events’)

r.json()

[{u’repository’: {u’open_issues’: 0, u’url’: ‘https://github.com…..

For Complete Requests Module  Reference, Check the below links.

http://docs.python-requests.org/en/master/

https://pypi.python.org/pypi/requests

Why Python is getting popularity (famous) ??

Introduction About Python:

Have you ever come across word the Python anywhere? If no, let me brief you about “Python”. Python is an interpreted, object oriented and high level programming language more over it has built in data structures which makes it attractive for rapid application development as well suitable for scripting language. The applications of python languages are wider it used to create GUI based desktop applications, web applications , business applications and Automation.

Advantages of Python:

Python has numerous third party modules which make it capable for interacting with other language and platform

Python is open source software which makes it free to use and distribute

Python provides excellent readability which helps beginners to learn the language fastly

Python offers user friendly data structures

Python increases the speed of application development

According to survey Python is popularly used programming language for data scientist across the globe. It is second widely used programming language next to java more over most of the IT companies have adopted Python as their programming language and number companies using Python are increasing rapidly which would create large job opportunities.

Language Ratings:

http://www.inc.com/larry-kim/10-most-popular-programming-languages-today.html

https://www.tiobe.com/tiobe-index/

http://blog.hackerearth.com/2016/11/top-programming-language-2017.html

https://fossbytes.com/best-popular-programming-languages-2017/

Link to original source:

http://besanttec.blogspot.in/2017/03/why-is-python-so-famous.html

Some Interesting Web Sites for enthusiast Programmers!!

1 )  www.hackerearth.com   – Code Practice , Solve the Puzzles and get hired.

2 ) www.codechef.com   – Code Practice , Win The Challenges , Solve the Puzzles, and get hired.

3 ) www.geeksforgeeks.org  – Learn The DS (Data Structures) and Algorithms, Learn the Programming Languages , Practice The code, Participate the  Quiz’s, And get the Interview Experience.

Set Python Environment Variable in Windows.

Some times after installing Python, you  may face issue like.

‘Python’ is not recognised as internal or external command,

img1

Solve the issue by fallowing below step by step procedure on the windows.

1 ) Right click on My Computer  open the option Properties.then you will find advanced system settings option then click on it.

img2

2) After clicking advanced setting link will find new tab with Environment variables tab click on it.

img3 img4

3) Copy the Python installation path, default path would be (C:\Python27).Then click the edit button of user variable settings and paste the path here.and repeat same for system variable also.

img5 img6

4) Then put the OK and come out from screens open fresh command prompt then try python installation.

img7

Note:

This is not for all the cases i.e ideally path should be set automatically . some times due to our system settings it wan’t happen then without any doubts apply the above steps and come out form the issue and do actual work .

A Simple Calculator App By Using Tkinter (Python GUI Module) :

from Tkinter import *

root = Tk()
root.title(“Calculator”)
#So that it becomes of fixed size
root.resizable(0, 0)
#So that it remains on top of the screen
root.wm_attributes(“-topmost”, 1)

#Label
Label1 = Label(root, text = “Calculator app”)
Label1.grid(row=0, columnspan=8)

#Variables
equa = “”
equation = StringVar()

calculation = Label(root, textvariable = equation)

equation.set(“Enter your expression : “)

calculation.grid(row=2, columnspan=8)

def btnPress(num):
global equa
equa = equa + str(num)
equation.set(equa)

def EqualPress():
global equa
total = str(eval(equa))
equation.set(total)
equa = “”

def ClearPress():
global equa
equa = “”
equation.set(“”)

Button0 = Button(root, text=”0″, command = lambda:btnPress(0), borderwidth=1, relief=SOLID)
Button0.grid(row = 6, column = 2, padx=10, pady=10)
Button1 = Button(root, text=”1″, command = lambda:btnPress(1), borderwidth=1, relief=SOLID)
Button1.grid(row = 3, column = 1, padx=10, pady=10)
Button2 = Button(root, text=”2″, command = lambda:btnPress(2), borderwidth=1, relief=SOLID)
Button2.grid(row = 3, column = 2, padx=10, pady=10)
Button3 = Button(root, text=”3″, command = lambda:btnPress(3), borderwidth=1, relief=SOLID)
Button3.grid(row = 3, column = 3, padx=10, pady=10)
Button4 = Button(root, text=”4″, command = lambda:btnPress(4), borderwidth=1, relief=SOLID)
Button4.grid(row = 4, column = 1, padx=10, pady=10)
Button5 = Button(root, text=”5″, command = lambda:btnPress(5), borderwidth=1, relief=SOLID)
Button5.grid(row = 4, column = 2, padx=10, pady=10)
Button6 = Button(root, text=”6″, command = lambda:btnPress(6), borderwidth=1, relief=SOLID)
Button6.grid(row = 4, column = 3, padx=10, pady=10)
Button7 = Button(root, text=”7″, command = lambda:btnPress(7), borderwidth=1, relief=SOLID)
Button7.grid(row = 5, column = 1, padx=10, pady=10)
Button8 = Button(root, text=”8″, command = lambda:btnPress(8), borderwidth=1, relief=SOLID)
Button8.grid(row = 5, column = 2, padx=10, pady=10)
Button9 = Button(root, text=”9″, command = lambda:btnPress(9), borderwidth=1, relief=SOLID)
Button9.grid(row = 5, column = 3, padx=10, pady=10)
Plus = Button(root, text=”+”, command = lambda:btnPress(“+”), borderwidth=1, relief=SOLID)
Plus.grid(row = 3, column = 4, padx=10, pady=10)
Minus = Button(root, text=”-“, command = lambda:btnPress(“-“), borderwidth=1, relief=SOLID)
Minus.grid(row = 4, column = 4, padx=10, pady=10)
Multiply = Button(root, text=”“, command = lambda:btnPress(““), borderwidth=1, relief=SOLID)
Multiply.grid(row = 5, column = 4, padx=10, pady=10)
Divide = Button(root, text=”/”, command = lambda:btnPress(“/”), borderwidth=1, relief=SOLID)
Divide.grid(row = 6, column = 4, padx=10, pady=10)
Equal = Button(root, text=”=”, command = EqualPress, borderwidth=1, relief=SOLID)
Equal.grid(row=6, column=3, padx=10, pady=10)
Clear = Button(root, text=”C”, command = ClearPress, borderwidth=1, relief=SOLID)
Clear.grid(row = 6, column = 1, padx=10, pady=10)

root.mainloop()

 

Note:

Tkinter module comes with Python as no need to install by using third party tool,

if not fallow the below link for installing on respected platforms.

http://www.tkdocs.com/tutorial/install.html

Source link

http://codeshot.in/pythongui/calculator.php