# -*- coding: utf-8 -*-
"""
Created on Thu May 9 08:11:49 2019
@author: Administrator
"""
# while 循环
i = 1; s = 0
while i <= 100:
s += i
i += 1
print(s)
count = 0
while count < 5:
print(count, " is less than 5.")
count += 1
else:
print(count, " is not less than 5, stop!")
# for 循环
d = {'name':'david', 'age':'20', 'gender':'male', 'depart':'stats', 'height':'178'}
for key in d:
print(key, ': ', d[key])
s = 0
for x in range(1, 101):
s += x;
print(s)
print('\n1---------------')
print(range(5))
print(list(range(5)))
for ww in range(3):
print(ww)
print('\n2---------------')
for kk in list(range(6)):
print(kk)
运行:
5050
0 is less than 5.
1 is less than 5.
2 is less than 5.
3 is less than 5.
4 is less than 5.
5 is not less than 5, stop!
name : david
age : 20
gender : male
depart : stats
height : 178
5050
1---------------
range(0, 5)
[0, 1, 2, 3, 4]
0
1
2
2---------------
0
1
2
3
4
5