Lab2

#!/usr/bin/env python

__author__ = 'rmuhamedgaliev'
__email__ = 'rinat.muhamedgaliev@gmail.com'

def task_21():
    A1 = read_coordinates(1)
    A2 = read_coordinates(2)
    A3 = read_coordinates(3)
    A4 = read_coordinates(4)
    check_head_paralellogramm(A1, A2, A3, A4)

def read_coordinates(number_of_coordinate):
    print 'Input coordinates A{0} point'.format(number_of_coordinate)
    x = raw_input("Input x coordinate: \t")
    check_number(x)
    y = raw_input("Input y coordinate: \t")
    check_number(y)
    return {'x{0}'.format(number_of_coordinate): float(x), 'y{0}'.format(number_of_coordinate): float(y)}

def check_head_paralellogramm(A1, A2, A3, A4):
    if not (A1['y1'] == A4['y4']) or not (A2['y2'] == A3['y3']) or not (A2['x2'] - A1['x1'] == A3['x3'] - A4['x4']):
        print "Normal paralellogram"
    else:
        print "Wrong coordinates of paralellogramm"


def check_number(data):
    try:
        if "." in data:
            float(data)
        else:
            int(data)
    except ValueError:
        print 'Wrong input data! Put only numbers.'
        exit(1)

if __name__ == '__main__':
    tasks = [
        "2.1", "2.2", "2.3", "2.4", "2.5"
    ]
    task = raw_input("Select number of task: {0}\t".format(tasks))
    if task == "2.1":
        task_21()
    else:
        print "Wrong task number"