Python学习第四天
2016-01-18 00:00
696 查看
摘要: http://www.runoob.com/python/python-for-loop.html
#!/usr/bin/python
# filename:test4.py
count = 0
while (count < 9):
print ('the count is:',count)
count =count + 1
print ("Good bye!")
i = 1
while i < 10 :
i += 1
if i%2 >0 :
continue
print (i)
# while ....else : else will execute after while finish
count = 0
while count < 5:
print (count,"is less than 5")
count = count + 1
else:
print (count," is not less than 5")
flag = 1
# this sentence is an example of infine loop
#while (flag):print ("Give flag is really true!")
# part two
for letter in 'Python' :
print ('the current character :',letter)
fruits = ['banana','apple','mango']
for fruit in fruits:
print ('current character:',fruit)
print ('Good bye!')
for index in range(len(fruits)):
print ('current fruit:',fruits[index])
print ('Good bye!')
for num in range(10,20):
for i in range(2,num):
if num%i == 0:
j=num/i
print ('%d equals %d * %d' % (num,i,j))
break
else:
print (num,'is a odd prime')
#!/usr/bin/python
# filename:test4.py
count = 0
while (count < 9):
print ('the count is:',count)
count =count + 1
print ("Good bye!")
i = 1
while i < 10 :
i += 1
if i%2 >0 :
continue
print (i)
# while ....else : else will execute after while finish
count = 0
while count < 5:
print (count,"is less than 5")
count = count + 1
else:
print (count," is not less than 5")
flag = 1
# this sentence is an example of infine loop
#while (flag):print ("Give flag is really true!")
# part two
for letter in 'Python' :
print ('the current character :',letter)
fruits = ['banana','apple','mango']
for fruit in fruits:
print ('current character:',fruit)
print ('Good bye!')
for index in range(len(fruits)):
print ('current fruit:',fruits[index])
print ('Good bye!')
for num in range(10,20):
for i in range(2,num):
if num%i == 0:
j=num/i
print ('%d equals %d * %d' % (num,i,j))
break
else:
print (num,'is a odd prime')
相关文章推荐
- 在spark上做简单的文本分类(python)
- [Python标准库]random——伪随机数生成器
- python修饰符——带参数
- Python一周学习的小结
- Python及requests乱码问题的总结
- python无参数的装饰符
- python 环境搭建(Mac)
- ML--HMM(隐马尔可夫模型及python的实现2)
- python100例(一)
- python列表和QVariant
- 《笨办法学Python》 第15课手记
- Python 基础【一】
- python数据类型-列表(序列类型)
- python collection系列
- Python_day01_笔记
- Python - 定制pattern的string模板(template) 具体解释
- Python数据类型-序列(元组)
- python数据类型(字符串)
- python 利用正则过滤表情符号
- windows 上执行python pywin32.exe