Upload
dodiep
View
227
Download
2
Embed Size (px)
Citation preview
�� ��� &��3��Python��%!"3 #�
• �kPythonku b
lbrl ket l b
g l l tl i
g PC
2
(
• 1 :Pythonl l 1• 2 :Pythonl l 2• 3 :Pythonl l 3• 4 : l 1• 5 : l 2• 6 : 1• 7 : 2• 8 : 3• 9 : 4
3
( (
• 10 : 5( hrh )• 11 : 1• 12 : 2• 13 : 3• 14 : 4( hrh )
• 15 : l hr
4
�1� �2� �3� �4� �5�4/11 4/18 4/25 5/2 5/9�6� �7� �8� �9� �10�5/16 5/23 5/30 6/6 6/13
�����11� �12� �13� �14� �15�6/20 6/27 7/4 7/11
����7/18
�����5
• k 30%• 10 14 k 30%• 40%
6
l
•• m l • k w
– http://www.is.kyusan-u.ac.jp/~kamiya/– [ ]→[ �]
– im [email protected]
)
w– for– while
5
• t il lk w f
l c w↓
• k l h g– n l c etc.
• l al l fb c w h g
9
for l n w
for in range( w b ) :
w b
i g
forl l l m• 4 f
Eclipsegm : Enter hg k
w l dbfor
fori inrange(3):print(‘Hello’)
forcountinrange(3):print(‘ w ’,count,’ ’)
HelloHelloHello
w 0w 1w 2
0 64
range�[���]�$[�����]�• for gu b
brl• -1 gl
b m0hgm l g
print(‘---1 ---’)forcountinrange(2):
print(count)
---1 ---01
print(‘---2 ---’)forcountinrange(2,4):
print(count)
---2 ---23
print(‘---3 ---’)forcountinrange(1,6,3):
print(count)
---3 ---14
(. l l
week=[‘Sun’,’Mon’,’Tue’,’Wed’,’Thu’,’Fri’,’Sat’]forday inweek:
print(day)
Sun …Monfor inlistday
1
print(day)
day=Sun
2Sun
SunMonTueWedThuFriSat
SunMonTueWedThuFriSat
Mon
:4 b l
for ku w kuw turtledf
importturtlekame=turtle.Turtle()kame.shape(‘turtle’)
l m
h l• l
k ’arrow’,‘circle’,‘square’,‘triangle’,‘classic’
90 4 5 0 3 c90 4 1029 0 3 c
k 90 4 6 kk 90 4 :45 k
90 4 2 2:4 l
14
• 200l
15
importturtleimporttimekame=turtle.Turtle()kame.shape(‘turtle’)kame.forward(200)kame.right(90)kame.forward(200)kame.right(90)kame.forward(200)kame.right(90)kame.forward(200)kame.right(90)time.sleep(3)
) 5 b
• 1 200l forf
������
16
importturtleimporttimekame=turtle.Turtle()kame.shape('turtle')fori inrange(4):kame.forward(200)kame.right(90)
time.sleep(3)
:4
• for m lu k l dfk h g df w k
• w df m� while w i kudf r
while :
ww
TrueFalse
17
w l dbwhile
i =0while(i <3):print(‘Hello’)i =i+1
count=0while(count<3):print(‘ w ’,count,’ ’)count=count+1
HelloHelloHello
w 0w 1w 2
df b tr
•– 1 6 gl� random– b brknum =random.randint(1,6)
1 6 gl f numk
• w– b num 6g h � num !=6
• w e w w brl– while
ki g gu gb r
19
df b tr
importrandomnum=0whilenum!=6:num=random.randint(1,6)print(‘num=‘,num)
print(‘6 blg ’)
m0num=6 ch while l w
b w 1
num=1num=1num=66 blg
g
• k rf bh b
k dbg h b g
– :passwd– :in_passwd– k
• in_passwd =input(‘ :’)
21
w l dbwhile
passwd =‘aaa’in_passwd =input(‘ :’)whilepasswd !=in_passwd:print(‘ df ’)in_passwd =input(‘ :’)
print(‘ b ’)
h g
• 7k f k rfh b
k db bm g
h b gh– :user– :in_user– k
• in_user =input(‘ :’)23
w l dbwhile
user=’k15te000’# l kpasswd =‘aaa’in_user =input(‘ :’)in_passwd =input(‘ :’)whileuser!=in_user orpassewd !=in_passwd:print(‘ df ’)in_user =input(‘ :’)in_passwd =input(‘ :’)
print(‘ b ’)