Created
October 17, 2018 10:27
-
-
Save NeilAlishev/acdcd3fa41509c8665fd830e15516d57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1 | |
def convert(miles): | |
return miles * 1.609 | |
# 2 | |
def area(a, b): | |
return a * b | |
# 3 (первый вариант - с использованием if) | |
def is_even(a): | |
if a % 2 == 0: | |
return True | |
else: | |
return False | |
# 3 (второй вариант - более короткий) | |
def is_even(a): | |
return a % 2 == 0 # тоже возвращается bool |
А в этой функции в чем ошибка не могу понять
def shetnoe(h):
w = h % 2
if w < 0.5:
return h + " число четное "
else:
return h + " число не четное "
ad = shetnoe(h)
NameError Traceback (most recent call last)
in
----> 1 ad = shetnoe(h)
NameError: name 'h' is not defined
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
у меня в # 3 оказалось более сложноватым.
Как говорится:
В красоте милей простота.
— Публий Овидий Назон