Blogger Information
Blog 32
fans 0
comment 0
visits 19621
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
python 30-40
XuanGG的博客
Original
529 people have browsed it

# test30
'''
scores = [10,20,30,40,60]
for i in scores:
   if i ==30:
       continue
 
   print i
'''


#---------------------------------------------------------------------------

# test 31 异常处理 try ...excep语句来处理异常,吧可能引发异常的语句放在Try快中
'''
try:
   a =1
   print a
except:
   print 'error'
print 'done'
'''

# test 32 字典就是一个键/值对的集合。建必须是唯一的且只能是简单对象
'''
score = {
   'mike':55,
   'xuan':100,
   'GG':20

}

for names in score:
   print names,
   print score[names]

'''

# test 33 模块
# 模块可以理解为是一个包含了函数和变量的py文件。
# 在你的程序中引入了某个模块,就可以使用其中的函数和变量。
'''
import random

print random.randint(1, 10)
print random.choice([1, 3, 5])

from math import pi
print pi
'''
# test 34 函数的默认参数
'''
def name(a='1'):
   print a
name()
'''
# test 35 面向对象
#面向对象编程最主要的两个概念就是:类(class)和对象(object)。
#类是一种抽象的类型而对象是这种类型的实类
'''
class myclass:
   name = 'sam'
   def sayhello(self):
       print 'Hello %s' % self.name

mc = myclass()
print mc.name
mc.sayhello()
'''
'''
class Car:
   speed = 60.0
   def drive(self,distance):
       time = distance / self.speed
       print time
car = Car()
car.drive(100.0)
car.drive(200)
'''

# test38 and or
'''
a = 3
result = (a > 0) and "big" or "small"
print result

a = 0
b = 17
c = True and a or b
d = (True and [a] or [b])[0]
print c, d
'''

# test 39 元祖 也是一种序列 在创建后不能被修改
'''
a = (1,2,3,4,5)

for i in a :
   print a[0]
'''

#40 数学运算python自带了一些基本的数学运算方法,包含在math模块中。
'''
import math
print math.pi
print math.floor(1.2)
'''

Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!