ComeçarComece de graça

Identificando código modular em Python

Você aprendeu sobre a separação de responsabilidades e vários motivos pelos quais escrever código modular é importante. Você também viu um exemplo de como o código modular pode ser em Python. Consegue reconhecer, entre as opções abaixo, qual exemplo faz uso de código modular?

A:

def get_higher_value(x, y):
    if x >= y:
         higher_value = x
    else:
         higher_value = y
    return higher_value

higher_value1 = get_higher_value(1, 2)
higher_value2 = get_higher_value(3, 4)

B:

x1 = 1
y1 = 2

if x1 >= y1:
    higher_value = x1
else:
    higher_value = y1

x2 = 1
y2 = 2

if x2 >= y2:
    higher_value = x2
else:
    higher_value = y2

Este exercício faz parte do curso

Conceitos de Paradigmas de Programação

Ver curso

Exercício interativo prático

Transforme a teoria em ação com um de nossos exercícios interativos

Começar o exercício