2.12 day9

while count <= 10 :

if n == 7 : #冒号不要忘记

1 #使用while循环输出 1 2 3 4 5 6     8 9 10
2 n = 1
3 while n < 11:
4     if n == 7:
5         pass
6     else :
7         print(n)
8     n = n + 1
9 print('----end----')
 1 #1.输出100以内的所有偶数
 2         """
 3         #自己代码
 4         count = 0
 5         while count < 101:
 6 
 7          count = count + 1
 8          if count % 2 == 0:
 9              print (count)
10 
11         
12         #teacher's 
13         n = 1
14         while n < 101:
15             temp = n % 2
16             if temp == 0:
17                 print(n)
18             else:
19                 pass
20             n = n + 1
21         print ('----end----')
22         """
23 #4.输出1到100所有的和
24 """
25 n = 1
26 s = 0
27 while n < 101:
28     print(n)
29     s = s + n
30     n = n + 1
31 print (s)
32 """
33 
34 
35 #5.求 1-2+3_4+5...99所有数的和
36 #teacher's
37 """
38 n = 1
39 s = 0 
40 
41 while n < 100
42     temp = n % 2
43     if temp == 0 :
44         s = s - n
45     else:
46         s = s + n
47     n = n + 1
48 print (s)
49 
50 #自己
51 n = 1
52 s = 0
53 while n < 101:
54     print(n)
55     if n % 2 == 0
56     n = n * -1
57     s = s + n
58     n = n + 1
59 
60 print (s)
61 """
View Code
总结
 1 day9
 2 
 3 编程语言
 4     高级
 5     低级
 6 
 7 python种类
 8     JavaPython
 9     cPython
10     pypy
11     
12     字节码 和 机器码
13 
14 python程序
15     1.
16         终端:
17             D:pythonpython.exe D:
18         解释器
19         
20     2.文件型
21         #/usr/bin/u/ubv/a python
22         
23         python 1.py
24         
25         ./1.py   加权限
26     
27     3.编码
28         #/usr/bin/u/ubv/a python
29         #-*- coding:utf-8 -*-
30         补充:
31               字节,位
32               unicode utf8 dbk
33               utf8: 3字节
34               gbk:   2字节
35     
36     4.print""37     
38     5.inp input(">>>")
39         
40         ps:
41             >>> hello
42             inp = "hello"
43 
44             >>> 10
45             inp = "10"
46             
47             # 如果将字符串转换成数字   new_inp = int(inp)
48             
49             inp * 10 = 10101010....
50             
51     6.变量名
52     
53         字母
54         数字
55         下划线
56         
57         要求:
58             不能数字开头
59             不能使用关键字
60             建议不要用python内置的。。
61             
62     7.条件语句
63         1.基本
64         2.嵌套
65         3.if   elif  else ...
66         
67     8.while循环
68         while条件:
69             ....
70         
71         print("...")
72         
73         补充:
74             a. while else
75             b. countiue 终止当前循环
76                break 终止所有循环
77             

原文地址:https://www.cnblogs.com/phyllissRyo/p/10367392.html