首页 > 代码库 > 开始几天的基本学习
开始几天的基本学习
#! /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
开始几天的基本学习
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。