Exemplo n.º 1
0
Write your code below and put the answer into the variable ANSWER.
"""


""" test """
inputFile = open('httpd-access.txt', 'r+')
count = 0
for cheese in inputFile:
    xx = cheese.split()
    zz = len(xx)
    strdd = ''.join(xx[zz-1:])
    if strdd != '-':
        pp = int(strdd)
        pp_string = str(pp)
      #  print(pp_string[:2])
       # print(pp_string[-1:])
        strss = int(pp_string[-1:])
    if strss % 2 == 0:
        count = count + strss


ANSWER = count


# Is the answer as expected?
# When you get stuck - change False to True to get a hint.
print(dbwebb.assertEqual("2.6", ANSWER, True))


dbwebb.exitWithSummary()
Exemplo n.º 2
0
# Is the answer as expected?
# When you get stuck - change False to True to get a hint.
print(dbwebb.assertEqual("5.5", ANSWER, False))
"""
Exercise 5.6 
 
Create a for-loop that goes through the numbers:
67,2,12,28,128,15,90,4,579,450. If the current number is even, you should
add it to a variable and if the current number is odd, you should subtract
it from the variable. Answer with the final result.  

Write your code below and put the answer into the variable ANSWER.
"""

serie = (67, 2, 12, 28, 128, 15, 90, 4, 579, 450)
result30 = 0
for number in serie:
    if number % 2 == 0:
        result30 += number
    else:
        result30 -= number

ANSWER = result30

# Is the answer as expected?
# When you get stuck - change False to True to get a hint.
print(dbwebb.assertEqual("5.6", ANSWER, False))

dbwebb.exitWithSummary()