#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2018-12-18 15:16
# @Author  : owen.zhang
# @Site    :Python3 循环语句
# @File    : opsUse.py
# @Software: PyCharm
#while 循环
# !/usr/bin/env python3

n = 100
sum = 0
counter = 1
while counter <= n:
    sum = sum + counter
    counter += 1
print("1 到 %d 之和为: %d" % (n, sum))

#for 语句
# !/usr/bin/python3

sites = ["Baidu", "Google", "Runoob", "Taobao"]
for site in sites:
    if site == "Runoob":
        print("菜鸟教程!")
        break
    print("循环数据 " + site)
else:
    print("没有循环数据!")
print("完成循环!")
##hile 中 使用 break：
#实例
n = 5
while n > 0:
    n -= 1
    if n == 2:
        break
    print(n)
print('循环结束。')

#3hile 中 使用 break：
实例
n = 5
while n > 0:
    n -= 1
    if n == 2:
        break
    print(n)
print('循环结束。')
30812486e0dc3e96d9f232b2a81cd2dfdfcd002f
<mask token>

<mask token>
while counter <= n:
    sum = sum + counter
    counter += 1
print('1 到 %d 之和为: %d' % (n, sum))
<mask token>
for site in sites:
    if site == 'Runoob':
        print('菜鸟教程!')
        break
    print('循环数据 ' + site)
else:
    print('没有循环数据!')
print('完成循环!')
<mask token>
while n > 0:
    n -= 1
    if n == 2:
        break
    print(n)
print('循环结束。')
实例
<mask token>
while n > 0:
    n -= 1
    if n == 2:
        break
    print(n)
print('循环结束。')

n = 100
sum = 0
counter = 1
while counter <= n:
    sum = sum + counter
    counter += 1
print('1 到 %d 之和为: %d' % (n, sum))
sites = ['Baidu', 'Google', 'Runoob', 'Taobao']
for site in sites:
    if site == 'Runoob':
        print('菜鸟教程!')
        break
    print('循环数据 ' + site)
else:
    print('没有循环数据!')
print('完成循环!')
n = 5
while n > 0:
    n -= 1
    if n == 2:
        break
    print(n)
print('循环结束。')
实例
n = 5
while n > 0:
    n -= 1
    if n == 2:
        break
    print(n)
print('循环结束。')

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2018-12-18 15:16
# @Author  : owen.zhang
# @Site    :Python3 循环语句
# @File    : opsUse.py
# @Software: PyCharm
#while 循环
# !/usr/bin/env python3

n = 100
sum = 0
counter = 1
while counter <= n:
    sum = sum + counter
    counter += 1
print("1 到 %d 之和为: %d" % (n, sum))

#for 语句
# !/usr/bin/python3

sites = ["Baidu", "Google", "Runoob", "Taobao"]
for site in sites:
    if site == "Runoob":
        print("菜鸟教程!")
        break
    print("循环数据 " + site)
else:
    print("没有循环数据!")
print("完成循环!")
##hile 中 使用 break：
#实例
n = 5
while n > 0:
    n -= 1
    if n == 2:
        break
    print(n)
print('循环结束。')

#3hile 中 使用 break：
实例
n = 5
while n > 0:
    n -= 1
    if n == 2:
        break
    print(n)
print('循环结束。')