Python Programming Python Code Samples



Filters


gaya38
Python program for the largest number in an array
gaya38 | 6 years, 10 months
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, 10 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 | 6 years, 10 months
import random
print random.uniform(10,500)
python
Connect to MySQL database with python mysql connector
kishore_kumar | 6 years, 3 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, 3 months
import sys
import boto3
import datetime
python aws boto3
Run SQL update statement using python pyodbc
kishore_kumar | 5 years, 6 months
import pyodbc

conn = pyodbc.connect('Driver={SQL Server};'
pyodbc python
Get os details using python os
kishore_kumar | 7 years
import os
print os.uname()
# Don't use os.system('uname -a'), its just executing "uname -a" comman
python python-os
Connect to mongo db using python and list of databases
kishore_kumar | 6 years, 4 months
import pymongo

client = pymongo.MongoClient("mongodb://localhost:27017")
pymongo python mongodb
Ramya
PYTHON: To download AWS ELB access log files from S3 bucket based on last modified time
Ramya | 5 years, 5 months
import boto3
import datetime
from datetime import datetime,timedelta,date
Before using this script, you need to set up AWS CLI first as below: ubuntu@ip-172-31-46-2:~$ aws
python boto3 s3
Matrix transpose using list comprehensions in python
harika | 6 years, 5 months
a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
#Procedure1:--------
transposed = [[row[i] for row in a ] fo
List comprehensions in python basically reduce the loc. Check the difference between two procudures
python matrix list
Prev Next