Last active
April 2, 2017 15:14
-
-
Save igor822/601f9df0fa130025f6e4ce3b5bc8883c 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
import sys | |
num = input() | |
num = int(num) | |
n = 0 | |
for i in range(1000): | |
sys.stdout.write("N[%d] = %d\n" % (i, n)) | |
n += 1 | |
if n >= num: | |
n = 0 |
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
line = input() | |
line_number = int(line) | |
operation = input() | |
def sum(items): | |
total = 0 | |
for x in items: | |
total += x | |
return total | |
def avg(items): | |
total = sum(items) | |
return total / len(items) | |
list_items = [] | |
for i in range(144): | |
inp = input() | |
if inp != '': | |
list_items.append(inp) | |
c = l = 0 | |
matrix = [] | |
line = [] | |
for x in list_items: | |
if c == 12: | |
c = 0 | |
matrix.append(line) | |
line = [] | |
l += 1 | |
if x != '': | |
line.append(float(x)) | |
c += 1 | |
if operation == 'S': | |
print(sum(matrix[line_number])) | |
else: | |
print(avg(matrix[line_number])) |
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
import sys | |
line = input() | |
col_number = int(line) | |
operation = input() | |
c = l = 0 | |
def soma(items): | |
total = 0 | |
for xx in items: | |
total += xx | |
return total | |
def avg(items): | |
total = sum(items) | |
return total / len(items) | |
def get_col(m, n): | |
return [i[n] for i in m] | |
list_items = [] | |
matrix = [] | |
for i in range(144): | |
if c == 12: | |
c = 0 | |
matrix.append(list_items) | |
list_items = [] | |
inp = input() | |
if inp != '': | |
list_items.append(float(inp)) | |
c += 1 | |
matrix.append(list_items) | |
coluna = get_col(matrix, col_number) | |
result = 0 | |
if operation == 'S': | |
result = soma(coluna) | |
else: | |
result = avg(coluna) | |
sys.stdout.write("%.1lf\n" % (result)) |
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
import sys | |
operation = input() | |
c = l = 0 | |
def soma(items): | |
total = 0 | |
for xx in items: | |
total += xx | |
return total | |
def avg(items): | |
total = sum(items) | |
return total / len(items) | |
def get_acima_diagonal(m): | |
items = [] | |
for ix in range(12): | |
for j in range(12): | |
if j > ix: | |
items.append(m[ix][j]) | |
return items | |
list_items = [] | |
matrix = [] | |
for i in range(144): | |
if c == 12: | |
c = 0 | |
matrix.append(list_items) | |
list_items = [] | |
inp = input() | |
if inp != '': | |
list_items.append(float(inp)) | |
c += 1 | |
matrix.append(list_items) | |
diagonal = get_acima_diagonal(matrix) | |
result = 0 | |
if operation == 'S': | |
result = soma(diagonal) | |
else: | |
result = avg(diagonal) | |
sys.stdout.write("%.1f\n" % (result)) |
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
import sys | |
operation = input() | |
c = l = 0 | |
def soma(items): | |
total = 0 | |
for xx in items: | |
total += xx | |
return total | |
def avg(items): | |
total = sum(items) | |
return total / len(items) | |
def get_col(m, n): | |
return [i[n] for i in m] | |
def get_diagonal(m): | |
return [m[i][i] for i in range(12)] | |
def get_acima_diagonal(m): | |
items = [] | |
for ix in range(12): | |
for j in range(12): | |
if ix > j: | |
items.append(m[ix][j]) | |
return items | |
list_items = [] | |
matrix = [] | |
for i in range(144): | |
if c == 12: | |
c = 0 | |
matrix.append(list_items) | |
list_items = [] | |
inp = input() | |
if inp != '': | |
list_items.append(float(inp)) | |
c += 1 | |
matrix.append(list_items) | |
diagonal = get_acima_diagonal(matrix) | |
result = 0 | |
if operation == 'S': | |
result = soma(diagonal) | |
else: | |
result = avg(diagonal) | |
sys.stdout.write("%.1f\n" % (result)) |
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
import sys | |
operation = input() | |
c = l = 0 | |
def soma(items): | |
total = 0 | |
for xx in items: | |
total += xx | |
return total | |
def avg(items): | |
total = sum(items) | |
return total / len(items) | |
def get_col(m, n): | |
return [i[n] for i in m] | |
def get_diagonal(m): | |
return [m[i][i] for i in range(12)] | |
def get_abaixo_diagonal(m): | |
items = [] | |
for ix in range(12): | |
for j in range(12): | |
if j > ix: | |
items.append(m[ix][j]) | |
return items | |
def get_acima_diagonal(m): | |
items = [] | |
for ix in range(12): | |
for j in range(12): | |
if ix > j: | |
items.append(m[ix][j]) | |
return items | |
def get_acima_diagonal_secundaria(m): | |
items = [] | |
for ix in range(12): | |
for j in range(12): | |
if j < (11 - ix): | |
items.append(m[ix][j]) | |
return items | |
list_items = [] | |
matrix = [] | |
for i in range(144): | |
if c == 12: | |
c = 0 | |
matrix.append(list_items) | |
list_items = [] | |
inp = input() | |
if inp != '': | |
list_items.append(float(inp)) | |
c += 1 | |
matrix.append(list_items) | |
diagonal = get_acima_diagonal_secundaria(matrix) | |
result = 0 | |
if operation == 'S': | |
result = soma(diagonal) | |
else: | |
result = avg(diagonal) | |
sys.stdout.write("%.1f\n" % (result)) |
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
import sys | |
operation = input() | |
c = l = 0 | |
def soma(items): | |
total = 0 | |
for xx in items: | |
total += xx | |
return total | |
def avg(items): | |
total = sum(items) | |
return total / len(items) | |
def get_col(m, n): | |
return [i[n] for i in m] | |
def get_diagonal(m): | |
return [m[i][i] for i in range(12)] | |
def get_abaixo_diagonal(m): | |
items = [] | |
for ix in range(12): | |
for j in range(12): | |
if j > ix: | |
items.append(m[ix][j]) | |
return items | |
def get_acima_diagonal(m): | |
items = [] | |
for ix in range(12): | |
for j in range(12): | |
if ix > j: | |
items.append(m[ix][j]) | |
return items | |
def get_acima_diagonal_secundaria(m): | |
items = [] | |
for ix in range(12): | |
for j in range(12): | |
if j < (11 - ix): | |
items.append(m[ix][j]) | |
return items | |
def get_abaixo_diagonal_secundaria(m): | |
items = [] | |
for ix in range(12): | |
for j in range(12): | |
if ix > (11 - j): | |
items.append(m[ix][j]) | |
return items | |
list_items = [] | |
matrix = [] | |
for i in range(144): | |
if c == 12: | |
c = 0 | |
matrix.append(list_items) | |
list_items = [] | |
inp = input() | |
if inp != '': | |
list_items.append(float(inp)) | |
c += 1 | |
matrix.append(list_items) | |
diagonal = get_abaixo_diagonal_secundaria(matrix) | |
result = 0 | |
if operation == 'S': | |
result = soma(diagonal) | |
else: | |
result = avg(diagonal) | |
sys.stdout.write("%.1f\n" % (result)) |
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
num = input() | |
num = int(num) | |
n1 = 0 | |
n2 = 1 | |
n = n1 + n2 | |
print("%d %d" % (n1, n2), end = '') | |
num -= 2 | |
while num > 0: | |
n = n1 + n2 | |
n1 = n2 | |
n2 = n | |
print(" %d" % n, end='') | |
num -= 1 | |
print('') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment