Monte Carlo Pi

Fri 14 November 2025

title: "Monte Carlo Pi" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


from numba import jit
import numpy as np
import random
import numba
@numba.jit
def monte_carlo_pi(nsamples):
    acc = 0
    for i in range(nsamples):
        x = random.random()
        y = random.random()
        if (x**2 + y**2 …

Category: numba

Read More

Months-And-Counts

Fri 14 November 2025

import numpy as np
import matplotlib.pyplot as plt

N = 12
medalists_mob = (2, 7, 8, 12, 3, 8, 78, 1, 8, 44, 55, 12)

ind = np.arange(N)  # the x locations for the groups
width = 0.15       # the width of the bars

fig, ax = plt.subplots()
rects1 = ax.bar(ind …

Category: barchart

Read More

More Itertools

Fri 14 November 2025

title: "More Itertools" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


import itertools as it
import more_itertools as mit
a = it.count(0, 2)
mit.take(10, a)
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]

more:

https://github.com/erikrose/more-itertools



Score: 5

Category: basics

Read More

Mp3-2-Wav

Fri 14 November 2025

title: "mp3 2 wav" author: "Rj" date: 2019-04-21 description: "-" type: technical_note draft: false


import speech_recognition as sr
from os import path
from pydub import AudioSegment
# convert mp3 file to wav                                                       
sound = AudioSegment.from_mp3("/tmp/two.mp3")
sound.export("/tmp/two.wav", format="wav")

print('Done')
Done


Score: 0

Category: textprocessing

Read More

Multiline-Glyb-1

Fri 14 November 2025

from bokeh.plotting import figure, output_file, show
from bokeh.io import output_notebook
from bokeh.models import ColumnDataSource
# Set Bokeh output to notebook
output_notebook()

Category: bokeh

Read More

Mutable Objet

Fri 14 November 2025

title: "Mutable Object" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false source: https://stackoverflow.com/questions/1132941/least-astonishment-and-the-mutable-default-argument


def foo(a=[]):
    a.append(5)
    return a
foo()
[5]
foo()
[5, 5]
foo()
[5, 5, 5]

Reason:

What causes the confusion is the behaviour you get when you …

Category: basics

Read More

My-Personal-Pynotes-Growth

Fri 14 November 2025

import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5, 6, 7]
y = [
    0,
    220,
    380,
    500,
    540,
    540,
    590,
]
y
[0, 220, 380, 500, 540, 540, 590]
plt.plot(x, y, 'ro')

# plt.axis([0, 10, 20, 100])
[<matplotlib.lines.Line2D at 0x7f895c338c20>]

png



Score: 5

Category: plot

Read More

Name-Collector

Fri 14 November 2025

title: "Name Collector" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


import requests
from bs4 import BeautifulSoup
# Collect and parse first page
page = requests.get('https://www.babble.com/pregnancy/1000-most-popular-boy-names/')
soup = BeautifulSoup(page.text, 'html.parser')    

#print(soup)    

items = soup.select('main.tm-single-content li a')

item_list …

Category: webreader

Read More

Name Meter

Fri 14 November 2025

title: "Get Name Meter" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


def get_int(c):
    if(c == 'a'):
        return (200 + ord(c))

    if(c == 'e'):
        return (250 + ord(c))

    if(c == 'i'):
        return (300 + ord(c))

    if(c == 'o'):
        return (350 + ord(c))

    if(c == 'u'):
        return …

Category: basics

Read More

Name Scope

Fri 14 November 2025

title: "Name Scope" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
# to clear the graph before new nodes
tf.reset_default_graph()

with tf.name_scope("march"):
    a = tf.constant(1 …

Category: tensorflow-work

Read More
Page 116 of 146

« Prev Next »