开始几天的基本学习
#! /usr/bin/env.python # _*_ coding: utf-8 _*_ """ start = 1 while True: if start == 7: start += 1 continue print(start) if start == 10: break start += 1 #zheshi wangshang dashen xiede i = 1 while i < 101: print(i) i += 1 if i % 2 == 0: i += 1 # zheshi w ziji xie de (1-100shuchu suoyou jishu ) 自己写的 start = 1 while True: if start%2 == 0: start += 1 continue print(start) if start == 99: break start += 1 # zheshi ziji xiede (1-100shuchusuoyou oushu) start = 1 while True: if start % 2 == 1: start += 1 continue print(start) if start == 100: break start += 1 start = 1 print(start) if start == 100: break start += 1 # start = start + 1 #1-100输出奇数 start = 1 while start < 101: #如果是奇数, 输出 #否则不管 temp = start % 2 #temp是余数,余数=0.偶数,否则,奇数 if temp == 1: print(start) else: pass start += 1 #1-100输出 偶数 start = 1 while start < 101: temp = start % 2 if temp == 0: print(start) else: pass start += 1 #求1-2+3-4+5...99的所有数的和 #思路 #a.1-99所有数的和 start = 1 sum = 0 while start < 100: temp = start % 2 if temp == 1: sum = sum + start else: sum = sum - start start += 1 print(sum) #计算过程 start = 1 sum = 0 s = "" while start < 100: temp = start % 2 if temp == 1: if start == 1: s = str(start) else: s = s + "+" + str(start) sum = sum + start else: s = s + "-" + str(start) sum = sum - start start += 1 print(s) print(sum) """ #用户登录(三次机会重试) #用户登录的实现 #循环三次机会 #错一次见一次 i = 0 while i < 3: user = raw_input("username:") pwd = raw_input("password") if user == "alex" and pwd == "123": print('yes') break else: print('try again') i += 1