摘要: 1 while True : 2 height= None 3 try : 4 height= int(input("请输入高:")) 5 except : 6 pass 7 if type(height) == int : 8 inc_height = 1 9 while inc_height<= height : 10 i=1 11 while i<=inc_height: 12 print( 阅读全文
posted @ 2019-09-17 20:43 fangxs666 阅读(586) 评论(0) 推荐(0) 编辑
摘要: ''' 用户输入长,宽,输出长*宽的长方形,用#输出 ''' #flag = True while True: width= None height= None try : height= int(input("请输入长:")) width= int(input("请输入宽:")) except : pass if type(height) == int and type... 阅读全文
posted @ 2019-09-17 19:45 fangxs666 阅读(320) 评论(0) 推荐(0) 编辑
摘要: while循环格式如下 while 条件: 语句 输出数字1~100 的偶数 #!/bin/python#输入1~100内的偶数num=1while num<=100 : if num % 2==0 : print(num) num+=1 只允许输入数字: 思想:存储输入的数字,通过type来判断是 阅读全文
posted @ 2019-09-17 15:07 fangxs666 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 逻辑与:and 条件1 and 条件2 条件1和条件2必须同时为真,结果为真,其他情况都是假 或:or 条件1 and 条件2 条件1和条件2至少一个条件为真,结果为真,同时为假才是假 取反:not and or not的优先级的相同的 短路原理 条件1 and 条件2:如果条件1为假,条件2就自动 阅读全文
posted @ 2019-09-17 11:11 fangxs666 阅读(131) 评论(0) 推荐(0) 编辑