Last active
December 17, 2019 01:49
-
-
Save lfalanga/9bac3dcec9c1e75862b948215844a2eb 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
# Example 1 | |
def biggest_number(*args): | |
print max(args) | |
return max(args) | |
def smallest_number(*args): | |
print min(args) | |
return min(args) | |
def distance_from_zero(arg): | |
print abs(arg) | |
return abs(arg) | |
biggest_number(-10, -5, 5, 10) | |
smallest_number(-10, -5, 5, 10) | |
distance_from_zero(-10) | |
# Example 2 | |
maximum = max(0.1,0.01,0.001) | |
print maximum | |
# Example 3 | |
minimum = min(0.1,0.01,0.001) | |
print minimum | |
# Example 4 | |
absolute = abs(42) | |
print absolute | |
# Example 5: Returns the type of the data it receives as an argument | |
print type(42) | |
print type(4.2) | |
print type('spam') | |
# Example 6 | |
def distance_from_zero(n): | |
if type(n) == int or type(n) == float: | |
return abs(n) | |
else: | |
return 'Nope' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment