Computer Science, asked by razimacolaco, 11 months ago

What is the value of triples after the following assignment? triples = [ (x,y,z) for x in range(2,4) for y in range(2,5) for z in range(5,7) if 2*x*y > 3*z ]

Answers

Answered by VIKRANT17565
0

Hope this will help you

Attachments:
Answered by AskewTronics
1

[(2, 4, 5), (3, 3, 5), (3, 4, 5), (3, 4, 6)]  is the value of triples variable in the above question code.

Explanation:

  • If there is not a if condition, then the triple variable holds the "[(2, 2, 5), (2, 2, 6), (2, 3, 5), (2, 3, 6), (2, 4, 5), (2, 4, 6), (3, 2, 5), (3, 2, 6), (3, 3, 5), (3, 3, 6), (3, 4, 5), (3, 4, 6)]" value which is like (x1,y1,z1),(x1,y1,z2) and so on for every x,y,z value, where x1,y1and z1 is the subset of the three defined loop.
  • But the if condition will states that value in which 2*x*y > 3*z for every x,y,z value. The x,y,z value is listed from the three-loop which uses the x,y,z variable.
  • So when any user calculates the above set like "2*x*y > 3*z", then only "[(2, 4, 5), (3, 3, 5), (3, 4, 5), (3, 4, 6)] " will be the output which is the answer.

Learn More :

  • Python : https://brainly.in/question/14689905
Similar questions