之前都是本身自學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