第一次課內容
?
學習心態及注意事項
信心
謙虛
腳踏實地
多動手
python簡介
代碼量少,簡介,易上手,語法要求不過于嚴格,
Python 庫。
速度慢,
不可加密。
輸出、變量、輸入
數據類型:整數、浮點數、字符串
?
?
?
>>>
?
>>> print("woshi zhazha")
woshi zhazha
>>> print("我是渣渣")
我是渣渣
>>> print("woshi","zhazha")
woshi zhazha
>>> print(1)
1
>>> print(1.5)
1.5
>>> print(-1)
-1
>>> print(4*5)
20
>>> print("dasdsdas",end="0"))
SyntaxError: invalid syntax
>>> print("dasdsdas",end="0")
dasdsdas0
>>> print('''
*
*
???????***
???????***''')
?
*
*
???????***
???????***
>>> print("兩分鐘時間,練習")
兩分鐘時間,練習
>>> print('''
三個引號后,直接回車換行''')
?
三個引號后,直接回車換行
>>> print('注意,括號和引號必須是英文。')
注意,括號和引號必須是英文。
>>> print('單引號雙引號都可以')
單引號雙引號都可以
>>> print('引號內為字符串')
引號內為字符串
>>> print('dasdadadasdada')
dasdadadasdada
>>> a=10
>>> print(a)
10
>>> print('a')
a
>>> print('a=',a)
a= 10
>>> a=10
>>> b=a
>>> a=5
>>> print(a,b)
5 10
>>> print('裝修的來了,大家自己練習一下')
裝修的來了,大家自己練習一下
>>> print('python代碼簡單優雅,讓同學們更注重解決問題的方法本身,而不是糾結于語法。相比其他語言,python更加靈活。')
python代碼簡單優雅,讓同學們更注重解決問題的方法本身,而不是糾結于語法。相比其他語言,python更加靈活。
>>> a=5
>>> a=a+5
>>> print(a)
10
>>> print("程序:0個或多個輸入;")
程序:0個或多個輸入;
>>> print('nvsd'sdf')
??????
SyntaxError: invalid syntax
>>> print("fsasfa'fasfas")
fsasfa'fasfas
>>> print('sasf"dsf')
sasf"dsf
>>> print(' ??\' ?')
???' ?
>>> print('\\\nhhh')
\
hhh
>>> input()
111
'111'
>>> a=input()
111
>>> print(a)
111
>>> a=1
>>> b=1.5
>>> c='aaa'
>>> print(a+c)
Traceback (most recent call last):
??File "<pyshell#77>", line 1, in <module>
????print(a+c)
TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>> print(a+b)
2.5
>>> b=int(b)
>>> print(b)
1
>>> print(int(-1))
-1
>>> print(int(-1.5))
-1
>>> print(2//3)
0
>>> print(-3//4)
-1
>>> print(float(1))
1.0
>>> print(fdubib)
Traceback (most recent call last):
??File "<pyshell#86>", line 1, in <module>
????print(fdubib)
NameError: name 'fdubib' is not defined
>>> fdubib=a
>>> print(fdubib)
1
>>> print('dadas\'dfsd')
dadas'dfsd
>>> print('''
fssdfs
sdfasdas''')
?
fssdfs
sdfasdas
>>> print("大家練習一下這部分內容")
大家練習一下這部分內容
>>> a='我'
>>> print(a)
我
>>> b='是'
>>> print(a+b)
我是
>>> print(4+3)
7
>>> a='4'
>>> b='5'
>>> print(a+b)
45
>>> a=1.5
>>> a=a*a
>>> print(a)
2.25
>>> input()
5
'5'
>>> print('')
?
>>> a=1
>>> a=input('請輸入邊長')
請輸入邊長5
>>> print("請輸入邊長")
請輸入邊長
>>> a=input()
5
>>> print(a*a)
Traceback (most recent call last):
??File "<pyshell#112>", line 1, in <module>
????print(a*a)
TypeError: can't multiply sequence by non-int of type 'str'
>>> a=int(a)
>>> print(a*a)
25
>>> a=int(input())
5
>>> print(a*a)
25
>>> print(int(input())**2)
5
25
>>> print('a'*10)
aaaaaaaaaa
>>> print('a'*10.0)
Traceback (most recent call last):
??File "<pyshell#119>", line 1, in <module>
????print('a'*10.0)
TypeError: can't multiply sequence by non-int of type 'float'
>>> print('woshi zhazha '*100)
>>> a=int(input('請輸入邊長'))
請輸入邊長5
>>> print('面積為',a**2)
面積為 25
>>> print('sdvfsfd')
sdvfsfd
>>> print('''
??????*
??????**
??????***
??????****
??????*****''')
?
??????*
??????**
??????***
??????****
??????*****
>>> print('\n'.join([''.join([('XXXXXXXX'[(x-y)%8]if((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3<=0 else' ')for x in range(-30,30)])for y in range(15,-15,-1)]))
????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????
????????????????XXXXXXXXX ??????????XXXXXXXXX ??????????????
????????????XXXXXXXXXXXXXXXXX ??XXXXXXXXXXXXXXXXX ??????????
??????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ????????
?????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ???????
????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ??????
????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ??????
????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ??????
????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ??????
????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ??????
????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ??????
?????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ???????
??????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ????????
??????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ????????
????????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ??????????
?????????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ???????????
??????????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ????????????
????????????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXX ??????????????
??????????????????XXXXXXXXXXXXXXXXXXXXXXXXX ????????????????
????????????????????XXXXXXXXXXXXXXXXXXXXX ??????????????????
???????????????????????XXXXXXXXXXXXXXX ?????????????????????
??????????????????????????XXXXXXXXX ????????????????????????
?????????????????????????????XXX ???????????????????????????
??????????????????????????????X ????????????????????????????
????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????
>>> print('\n'.join([' '.join(['%d*%d=%2d'%(y,x,x*y) for y in range(1,x+1)]) for x in range(1,10)]))
1*1= 1
1*2= 2 2*2= 4
1*3= 3 2*3= 6 3*3= 9
1*4= 4 2*4= 8 3*4=12 4*4=16
1*5= 5 2*5=10 3*5=15 4*5=20 5*5=25
1*6= 6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36
1*7= 7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49
1*8= 8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64
1*9= 9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81
>>> print('大家要腳踏實地,沒有一蹴而就')
大家要腳踏實地,沒有一蹴而就
>>> print("不要因為其他學長的影響,改變了自己的內心")
不要因為其他學長的影響,改變了自己的內心
>>> print('聽的經驗很重要,但是')
聽的經驗很重要,但是
>>> print('大家不如先搞懂一個小程序,搞懂input,print如何使用,一步一步學')
大家不如先搞懂一個小程序,搞懂input,print如何使用,一步一步學
>>> print('心不要飄,要腳踏實地')
心不要飄,要腳踏實地
>>> print('里面放字符串a=',a)
里面放字符串a= 5
>>> print("謝謝大家,講的不好還請體諒")
謝謝大家,講的不好還請體諒
>>> while 1:print('i love you',end=' ')
?