Python Code Samples



Filters


Matplotlib pie chart replace auto labelled values with original values
kishore_kumar | 6 years, 9 months
import matplotlib.pyplot as plt

labels = 'Grapes', 'Oranges', 'Mangoes', 'Apples'
*autopct*: [ *None* | format string | format function ] If not *None*, is a string or function
python matplotlib
template filters for slice string and print new lines in Django filters
kishore_kumar | 6 years, 1 month
<!-- will give first 100 characters from my_string -->
{{ my_string | slice:"100 "}}

html python django
create matrix and multiply using numpy in python
kishore_kumar | 6 years, 12 months
import numpy as np

matrix = [[1,2,3], [4,5,6], [7,8,9]]
python numpy
gaya38
Python program for the largest number in an array
gaya38 | 7 years
a = [1,43,98,5]#Dummy data
for l in range(len(a)-1):
        if (a[l]>a[l+1]):
python
how to iterate or get values in python dictionaries
kishore_kumar | 6 years, 12 months
sample_dict = { "number": 1, "fruits": ["apple", "mango", "banana"], "name": "kishore"}

for key i
python
gaya38
Generate Random number within the range in python
gaya38 | 7 years
import random
print random.uniform(10,500)
python
Connect to MySQL database with python mysql connector
kishore_kumar | 6 years, 5 months
# pip install mysql-connector

from mysql import connector
python mysql mysql-connector
Ramya
Deleting Amazon EBS snapshots older than n days based on tags
Ramya | 6 years, 5 months
import sys
import boto3
import datetime
python aws boto3
Run SQL update statement using python pyodbc
kishore_kumar | 5 years, 8 months
import pyodbc

conn = pyodbc.connect('Driver={SQL Server};'
pyodbc python
Get os details using python os
kishore_kumar | 7 years, 2 months
import os
print os.uname()
# Don't use os.system('uname -a'), its just executing "uname -a" comman
python python-os
Prev Next