0

Output question f = ((0,))

Hello, completely lost on this one too:(. "f = ((0,)) f = f + 2 * (2,) print f Solution: (0,2,2)" The way I see it, f=0, so 0+2*(2,). But it's not asking for a solution? But even then, shouldn't it be f= 0, 2, 4 (2*2=4)? Thanks for any help.

18th Mar 2019, 10:48 PM
tristach605
tristach605 - avatar
1 Antwort
+ 5
Here f= (0,), it igones extra parentheses if it's empty. Now, + operator between 2 tuples concatenates them and * operator when applied on a tuple, fills the tuple with what it already has, multiple times. ex: a=(1, 2) then, 2*a= (1,2,1,2) In this case, f= f+ 2*(2,) f= (0,) + (2,2) f= (0,2,2)
19th Mar 2019, 12:18 AM
Шащи Ранжан
Шащи Ранжан - avatar