Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Python

a=4 b=2 c=2 d=a*b**c**3//2 print(d) Please explain the mathematical logic behind this. I know it prints 512

12th Feb 2019, 9:53 PM
Safina Nganga
Safina Nganga - avatar
5 Answers
+ 2
** is evaluated first, and from right to left; then */ is done. a*(b**(c**3))//2 --> 512
12th Feb 2019, 10:00 PM
HonFu
HonFu - avatar
+ 1
c ** 3 is 8. b ** 8 is 256. a * 256 is 1024. 1042 // 2 is 512. You must have typed something wrong.
12th Feb 2019, 10:05 PM
HonFu
HonFu - avatar
+ 1
haha the program came out right just trying to figure out how to calculate manually and thanks
12th Feb 2019, 10:07 PM
Safina Nganga
Safina Nganga - avatar
0
did that and got some really high number 😕😕😕
12th Feb 2019, 10:03 PM
Safina Nganga
Safina Nganga - avatar
0
Pleasure. :)
12th Feb 2019, 10:10 PM
HonFu
HonFu - avatar