Skip to content

Instantly share code, notes, and snippets.

View BolinF77's full-sized avatar

jcf_77 BolinF77

View GitHub Profile
@BolinF77
BolinF77 / list.md
Created May 18, 2022 13:04 — forked from ih2502mk/list.md
Quantopian Lectures Saved
class Person:
def __init__(self, name, nationality, age, sex, job):
self.Name = name
self.Country = nationality
self.Age = age
self.Sex = sex
self.Job = job
def talk(self, msg = 0):
self.Msg = msg
@BolinF77
BolinF77 / BlaringStrikingMetalmarkbutterfly-1.py
Last active November 23, 2017 16:44
Class understanding exemple "Person"
class Person:
def __init__(self, name, nationality, age, sex, job):
self.Name = name
self.Country = nationality
self.Age = age
self.Sex = sex
self.Job = job
def talk(self, msg = 0):
self.Msg = msg
from functool import lru_cache
@lru_cache(maxsize = 10000001)
def fibouncci(n):
if n==0:
return 0
elif n==1:
return 1
elif n>1:
return (n-1)+(n-2)
class Dog:
def __init__(self,race):
self.race = race
def info(self, name, age, sex, color):
print ("%s is a %s year old %s dog. He is a %s %s."%(name, age, sex, color, self.race))
def bark(self):
print ("Wooow!")
D = Dog('Labrador')
D.info('Milo', 4, "male", "chocolat")
from functool import lru_cache
@lru_cache(maxsize = 10000001)
def fibouncci(n):
if n==0:
return 0
elif n==1:
return 1
elif n>1:
return (n-1)+(n-2)
from functool import lru_cache
@lru_cache(maxsize = 10000001)
def fibouncci(n):
if n==0:
return 0
elif n==1:
return 1
elif n>1:
return (n-1)+(n-2)
@BolinF77
BolinF77 / Determine score grade.py
Last active November 16, 2017 13:25
Monisen number
from math import sqrt
# python 2.7
# 判断一个数是否是素数的函数
def isPrime(i):
k = int(sqrt(i)) #获取其平方根
flag = 1 #每个循环判断前,先默认每个数都是素数,0是合数,1是素数
for m in range(2,k+1):
if (i%m == 0):
flag = 0 #设置为合数
@BolinF77
BolinF77 / Determine score grade.py
Created November 14, 2017 16:55
Determine score grade created by jichuanfeng - https://repl.it/@jichuanfeng/Determine-score-grade
test = int(input('Enter score: '))
#Grading scale
def determine_score(grade):
if 90 <= grade <= 100:
return 'A'
elif 80 <= grade <= 89:
return 'B'
elif 70 <= grade <= 79:
return 'C'
@BolinF77
BolinF77 / hanoi.py
Created November 14, 2017 16:30
hanoi created by jichuanfeng - https://repl.it/@jichuanfeng/hanoi
def hanoi(a,b,c,n):
if n==1:
print(a,'->',c)
else:
hanoi(a,c,b,n-1)
print(a,'->',c)
hanoi(b,a,c,n-1)
hanoi('a','b','c',4)