Created
October 1, 2018 07:43
-
-
Save sp90/c3deddc0b18765d8a15a1b7945f202d0 to your computer and use it in GitHub Desktop.
A simple increment function in python
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
# So first we def (define) the function and giving it | |
# the name increment, and adding one parameter | |
# i call that number_to_increment because its | |
# the number that you want to increment by 1 | |
def increment(number_to_increment): | |
# Then we return the number_to_increment + 1 | |
# So if the number_to_increment is 3 it will return 4, if number_to_increment is 500 it will return 501 | |
return number_to_increment + 1 | |
# Here we test the function works | |
# test_one we set number_to_increment = 2 | |
# by doing this | |
test_one = increment(2) | |
# Then we print the result | |
print(test_one) # 3 | |
# | |
# I just do a few tests here to show how it works | |
# | |
test_two = increment(14) | |
# Then we print the result | |
print(test_two) # 15 | |
test_three = increment(10) | |
# Then we print the result | |
print(test_three) # 11 | |
test_four = increment(5000) | |
# Then we print the result | |
print(test_four) # 5001 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment