U E D R , A S I H C RSS

2학기파이선스터디/if문, for문, while문, 수치형

1. if


~cpp 
if 1:
	<1>
elif 2:
	<2>
else:
	<3>

1 <1> , 2 <2> . <3> else (:) , else if elif . if .
.

~cpp 
>>> order = 'spagetti'
>>> if order == 'spam':
	price = 500
elif order == 'ham':
	price = 700
elif order == 'egg':
	price = 300
elif order == 'spagetti':
	price = 900

, C switch, case 해하 . .

~cpp 
>>> order = 'spagetti'
>>> menu = { 'spam':500, 'ham':700, 'egg':300, 'spagetti':900}
>>> price = menu[order]

2. for


~cpp 
for <> in <>:
	<1>
else:
	<2>

<> . <> , for continue for break <2> 행하 for . else <2> for 행한. 1 10 .

~cpp 
>>> sum = 0
>>> for x in range(1, 11):
	sum = sum + x

>>> print sum
55

for enumerate() (파 2.3 ). enumerate() (, ) 튜플 .

~cpp 
>>> L = [ 'cat', 'dog', 'bird', 'pig', 'spam']
>>> for k, animal in enumerate(L):
...	print k, animal
...
0 cat
1 dog
2 bird
3 pig
4 spam

3. while


~cpp 
while <>: 
	<1>
else:
	<2>
while else , break else 행하 . while continue break while .
1 10 .

~cpp 
>>> count = 1
>>> while count < 11:
	print count
	count = count + 1

4.


10, 8, 16 -2,147,483,648 ~ 2,147,483,647.
0 8, 0x 0X 16.

포함하 e, E 포함하 , C double형 8. 17, 10 -308~308 .

. (long)형 L, l . .

+허 J, j . .

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:13
Processing time 0.0188 sec