Python Programming Python Code Samples



Filters


delete files older than n days in a directory using python
kishore_kumar | 4 years, 3 months
import os
import time
base_path = '/home/kishore/my_files'
python os
Ramya
Python: Vending Machine
Ramya | 4 years, 9 months
class SodaMachine:
    def __init__(self,product,price):
        self.product=product
python >>>from <file_name> import <class_name> >>>shop=class_name("product",price) #Instantiate
python
convert and decode base64 string into pdf using python
kishore_kumar | 4 years, 8 months
import base64

b64str = "a29kZXJwbGFjZQ=="
python base64
Example to use a DAG to run a jar file.
Reshma | 4 years, 7 months
from airflow import DAG
from airflow.operators import BashOperator
from datetime import datetime
python airflow jar
Matplotlib pie chart replace auto labelled values with original values
kishore_kumar | 5 years, 5 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
generate random numbers matrix with numpy python
kishore_kumar | 5 years, 7 months
import numpy as np

random_arr = np.random.randint(1,50,9)
python numpy
Ramya
Lambda code for Creating VPC flow log automatically when a VPC is created
Ramya | 5 years
from __future__ import print_function
import json
import os
lambda boto3 aws
List all files and folders using python os module
kishore_kumar | 5 years, 9 months
import os

def list_files_folders(path):
python python-os
use python requests to get contents of url ( get request )
kishore_kumar | 5 years, 7 months
import requests

req = requests.get("https://httpbin.org/get")
python python-requests
create matrix and multiply using numpy in python
kishore_kumar | 5 years, 7 months
import numpy as np

matrix = [[1,2,3], [4,5,6], [7,8,9]]
python numpy
Prev Next