Skip to content

Instantly share code, notes, and snippets.

View NimJ's full-sized avatar

Nimesh Jha NimJ

  • IBM
View GitHub Profile
Class a:
def cow_bull(self):
import random
cowbull = [0,0]
count = 1
x = random.sample([1,2,3,4,5,6,7,8,9,0],4)
y = list(input('input 4 digits seperated by spaces \n '))
while x != y:
for i in range(3):
if y[i] in x:
@NimJ
NimJ / guess.py
Created March 28, 2017 09:31
Guessing Game
def guessing_game(self):
import random
try:
number = random.randint(1,9)
count =0
x = int(input('guess the number \n '))
while x != number:
if x > number:
print 'high guess try again'
count +=1
@NimJ
NimJ / beautiful_idiomatic_python.md
Created October 5, 2016 06:42 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@NimJ
NimJ / Spark Dataframe Cheat Sheet.py
Created July 22, 2016 14:50 — forked from evenv/Spark Dataframe Cheat Sheet.py
Cheat sheet for Spark Dataframes (using Python)
# A simple cheat sheet of Spark Dataframe syntax
# Current for Spark 1.6.1
# import statements
from pyspark.sql import SQLContext
from pyspark.sql.types import *
from pyspark.sql.functions import *
#creating dataframes
df = sqlContext.createDataFrame([(1, 4), (2, 5), (3, 6)], ["A", "B"]) # from manual data