Created
May 2, 2017 09:46
-
-
Save ehedaoo/f4a06df410a02eef25ee6e48dab26fe9 to your computer and use it in GitHub Desktop.
Write a Python program to get the largest number from a list.
Using function
This file contains 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
# Write a Python program to get the largest number from a list. | |
# Using function | |
# a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] | |
def max_num(a): | |
flag = 0 | |
for i in a: | |
if i > flag: | |
flag = i | |
return flag | |
a = [ 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 99, 101] | |
print(max_num(a)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment