python练习题

练习题:

0708

1、输出1-100

num = 1
while num <= 100:
  print(num)
  num += 1
num = 0
while num <= 99:
  num += 1
  print(num)

2、输出1-100的偶数

num = 0
while num <= 99:
  num = num+2
  print(num)
num = 0
while num <=99:
  if num%2 == 0:
    print(num)
  num += 1

0709

1、while循环打出“alex”

s = "alex"
while i in len(s):
  print(s[i])
  i += 1

2、for循环打出“alex”

s = "alex"
for i in s:
  print(i)

3、for循环打出“alex”字符串

s = "alex"
for i in s:
  print(s) 
posted @ 2019-07-09 09:56  张珊33  阅读(168)  评论(0编辑  收藏  举报