E D R , A S I H C RSS

Python For Statement

Python �� For Statement �� �� �������.

����


�간..����..


결과�� �������.�� ���..���� ������ ��...��감...;;;;

�� 1

게 � ���� �� ���� ��고 ��.

���� hello world���� ���� a ���� C++�� �������게 �� �� ��기 ���. h�� a[0], e �� a[1]... �������� ���.

�� �� ������ 값�� ��� ���� ������ �� C++�� ���고 ���� ��.

����� ��� ���� C++�� ������ C++�� string ����, Java�� String ���� �������� ���� �� ��. -- Leonardong

�� 2

python�� for statement ���� 근������ �������� ��근 ����.

python ��������.
~cpp 
for i in 'helloworld':print i,
for i in [ 'h','e','l','l','o','w','o','r','l','d']:print i,
����과 � ������ ���� ���� ��까��?

���� for ���� ���� ����.
~cpp 
for statement definition

for_stmt  ::=  "for" target_list "in" expression_list ":" suite 
    ["else" ":" suite] 
---
��게 ����, 

for 겟객������(target) in ����(expression_list==sequence):
    ��(expression)
in ������ �� ���� ������.
������ ���� ����과 �������.
{{|
Sequences
These represent finite ordered sets indexed by non-negative numbers. The built-in function len() returns the number of items of a sequence. When the length of a sequence is n, the index set contains the numbers 0, 1, ..., n-1. Item i of sequence a is selected by ai.
...

������ :)

����
����� ������ ���� ������ ����� ��겨�� ���. ������ len()�� ������ �� 갯���� ����. ������ 길�� n, �������� 0..n-1 까�� ������ �����. ������ �� i�� ai�� ������.

... ������ ��� ��...����
|}}
���� ������ 2.3 기���� ����� ���� �� �� ��������.
{{|There are six sequence types: strings, Unicode strings, lists, tuples, buffers, and xrange objects|}}
���� strings �� ���� ��, a[i] �� ��근�� ��������. ������,

for i in 'helloworld': print i,
���� i�� ���������� 'h','e'... �� ����

���� 기������ list ���� ���� ��, a[i] �� ��근�� ��������.
for i in [ 'h','e','l','l','o','w','o','r','l','d']:print i,
�� ���� i� 'h','e'.. �� �����게 ������.

��기까 ����, Python Language Reference���� sequence, for statement�� ���� ���� ������. ����� �������� �� ����������. 그��고 ������ �기�� ���� ���� �� �� 겁����.


C / Java 1.4 ���� �� for ������ ������ ���� �� ������. �������� for�� �� ������� �����, ������. ��, while���� ���� ��기 ��게 �간 고�������� ���� �� ��과����.

C/Java1.4 Python�� for���� � ��� �� ��������. 그��고 ������. C�� for��과 구���기 ���� python�� ��� for���� �� for each ����고 ������. ���� for�� ��고 �기�� ��.

� C++�� ����, C++�� ���� C���� ������ ��고, C������ ��과 � ������ ���������� ��근�� �� ���� �������� ���� 구�� ���������. ������ C++������ STL�� for_each(..) ���� ���� ����� ����� ��기�� ����.

Java 1.5 �� advanced for statement ���� ������ ����� � �������고, C#���� �� ���� ����������. Java 1.5������ ����간 ���� ���� ������ ������, ���� �������� Autoboxing/Unboxing과 �������� �� Template과 � ���� ������고 ��������(?)� 개�� ���������������.

ref : Python Lib ref, Python Language ref, ����
--NeoCoin


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:24:08
Processing time 0.0180 sec