摘要: #求1-100的所有数的和 n = 1 s = 0 while n < 101: s = s + n n = n + 1 print(s) """ #求1-2+3-4+5...99的所有数的和 n = 1 s = 0 # s是之前所有数的总和 while n < 100: temp = n % 2 if temp == 0: ... 阅读全文
posted @ 2018-07-14 17:31 史博洋 阅读(5373) 评论(0) 推荐(0)
摘要: #输出1-100的所有奇数 n = 1 while n < 101: temp = n % 2 if temp == 0: pass else: print(n) n = n + 1 print('----end----') #输出1-100的所有偶数 n = 1 while n < 101: t... 阅读全文
posted @ 2018-07-14 16:43 史博洋 阅读(1996) 评论(0) 推荐(0)
摘要: count = 0 while count < 10: if count == 6: pass else: print (count + 1) count = (count + 1) print('----end----') 阅读全文
posted @ 2018-07-14 16:32 史博洋 阅读(424) 评论(0) 推荐(0)
摘要: # if嵌套用法 if 1 == 1 : if 2 == 3: print("欢迎离开") print("欢迎滚出") else: print('再见') else: print("欢迎来到python世界") 阅读全文
posted @ 2018-07-14 16:27 史博洋 阅读(269) 评论(0) 推荐(0)
摘要: # if多个条件 inp = input('1:') if inp == "2": print('3') elif inp == "4": print('5') elif inp == "6": print('7') elif inp == "8": print('9') else: print('10') print('辞职吧,追求自己的理想... 阅读全文
posted @ 2018-07-14 16:23 史博洋 阅读(827) 评论(0) 推荐(0)