Skip to content

Instantly share code, notes, and snippets.

@Marva82
Marva82 / Histogram - Two Normal Distributions Plots.py
Created July 4, 2018 19:32
Histogram Plotting in Python - 2 Plots on same Matplotlib axes
#Plotting Kernel Density Estimate - Estimate of Probability Density Function
#Means of smoothing data
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
means = 15, 35
stdevs = 6, 12
distro = pd.DataFrame(np.random.normal(loc=means, scale=stdevs, size=(2000,2)),
@Marva82
Marva82 / Cryptography - CaesarCipher.py
Created June 8, 2018 21:11
Caesar Cipher - Cryptography in Python
#Simple Ceasar Cipher - Cryptography
class CaesarCipher:
#Class for doing ecryption and decryption using Ceasar cipher
def __init__(self,shifter):
#Costruct cipher using integer shift of alphabet
encoderList = [None] * 26
decoderList = [None] * 26
for i in range(26):
@Marva82
Marva82 / List Comprehension.py
Created June 8, 2018 16:29
List Comprehension
#Creating a list using List Comprehension
squares = []
for i in range(1,11):
squares.append(i*i)
print(squares)
squares = [i*i for i in range(1,15)]
@Marva82
Marva82 / Recursion_Part2.py
Created June 6, 2018 21:00
Getting all subsets from a list using Recursion in Python
'''
Second part to recursion videos
Printing out all subsets of a list of numbers
using recursion
'''
def subset(input):
if input == []:
return [[]]
else:
@Marva82
Marva82 / Recursion.py
Created June 6, 2018 20:58
Small code snippet showing simple recursion in Python
#Showing simple recursion example
def recursionFunc(input):
if input <= 1:
return 1
else:
return input * recursionFunc(input - 1)
someInput = recursionFunc(4)
print(someInput)
@Marva82
Marva82 / Python Calculator.py
Created June 6, 2018 13:38
Python Calculator that accepts multiple inputs from a user
#Creating a calculator that gets multiple input from the user
from functools import reduce
def addition(*args):
newList = []
for i in inputList:
z = int(i)
newList.append(z)
NumbersSum = sum(newList)
return NumbersSum