#coding:gbk
from pip._vendor import requests
score=20;
if score>=80:
print("很好")
elif score>=60:
print("及格")
elif score>=30:
print("不及格")
else:
print("你成绩很烂")
for i in range(0,10):
print("我是循环练习1---{0}".format(i));
def sayHello():
print("hell 我是方法");
def Max(a,b):
if a>b:
return a
else:
return b
sayHello()
print( Max(10,20))
# python对象
class Hello:
def sayHello(self):
print("Hello")
h=Hello()
h.sayHello();
#构造方法
class HelloTwo:
def __init__(self,name):
self._name=name
def sayHello(self):
print("Hello{0}".format(self._name))
h=HelloTwo("hello极客学院")
h.sayHello();
class Hi(HelloTwo):
def __int__(self,name):
HelloTwo.__init__(self,name)
def sayHi(self):
print("Hi {0}".format(self._name));
h=HelloTwo("hello极客学院")
h.sayHello();
hi=Hi("我是继承构造方法实例")
hi.sayHi()
#第一种引用外部文件方法
import mylib
h=mylib.hello();
h.sayHello();
#第二种引用外部文件方法
from mylib import hello
h=hello();
h.sayHello();
运行效果图:

原文:http://www.cnblogs.com/aaaaq/p/5934279.html