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
from fractions import Fraction | |
def fromrepeating(r): | |
if type(r) == int: | |
return(Fraction(r,1)) | |
if type(r) == float: | |
return(Fraction(int(str(r).replace('.','')),10**(len(str(r))-str(r).index('.')-1))) | |
if type(r) != str: | |
return(None) | |
if 'r' not in r: | |
try: |
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
""" | |
github.com/dimnikolos | |
2019 | |
""" | |
import re | |
import scholarly | |
with open('citescount.html','w',encoding='utf-8') as resf: | |
#cites.txt is your bibliography/reference in a text file | |
#a line per reference |
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
from microbit import * | |
def showEL(greekLetter): | |
greekLetters = {"Α": Image("09900:90090:99990:90090:90090"), | |
"Β": Image("99900:90090:99900:90090:99900"), | |
"Γ": Image("99990:90000:90000:90000:90000"), | |
"Δ": Image("09900:90090:90090:90090:99990"), | |
"Ε": Image("99990:90000:99900:90000:99990"), | |
"Ζ": Image("99990:00900:09000:90000:99990"), |
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 replaceAccents(l): | |
""" | |
replace greek accents | |
""" | |
l = l.lower() | |
rDict = {'ά':'α','ό':'ο','ύ':'υ','ϋ':'υ','ΰ':'υ','έ':'ε','ί':'ι', | |
'ϊ':'ι','ΐ':'ι','ή':'η','ώ':'ω','ς':'σ'} | |
retStr = '' | |
for x in l: | |
retStr += (x if x not in rDict else rDict[x]) |
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
from fractions import Fraction | |
def mixed(k): | |
m = int(k) | |
f = k-m | |
if m == 0: | |
return(str(f)) | |
if f == 0: | |
return(str(m)) | |
return(str(m) + " " + str(f)) |
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 math | |
def einaiTetragwnos(x): | |
if math.sqrt(x) == int(math.sqrt(x)): | |
return(True) | |
else: | |
return(False) | |
for a in range(-3,3): | |
for b in range(-3,3): | |
for g in range(-3,3): |
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
#Συναισθήματα χαράς και λείπεις | |
#Μου λύπης! | |
#@dnikolos | |
removeProblems = { | |
"ου":"ΟΥ", | |
"ού":"ΟΎ", | |
"αυ":"ΑΥ", | |
"αύ":"ΑΎ", | |
"ευ":"ΕΥ", |
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
""" | |
computing partial sums | |
for a multiplication | |
""" | |
def updict(v,p,d): | |
if p in d: | |
d[p].append(v) | |
else: |
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
\documentclass{article} | |
\usepackage{amsmath} | |
\begin{document} | |
\begin{align*} | |
999^2&=(999^2 - 1) + 1\\ | |
999^2&=(999^2 - 1^2) + 1\\ | |
&=(999-1)(999+1) + 1\\ | |
&=998\cdot 1000 + 1\\ | |
&=998000 + 1\\ | |
&=998001 |
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 csv | |
import sys | |
csv.field_size_limit(sys.maxsize) | |
#allBlocks.csv is from https://github.com/TUDelftScratchLab/ScratchDataset | |
with open('allBlocks.csv','r') as rawcsv: | |
reader = csv.DictReader(rawcsv,fieldnames =[ | |
'projectID', 'scriptCoordinates', 'scriptIndex', | |
'stageSpriteindication', 'spriteName', 'indentation', | |
'blockIndex', 'blockType', 'parameters']) |
NewerOlder