Skip to content

Commit

Permalink
Improved functions and booleans
Browse files Browse the repository at this point in the history
  • Loading branch information
RenatoLopes771 committed Oct 2, 2021
1 parent a3a69f0 commit 61ba6bd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
29 changes: 29 additions & 0 deletions functions/using-functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,32 @@ def another_function(argument1, argument2):
# Challenge: create a function that takes two integers as arguments and prints the sum.
# call the function and pass the values '1' and '2' to the function
# ------------------------------------------------------------------------------------








# ---------------------------------------------------
# More on functions
# ---------------------------------------------------

# Functions can return something with the 'return' keyword.
def biggestNumber(number1, number2):
maxnumber = max(number1, number2) # The max keyword returns the highest value of all those passed

return maxnumber

# When calling the function, you can use the value returned
oldestPerson = biggestNumber(15, 18)
print("Oldest person:", oldestPerson)

print( biggestNumber(100*0, 1*2) )

# -----------------------------------------------------------------------------------
# Challenge: modify the previous function you create so it returns the value instead.
# create another piece of code that uses the value returned from that function
# ------------------------------------------------------------------------------------

3 changes: 3 additions & 0 deletions variables/booleans.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def Boolean():

Boolean()

# any expression in Python is True or False
print("Basic boolean:", 5 == 5, type(5 == 5))

def Challenge(arg1, arg2, arg3):
print("Challenge:")
print(bool(arg1))
Expand Down

0 comments on commit 61ba6bd

Please sign in to comment.