Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Monday, 12 August 2019

Hands on Bokeh : Python Toast



Bokeh  library helps in interactive visualization, that targets web browsers for representation.

We are going to cover three vital aspects in plotting a simple visualization

1.  figure: Set labels of the plot using this function 
2.  show: use this to show the plot
3.  output_html: Function to select the output as target example sample.html


In action code:

#import 
from bokeh.plotting import show,figure,output_file

#Target file for plotting
output_file('First_sample.html')

#set x axis and y axis lable inside 
p=figure(x_axis_label='City',y_axis_label='Temperature in Celsius')

#draw a circle plot with color red and size 20 of each dot
p.circle([1,2,3,4,5],[10,7,15,12,2],color='Red',size=20,name='city')

# show the plot
show(p)


output:



Saturday, 10 November 2018

TDD with Python

Example to Demonstrate Test driven development using Python




#write a unite test to tst the method
"""doc sting
"""
import unittest

def simple_intrest(principle, rate, time):
    """this function compute simple interest
    """
    return (principle*rate*time)/100
def amount(principle, rate, time):
    """this function compute the amount on
    i.e  simple interest + principle
    """
    return principle+simple_intrest(principle, rate, time)
class TestBanking(unittest.TestCase):
    """ the is the test class
    """
    def test_simple_intrest(self):
        """ test simple intrest
        """
        self.assertEqual(simple_intrest(1000, 8, 1), 80)
        self.assertEqual(simple_intrest(100, 8, 1), 8)
        self.assertEqual(simple_intrest(-100, 8, 1), -8)
    def test_amount(self):
        """ test amount
        """
        self.assertEqual(amount(100, 8, 1), 108)
        self.assertEqual(amount(10, 8, 1), 10.8)

RUN_TEST = TestBanking()
#call test simple intrest function
RUN_TEST.test_simple_intrest()
#call test amount function
RUN_TEST.test_amount()

Apache Beam Learning In Java Tutorials

 Wow  https://youtu.be/9kGETU63rkc