Last active
December 18, 2015 02:18
-
-
Save razpeitia/5709584 to your computer and use it in GitHub Desktop.
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
def read_numbers(n): | |
numbers = [] | |
for i in range(n): | |
numbers.append(int(raw_input('Number [%d]: ' % i))) | |
return numbers | |
def find_largest(numbers): | |
max_number = max(numbers) | |
return [index for index, number in enumerate(numbers) if number == max_number] | |
def find_numbers_that_ends_with(numbers, digit): | |
return [index for index, number in enumerate(numbers) if (number % 10) == digit] | |
def count_largest(numbers): | |
return numbers.count(max(numbers)) | |
def find_number_with_more_digits_than(numbers, digits): | |
digits -= 1 | |
bound = 10 ** digits | |
return [index for index, number in enumerate(numbers) if (number >= bound) or (number <= -bound)] | |
numbers = read_numbers(10) | |
print "Position of the largest numbers:", find_largest(numbers) | |
print "Position of numbers that ends with 4:", find_numbers_that_ends_with(numbers, 4) | |
print "How many times the largest number is repetead:", count_largest(numbers) | |
print "Position of the numbers that have more than 3 digits:", find_number_with_more_digits_than(numbers, 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment