day1我学会了什么?

   之前都是本身自学python没有老师的讲解没有同窗们一块儿学习的氛围,本身的进展很慢。python

经过第一天认真的听讲,使我对基础部分记忆的更加的深入了。学习

做业:utf-8

求一百之内的和:input

# -*- coding:utf-8 -*-
sum = 0

count = 1
while count < 101:
sum = sum + count
count = count + 1
print(sum)
一百之内的奇数:
# -*- coding:utf-8 -*-
count = 0
while True:
if count == 100:
break
count = count + 1
if 0 != count % 2:
print(count)
一百之内的偶数:
# -*- coding:utf-8 -*-
count = 1
while count < 101:
div = count % 2
if div == 0:
print(count)
else:
pass
count = count + 1
求1-2+3-4+5 ... 99的全部数的和:
# -*- coding:utf-8 -*-
count = 1
sum = 0
while count < 100:
div = count % 2
if div == 1:
sum = sum + count
else:
sum = sum - count
count = count + 1
print(sum)
用户登陆(三次错误机会):
# -*- coding:utf-8 -*-counts = 0user_list =  [{'username':'jack', 'password':'123456' },{'username':'tom', 'password':'123456'},              {'username':'jieru', 'password':'123456'},{'username':'xiaogang', 'password':'123456'},]flag = Falsefor item in user_list:    user = input("请输入用户名:")    passwd = input("请输入密码:")    if item['username'] == user and item['password'] == passwd:        flag = True        print("登陆成功")        break    else:        print("登陆失败")        counts = counts + 1    if counts == 3:        print("您已经输错三次,不能再输入了。")        break
相关文章
相关标签/搜索