0

What is the output of this code? >>>x=3,>>>num=17,>>>print(num%x)

2nd Jul 2017, 11:18 AM
Ayoola-popoola Samuel
4 Respuestas
+ 20
The output will be "2" : x has been assigned a value of 3 and num of 17. Now, we divide num by x or 17 by 3, the answer would give the remainder after the division and i.e. 2; % is used for getting the remainder after the division of any two numbers. So : 3 x 5 = 15; 17 - 15 = 2;
2nd Jul 2017, 11:30 AM
Dev
Dev - avatar
0
x = 3 num = 17 print(num % x) #output: 2 3 divides into 17, 5 times (15). There is a remainder of 2.
2nd Jul 2017, 11:28 AM
Sapphire
0
17/3= 5 and 5*3= 15 so 2 more nedeed to be added to get 17 so 17%3 =2
4th Jul 2017, 12:02 AM
Maid Rondic
Maid Rondic - avatar
0
x = 3 num = 17 print(num % x) You first take 17 divide by 3 of which 3 goes into 17, 5times and we will have a remainder of 2. So 2 will be the output of : x = 3 num = 17 print(num % x)
13th Aug 2021, 1:40 PM
Shally Navina