~cpp if 조건식1: <문들1> elif 조건식2: <문들2> else: <문들3>
~cpp >>> order = 'spagetti' >>> if order == 'spam': price = 500 elif order == 'ham': price = 700 elif order == 'egg': price = 300 elif order == 'spagetti': price = 900
~cpp >>> order = 'spagetti' >>> menu = { 'spam':500, 'ham':700, 'egg':300, 'spagetti':900} >>> price = menu[order]
~cpp for <타겟> in <객체>: <문1> else: <문2>
~cpp >>> sum = 0 >>> for x in range(1, 11): sum = sum + x >>> print sum 55
~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
~cpp while <조건식>: <문1> else: <문2>
~cpp >>> count = 1 >>> while count < 11: print count count = count + 1