This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pascal traingle generator - generates n rows of triangle | |
if __name__ == "__main__": | |
n = int(input("n: ")) # num rows | |
triangle = [] # pascal triangle | |
for x in range(0, n): | |
# no references for the 1's at the edges | |
# hard code them, generate the rest | |
if x == 0: | |
triangle.append([1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# matrix calculator | |
import numpy as np | |
if __name__ == "__main__": | |
# select matrix dimemsion | |
print("#### MATRIX CALCULATOR ####") | |
print("Paper work: ") | |
print("-- Separate row elements by spaces") | |
print("-- Use x to end matrix input") | |
print("-- Use only nxn matrices for non-arithmetic operations") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the sum of a list of numbers without using a for loop | |
def add(arr, s = 0): | |
s += arr[0] | |
if len(arr) > 1: | |
s += add(arr[1:]) | |
return s | |
print("Sum", add([1, 2, 3, 4, 5])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# binomial coeficient | |
import math | |
if __name__ == "__main__": | |
print("#### Binomial Coefficent Calculator ####") | |
print("Use: Given (a + b)^n, p = coefficient of a, q = coefficient of b, t = nth term") | |
# get params n, p, q and t | |
n = int(input("n: ")) | |
p = int(input("p: ")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gradingSystem(): | |
print("Enter 'done' to end program.") | |
score = input("Enter student's score between 0 to 100:") | |
while(score != "done"): | |
score = float(score) | |
if score >= 101 or score < 0: | |
print("Sorry, score out of grade system range") | |
elif score >= 90: | |
print("You got an 'A'") | |
elif score >= 80: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
# method 1 | |
# using Regular Expressions AKA RegEx-es | |
def lenFunction1(): | |
print("#### Method 1 ####") | |
sentence = str(input("Enter valid sentence:")) | |
# use RegEx substitution | |
# param 1: find | |
# param 2: replace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* jquery.linky.js v0.1.8 | |
* https://github.com/AnSavvides/jquery.linky | |
* The MIT License (MIT) | |
* | |
* Copyright (c) 2013 - 2015 Andreas Savvides | |
* | |
* Customized to allow any link-to base url | |
* So you're not limited to Twitter, Instagram or GitHub | |
* Plus other hacks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# reference (https://pythonprogramming.net/change-show-new-frame-tkinter/) | |
import tkinter as tk | |
# window | |
class LoginApp(tk.Tk): | |
# constructor | |
def __init__(self, *args, **kwargs): | |
tk.Tk.__init__(self, *args, **kwargs) | |
container = tk.Frame(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript"> | |
// A CSRF token is required when making post requests in Django | |
// To be used for making AJAX requests in script.js | |
window.CSRF_TOKEN = "{{ csrf_token }}"; | |
</script> | |
</head> | |
<body> | |
<h2>My Blog Posts</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.timeline { | |
position: relative; | |
padding:4px 0 0 0; | |
margin-top:22px; | |
list-style: none; | |
} | |
.timeline>li:nth-child(even) { | |
position: relative; | |
margin-bottom: 50px; |
OlderNewer