without haste but without rest

[python/계프] 1주차 과제 - 가장 차이가 큰 항 구하기 본문

Homework

[python/계프] 1주차 과제 - 가장 차이가 큰 항 구하기

JinungKim 2020. 4. 4. 16:08

가장 차이가 큰 항 구하기

 

import random

def max_value(x, y):
    xlist = [random.randint(x, y) for _ in range(10)]
    ylist = [random.randint(x, y) for _ in range(10)]
    res = []

    print(xlist, ylist, sep='\n', end='\n\n')
    for i, a in enumerate(xlist):
        res.append(abs(a - ylist[i]))

    check = res.index(max(res))
    for i, a in enumerate(xlist):
        if i == check:
            print("( {})".format(xlist[i]), end='\t')
        else:
            print(xlist[i], end='\t')

    print()
    for i, a in enumerate(ylist):
        if i == check:
            print("( {})".format(ylist[i]), end='\t')
        else:
            print(ylist[i], end='\t')

max_value(10, 50)

 

 

Comments