提交
This commit is contained in:
14
day8/传参.py
Normal file
14
day8/传参.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
class People():
|
||||||
|
def __init__(self,name,age):
|
||||||
|
self.name = name
|
||||||
|
self.age = age
|
||||||
|
def getname(self):
|
||||||
|
return self.name
|
||||||
|
def getage(self):
|
||||||
|
return self.age
|
||||||
|
def eat(self,food):
|
||||||
|
print(self.name+'吃掉了'+food)
|
||||||
|
r = People('僵尸',213)
|
||||||
|
#print(r.name)
|
||||||
|
print(r.getname(),r.age)
|
||||||
|
r.eat('你的大脑')
|
||||||
16
day8/订单号.py
Normal file
16
day8/订单号.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
|
class Random:
|
||||||
|
def __init__(self):
|
||||||
|
self.cpu_id = 123
|
||||||
|
self.os_id = 890
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
timestamp = int(datetime.datetime.now().timestamp() * 1000000)
|
||||||
|
final = timestamp * 1000000 + self.cpu_id * 1000 + self.os_id
|
||||||
|
return final
|
||||||
|
|
||||||
|
|
||||||
|
r = Random()
|
||||||
|
print(r.get())
|
||||||
33
day9/circle.py
Normal file
33
day9/circle.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
class Circle:
|
||||||
|
def __init__(self, datalist):
|
||||||
|
self.x = int(datalist[0])
|
||||||
|
self.y = int(datalist[1])
|
||||||
|
self.r = int(datalist[2])
|
||||||
|
|
||||||
|
def getr(self):
|
||||||
|
return self.r
|
||||||
|
|
||||||
|
def postion(self):
|
||||||
|
print("(" + str(self.x) + "," + str(self.y) + ")")
|
||||||
|
|
||||||
|
def calculate(self):
|
||||||
|
print(self.r**2 * 3.14)
|
||||||
|
|
||||||
|
|
||||||
|
def prepare(a: Circle, b: Circle):
|
||||||
|
distance2 = (a.x - b.x) ** 2 + (a.y - b.y) ** 2
|
||||||
|
if distance2 < (a.r + b.r) ** 2:
|
||||||
|
print("相交")
|
||||||
|
if distance2 == (a.r + b.r) ** 2:
|
||||||
|
print("相切")
|
||||||
|
if distance2 > (a.r + b.r) ** 2:
|
||||||
|
print("相离")
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
a = Circle([1, 1, 1])
|
||||||
|
a.calculate()
|
||||||
|
b = Circle((input("请输入x,y,半径")).split())
|
||||||
|
prepare(a, b)
|
||||||
|
except:
|
||||||
|
print("需要三个数")
|
||||||
@ -1,3 +1,4 @@
|
|||||||
repository 项目
|
repository 项目
|
||||||
untracked 未跟踪
|
untracked 未跟踪
|
||||||
push 发布
|
push 发布
|
||||||
|
shift + table 多行缩进
|
||||||
Reference in New Issue
Block a user