Skip to content

Instantly share code, notes, and snippets.

View gauravpatt92's full-sized avatar

Gaurav Pattnaik gauravpatt92

  • New Delhi
View GitHub Profile
def caesar_encryption(st, shift, num):
new = st.lower()
result = ""
if shift=='l':
for i in new:
if i.isalpha():
if ord(i)-num<97:
result = result + chr(122-(97-(ord(i)-num) +1))
else:
result = result + chr(ord(i)-num)
@gauravpatt92
gauravpatt92 / bir_month_plot.py
Last active May 8, 2017 16:34
bokeh plot for birthdays in each month.
import json
from collections import Counter
from bokeh.plotting import figure, show, output_file
with open("birthdays_1.json", "r") as f_r:
data = json.load(f_r)
l_month = []
for i in data:
@gauravpatt92
gauravpatt92 / birthday add and search.py
Created May 8, 2017 14:54
Adding birthdays and searching for them in a json file
import json
answer='yes'
while answer!='no':
with open("birthdays_1.json","r") as f_r:
data = json.load(f_r)
print("\n\nWe have birthdays of the following people...")
for i in data:
@gauravpatt92
gauravpatt92 / Hangman.py
Last active May 8, 2017 12:36
The hangman letter guessing game of a random word.
def printHang(n):
gal = [['---- '],
['| | '],
['| '],
['| '],
['| ']]
if n < 6:
gal[2] = ['| o ']
if n < 5:
gal[3] = ['| / ']
@gauravpatt92
gauravpatt92 / Tic Tac Toe.py
Created May 7, 2017 03:35
Tic Tac Toe full game
print ("TIC TAC TOE board. Rows and Columns starting from 1,1. Chances over after every place filled and not when someone wins.")
print ("Game board is printed after each chance to show progress!")
def print_game(game):
print ("\n")
for i in range(3):
print (" | ".join(str(x) for x in game[i]))
if i<2:
print("-------------")
@gauravpatt92
gauravpatt92 / tic tac toe input.py
Created May 7, 2017 01:21
Tic Tac Toe board entry
print ("TIC TAC TOE board. Rows and Columns starting from 1,1. Chances over after every place filled and not when someone wins.")
print ("Game board is printed after each chance to show progress!")
def print_game(game):
print ("\n")
for i in range(3):
print (str(game[i]) + "\n")
game=[[0,0,0], [0,0,0], [0,0,0]]
@gauravpatt92
gauravpatt92 / GuessingGame2.py
Created May 6, 2017 22:24
Python 3 code for guessing game 2 on practiceputhon.org
def guess_work():
count = 0
min = 0
max = 101
ans = ""
while ans!='same':
count+=1
mid = (max + min)//2