print('Hello World Python');
#python 变量定义
x = 1;
y = 2;
z = x + y;
print(z);
#if 判断语句
score = 50;
if score >= 90:
print("优秀");
elif score >= 80:
print("良好");
elif score >= 60:
print("及格");
else:
print("不及格");
#for 循环
for i in range(0,10):
print(i);
print("Index {0},{1}".format(i,"blogs"))
print("for is end");
#python 函数定义
def Say():
print("Hello Python3");
def Size(x,y):
if x > y:
return x;
else:
return y;
Say();
print("size is {0}".format(Size(1,2)));
#Python3 定义Class
class Person:
def __init__(self,name):
self.name = name;
def getName(self):
print("my name is {0}".format(self.name));
person = Person("zzg");
person.getName();
#Python3 继承
class Man(Person):
def __init__(self,name,age):
Person.__init__(self,name);
self.age = age;
def getAge(self):
print("my age is {0}".format(self.age));
man = Man("zzg","26");
man.getName();
man.getAge();