+ 1

What is the output of this code? Please explain your answer too because I didn't understood this question.

tuple_sets=((0,1),(2,3),(4,5)) x = tuple_sets[1][0] y = tuple_sets[2][1] z = y % x print(z)

20th Oct 2019, 10:53 AM
Manju Gurung
Manju Gurung - avatar
4 Respostas
+ 3
tuple_sets=((0,1),(2,3),(4,5)) x = tuple_sets[1][0] # picking 2, element index [1] = (2,3) pos index [0] = 2 y = tuple_sets[2][1] # picking 5, element index [2] = (4,5) pos index [1] = 5 z = y % x # 5%2 is 1 as % is modulo division that returns the division remainder print(z) # output = 1
20th Oct 2019, 10:59 AM
Lothar
Lothar - avatar
+ 3
tuple_sets=( ( 0 , 1 ) , ( 2 , 3 ) , ( 4 , 5 ) ) | | | tuple_sets[0] tuple_sets[1] tuple_sets[2] | | | | | | [0]=0 [1]=1 [0]=2 [1]=3 [0]=4 [1]=5 so, tuple_sets[0] = (0,1) tuple_sets[0][0]= 0 tuple_sets[0][1]=1 tuple_sets[1] = (2,3) tuple_sets[1][0]= 2 tuple_sets[1][1]=3 tuple_sets[2] = (4,5) tuple_sets[2][0]= 4 tuple_sets[2][1]=5 x=tuple_sets[1][0] #2 y=tuple_sets[2][1] #5 z = y % x #5%2 => 1 print(z) #Ouput: 1
20th Oct 2019, 11:34 AM
Sousou
Sousou - avatar
+ 1
Jan Markus , Lothar, Sousou , & wet water ))) ... Now I got it. Thank you so much guys. 🙏
21st Oct 2019, 2:01 PM
Manju Gurung
Manju Gurung - avatar