Functions in Python (def)
Simple Hello-name function in Python
To execute:
def hello_name(name): return 'Hello ' + name + '!'
To execute:
print(hello_name('Peter'))
The output will be:
Hello Peter!
________ Other examples of functions in Python:def string_times(str,n): return str * nor...def first_last6(nums): if nums([0]) == 6 or nums[-1] == 6: return True else: return Falseor...def sleep_in(weekday,vacation): if weekday == False or vacation == True: return True else: return Falseor (simplified from above)...def sleep_in2(weekday,vacation): if not weekday or vacation: return True else: return Falseor...def first_last6(nums): if nums([0]) == 6 or nums[-1] == 6: return True else: return False
Comments
Post a Comment