Skip to content

Instantly share code, notes, and snippets.

View ry05's full-sized avatar
๐Ÿ“
Deliberate Practice

Ramshankar Yadhunath ry05

๐Ÿ“
Deliberate Practice
View GitHub Profile
#reusing code written before
countries=country
best_choc={} # empty dictionary
for j in countries:
c=0
b=df[df['location']==j]
br=b[b['rating']>=4] # rating more than 4
for i in br['rating']:
c+=1
best_choc[j]=c
#to get the indices
countries=df['broad_bean_orig'].value_counts().index.tolist()[:5]
# countries has the top 5 countries in terms of reviews
best_choc={} # empty dictionary
for j in countries:
c=0
b=df[df['broad_bean_orig']==j]
br=b[b['rating']>=3] # rating more than 3
for i in br['rating']:
c+=1
@ry05
ry05 / bank_management.py
Last active March 26, 2017 06:14
Basic code implementing dictionary usage in python
print('Bank Management System')
b=[]
c='y'
while(c=='y'):
name=input('Enter customer name: ')
accno=str(input('Enter the account number: '))
amount=int(input('Enter the amount you have: '))
b.append((accno,(name,amount)))
c=input('do u want to enter details? ')
bank=dict(b)
@ry05
ry05 / gauss_elimination.c
Created March 26, 2017 06:09
Solving linear system of equations(Gauss Elimination)
#include <iostream.h>
int main()
{
cout<<"\t\t\t\t"<<"GAUSS ELIMINATION"<<endl;
int x,y,z;
int a1,b1,c1,a2,b2,c2,a3,b3,c3,d1,d2,d3;
cout<<"Enter the coeeficients of x,y,z in the same order for equation 1.Also enter the constant on RHS after that."<<endl;
cin>>a1>>b1>>c1>>d1;
cout<<"Enter the coeeficients of x,y,z in the same order for equation 2.Also enter the constant on RHS after that."<<endl;
@ry05
ry05 / number_guess_game.c
Created March 26, 2017 06:05
A one player game where u guess the machine
import random
n=random.randint(1,100)
pts=100
c=1
i=1
print("Hello Player! Welcome to the Number Guess Game!\n U get like 10 chances to guess a number that the computer generates...\n You have clues but only at try 1,try 4 and try 7. \n WARNING: YOU LOSE POINTS FOR EACH CLUE!")
while(i<=10):
a=int(input("\nEnter number between 1 and 100: "))
if(a==n):
print("\nYou win!")
@ry05
ry05 / tic_tac_toe_code.py
Created March 26, 2017 06:01
A code for tic tac toe game using python.
x='X'
o='O'
EMPTY=' '
NUM_SQUARES=9
played_moves=[]
board=[]
c=0
def instructions():
print("Tic tac toe game.\nPlayer 1 is always the first to move and he gets 'X' by default")
print('The game board is: \n')