if (x > y) {
   x = 1;
   y = 2;
}


if x > y:
   x = 1
   y = 2


Wiersz nagłówka:
   Zagnieżdżony blok instrukcji


if (x < y)


if x < y


x = 1;


x = 1


if (x > y) {
   x = 1;
   y = 2;
}


if x > y:
   x = 1
   y = 2


while (x > 0) {


while (x > 0) {
    --------;
    --------;


while (x > 0) {
    --------;
    --------;
           --------;
           --------;


while (x > 0) {
    --------;
    --------;
           --------;
           --------;
--------;
--------;
}


if (x)
   if (y)
      instrukcja1;
else
      instrukcja2;


if x:
   if y:
      instrukcja1
else:
   instrukcja2
      
      
a = 1; b = 2; print a + b                    # Trzy instrukcje w wierszu


mlist = [111,
         222,
         333]


X = (A + B +
     C + D)         


if (A == 1 and
    B == 2 and
    C == 3):
       print 'mielonka' * 3


X = A + B + \
    C + D

    
if x > y: print x


while True:
   reply = raw_input('Wpisz tekst:')
   if reply == 'stop': break
   print reply.upper( )


Wpisz tekst:mielonka
MIELONKA
Wpisz tekst:42
42
Wpisz tekst:stop


>>> reply = '20'
>>> reply ** 2
...pominięto tekst błędu...
TypeError: unsupported operand type(s) for ** or pow( ): 'str' and 'int'


>>> int(reply) ** 2
400

while True:
   reply = raw_input('Wpisz tekst:')
   if reply == 'stop': break
   print int(reply) ** 2
print 'Koniec'


Wpisz tekst:2
4
Wpisz tekst:40
1600
Wpisz tekst:stop
Koniec


Wpisz tekst:xxx
...pominięto tekst błędu...
ValueError: invalid literal for int( ) with base 10: 'xxx'


>>> S = '123'
>>> T = 'xxx'
>>> S.isdigit( ), T.isdigit( )
(True, False)


while True:
   reply = raw_input('Wpisz tekst:')
   if reply == 'stop':
      break
   elif not reply.isdigit( ):
      print 'Niepoprawnie!' * 5
   else:
      print int(reply) ** 2
print 'Koniec'


Wpisz tekst:5
25
Wpisz tekst:xyz
Niepoprawnie!Niepoprawnie!Niepoprawnie!Niepoprawnie!Niepoprawnie!
Wpisz tekst:10
100
Wpisz tekst:stop


while True:
   reply = raw_input('Wpisz tekst:')
   if reply == 'stop': break
   try:
      num = int(reply)
   except:
      print 'Niepoprawnie!' * 5
   else:
      print int(reply) ** 2
print 'Koniec'


while True:
   reply = raw_input('Wpisz tekst:')
   if reply == 'stop':
      break
   elif not reply.isdigit( ):
      print 'Niepoprawnie!' * 5
   else:
   num = int(reply)
   if num < 20:
      print 'mało'
   else:
      print num ** 2
print 'Koniec'


Wpisz tekst:19
mało
Wpisz tekst:20
400
Wpisz tekst:mielonka
Niepoprawnie!Niepoprawnie!Niepoprawnie!Niepoprawnie!Niepoprawnie!
Wpisz tekst:stop
Koniec