Python Code Samples



Filters


delete files older than n days in a directory using python
kishore_kumar | 4 years, 2 months
import os
import time
base_path = '/home/kishore/my_files'
python os
Ramya
Python: Vending Machine
Ramya | 4 years, 8 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, 7 months
import base64

b64str = "a29kZXJwbGFjZQ=="
python base64
generate random numbers matrix with numpy python
kishore_kumar | 5 years, 6 months
import numpy as np

random_arr = np.random.randint(1,50,9)
python numpy
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, 6 months
import requests

req = requests.get("https://httpbin.org/get")
python python-requests
Run SQL update statement using python pyodbc
kishore_kumar | 4 years, 2 months
import pyodbc

conn = pyodbc.connect('Driver={SQL Server};'
pyodbc python
create matrix and multiply using numpy in python
kishore_kumar | 5 years, 6 months
import numpy as np

matrix = [[1,2,3], [4,5,6], [7,8,9]]
python numpy
how to iterate or get values in python dictionaries
kishore_kumar | 5 years, 6 months
sample_dict = { "number": 1, "fruits": ["apple", "mango", "banana"], "name": "kishore"}

for key i
python
gaya38
Python program for the largest number in an array
gaya38 | 5 years, 6 months
a = [1,43,98,5]#Dummy data
for l in range(len(a)-1):
        if (a[l]>a[l+1]):
python
Prev Next