Lecture 1: Introduction to Research — [📝Lecture Notebooks] [
Lecture 2: Introduction to Python — [📝Lecture Notebooks] [
Lecture 3: Introduction to NumPy — [📝Lecture Notebooks] [
Lecture 4: Introduction to pandas — [📝Lecture Notebooks] [
Lecture 5: Plotting Data — [📝Lecture Notebooks] [[
This file contains hidden or 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
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 |
This file contains hidden or 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
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 |
This file contains hidden or 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 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) |
This file contains hidden or 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
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") |
This file contains hidden or 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 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) |
This file contains hidden or 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 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) |
This file contains hidden or 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 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 #设置为合数 |
This file contains hidden or 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
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' |
This file contains hidden or 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 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) |
NewerOlder