Python3 基础语法,从入门到精通一

来源:互联网 发布:安装windows 2003灰色 编辑:程序博客网 时间:2024/06/06 20:15
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 定义Classclass 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();

0 0