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



if x > y:
    x = 1
    y = 2



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



if (x) 
     if (y)
          statement1;
else
     statement2;



if x:
     if y:
          statement1
else:
     statement2



a = 1; b = 2; print a + b                # 3 statements on 1 line



mlist = [111,
         222,
         333]



X = (A + B +
     C + D)



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



X = A + B + \
      C + D



if x > y: print x



while True:
    reply = raw_input('Enter text:')
    if reply == 'stop': break
    print reply.upper()



Enter text:spam
SPAM
Enter text:42
42
Enter text:stop



>>> reply = '20'
>>> reply ** 2
error text omitted
TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'



>>> int(reply) ** 2
400



while True:
    reply = raw_input('Enter text:')
    if reply == 'stop': break
    print int(reply) ** 2
print 'Bye'



Enter text:2
4
Enter text:40
1600
Enter text:stop
Bye



Enter text:xxx
error text omitted
ValueError: invalid literal for int() with base 10: 'xxx'



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



while True:
    reply = raw_input('Enter text:')
    if reply == 'stop':
        break
    elif not reply.isdigit():
        print 'Bad!' * 8
    else:
        print int(reply) ** 2
print 'Bye'



Enter text:5
25
Enter text:xyz
Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!
Enter text:10
100
Enter text:stop



while True:
    reply = raw_input('Enter text:')
    if reply == 'stop': break
    try:
        num = int(reply)
    except:
        print 'Bad!' * 8
    else:
        print int(reply) ** 2
print 'Bye'



while True:
    reply = raw_input('Enter text:')
    if reply == 'stop':
        break
    elif not reply.isdigit():
        print 'Bad!' * 8
    else:
        num = int(reply)
        if num < 20:
            print 'low'
        else:
            print num ** 2
print 'Bye'



Enter text:19
low
Enter text:20
400
Enter text:spam
Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!
Enter text:stop
Bye

