Skip to content

Instantly share code, notes, and snippets.

@itsmuriuki
itsmuriuki / gist:33b46e8cfee0318587693f251c76c235
Created September 30, 2016 13:02
square root of numbers
def square_root (n,d) #number and error difference
guess = n / 2.0 #half the guess since square root cant be more than half
while (((guess *guess) - n).abs > d)
guess = refine(guess, n)
end
puts guess
end
def refine (guess, n)
guess = (guess + (n / guess)) / 2.0
def square_root (n)
guess = n / 2.0
while (((guess *guess) - n).abs > 0.000000001)
guess = refine(guess, n)
end
return guess
end
def refine (guess, n)
def max_min(arr):
mini=arr[0]
maxi=arr[0]
for x in arr:
if maxi<x:
maxi=x
if mini>x:
mini=x
max_and_min=[maxi,mini]
def wierd_sort (arr): #defining the length of the array
wierd =[] #Empty arry to store sorted arr
myarr = arr[:] #makes a copy of the array
myarr = sorted(myarr) #sorts array
i = 0
while i < len(myarr): #goes through the lenngth of the array
if len(myarr) > 1:
wierd.append(myarr[0]) #appends the first digit into the new arr
wierd.append(myarr[-1]) #appends the last digit into the new arr
myarr.remove(myarr[0]) #removes the first digit from a copy of the initial array
arra = [1,2,3]
def roots_of_eqn(coeffs)
a = coeffs[0]
b = coeffs[1]
c = coeffs[2]
d = (b * b) - (4 * a * c)
if d <= 0
def sort_playlist(arr):
arr = arr[:]
for num_pass in range(len(arr)-1,0,-1):
for i in range(num_pass):
if arr[i][1] > arr[i+1][1]:
arr[i], arr[i+1] = arr[i+1],arr[i]
return arr
def select_songs(playlist,time):
sorted_playlist = sort_playlist
@itsmuriuki
itsmuriuki / Installing PyMongo for Python3 via pip3
Created September 16, 2017 14:23
Installing PyMongo for Python3 via pip3
#checking python version
python3 --version # should return 'Python 3.4.0'
sudo apt-get install python3-pip
sudo pip3 install pymongo #installing pymongo
Verifying my Blockstack ID is secured with the address 1Fi57n2HTNgRerKqEm1KD9bYSSnJZkt4wF https://explorer.blockstack.org/address/1Fi57n2HTNgRerKqEm1KD9bYSSnJZkt4wF
@itsmuriuki
itsmuriuki / east&southernafricamosquitoes.ipynb
Last active July 17, 2019 09:36
East and South African Mosquito classifier: This notebook has images of mosquitoes of three species which are prevalent in the areas mentioned and could be carriers of the parasite Plasmodium in their salivary glands which is the causative agent of malaria.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@itsmuriuki
itsmuriuki / Ians_gans_02_2018.md
Created April 14, 2019 02:07 — forked from z-a-f/Ians_gans_02_2018.md
Ian's GAN list 02/2018