#变量名,模块名的命名规则 模块名用小写字母,全局变量用__rule
#第2行定义了一个名为Student的对象,类名大写
#第4行定义了一个实例变量有2个下划线,
#第4行定义用self前缀说明了__name变量属于Student类
class Student(object):
"""docstring for Student"""
__name = ""
def __init__(self, name):
super(Student, self).__init__()
self.name = name
def getName(self):
return self.__name
if __name__=="__main__":
student = Student("borphi")
print student.getName()
#第2行定义了一个名为Student的对象,类名大写
#第4行定义了一个实例变量有2个下划线,
#第4行定义用self前缀说明了__name变量属于Student类
#第7行定义了一个函数,第12行定义了一个对象
import random
def compareNum(num1,num2):
if(num1>num2):
return 1
else:
return 0
pass
num1 = random.randrange(1,9)
num2 = random.randrange(1,9)
print "num1=", num1
print "num2=", num2
print compareNum(num1,num2)
#关于函数的写法
i =1
print type(i)
l = 99999999999
print type(l)
f = 1.2
print type(f)
b = True
print type(b)
关于数据类型
<type 'int'>
<type 'long'>
<type 'float'>
<type 'bool'>
[Finished in 0.2s]