Python Code Samples



Filters


how to iterate or get values in python dictionaries
kishore_kumar | 1 year, 8 months
sample_dict = { "number": 1, "fruits": ["apple", "mango", "banana"], "name": "kishore"}

for key i
python
gaya38
Shuffle list elements in python
gaya38 | 1 year, 8 months
import random;
z = [1,90,4,2]
z = random.shuffle(z)
python
Get current environment variables in python
kishore_kumar | 1 year, 10 months
import os
env = os.environ

python python-os
sandeep
Python Script to create AWS beanstalk
sandeep | 1 year, 11 months
#!/usr/bin/python
  
import boto
python aws beanstalk
gaya38
Python program for the largest number in an array
gaya38 | 1 year, 8 months
a = [1,43,98,5]#Dummy data
for l in range(len(a)-1):
        if (a[l]>a[l+1]):
python
create matrix and multiply using numpy in python
kishore_kumar | 1 year, 8 months
import numpy as np

matrix = [[1,2,3], [4,5,6], [7,8,9]]
python numpy
gaya38
Generate Random number within the range in python
gaya38 | 1 year, 8 months
import random
print random.uniform(10,500)
python
Connect to MySQL database with python mysql connector
kishore_kumar | 1 year, 1 month
# pip install mysql-connector

from mysql import connector
python mysql mysql-connector
Matrix transpose using list comprehensions in python
harika | 1 year, 3 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
Connect to mongo db using python and list of databases
kishore_kumar | 1 year, 2 months
import pymongo

client = pymongo.MongoClient("mongodb://localhost:27017")
pymongo python mongodb
Prev Next