provinha 10: gabarito

provinha 10: gabarito

por José Coelho de Pina -
Número de respostas: 0

Questão. Suponha que o Python tenha lido todas as funções a seguir (teclamos F5 no spyder).

def f(x, y):                def g(x, y):                    def h(m):                              
    z = [ [0] * y ] * x         w = [0] * y                     m[0][0] = False   
    return z                    z = []                          print(m)          
                                for i in range(0, x, 1):                          
                                    z += [w]               
                                return z

A seguir está uma transcrição de uma seção do Python Shell. Complete as lacunas com o valor do resultado da expressão correspondente. Se ocorrer um erro, escreva apenas ERRO.

In [1]: x = [[1,'x',True], [2.7,'z',False]]

In [2]: x[-1][1]

Out[2]: False

In [3]: x[2][2]

Out[3]: ERRO (IndexError: list index out of range)

In [4]: x[1:]

Out[4]: [[2.7, 'z', False]]

In [5]: y = x

In [6]: y[1][1] = 4

In [7]: x

Out[7]: [[1, 'x', True], [2.7, 4, False]]

In [8]: y

Out[8]: [[1, 'x', True], [2.7, 4, False]]

In [9]: x = [[1,'x',True], [2.7,'z',False]]

In [10]: y = x

In [11]: x = h( y)

In [12]: x

Out [12]: None

In [13]: y

Out[13]: [[False, 'x', True], [2.7, 'z', False]]

In [14]: x = [[1,'x',True], [2.7,'z',False]]

In [15]: y = x

In [16]: x = g(2,3)

In [17]: x[0][1] = 'oi'

In [18]: x

Out[18]: [[0, 'oi', 0], [0, 'oi', 0]]

In [19]: y

Out[19]: [[1, 'x', True], [2.7, 'z', False]]

In [20]: x = f(2,3)

In [21]: x[1][2] = 3.4

In [22]: x

Out[22]: [[0, 0, 3.4], [0, 0, 3.4]]

right


Comentários?