0

2**4 is 16..ok,but why answer is not comming as 16.0?

26th Mar 2017, 6:01 PM
Rishi Sharma
Rishi Sharma - avatar
11 Answers
+ 2
Because in every programming language it mostly preferred to converts its value to integer format unless and untill some manual creation is not done to the program Also when the program is compiled its value is send to ram in binary format and then that binary format gets decode and print in the integer format
26th Mar 2017, 6:15 PM
Siddharth Upadhyay
Siddharth Upadhyay - avatar
+ 2
2.0*4.0 is in fact 16.0 .. python doesn't need you to declare things such as integer or double or float. it does a good job handling that for you. when you tell it 2.0 you are telling Python that the number is a float, so when it returns the result, it returns a float
26th Mar 2017, 6:18 PM
LordHill
LordHill - avatar
+ 2
first doesn't change anything. 2.0*4 is 8.0 2*4.0 is 8.0 bringing a float into the mix makes the outcome a float
26th Mar 2017, 6:33 PM
LordHill
LordHill - avatar
+ 1
The answer for 2.0*4.0 will be 8.0 because compiler get to knows that it is dealing with decimal values so 8.0
26th Mar 2017, 6:28 PM
Siddharth Upadhyay
Siddharth Upadhyay - avatar
+ 1
you can ask, or you can try.. you will learn more that way. print(2.0**4) see what it does
26th Mar 2017, 6:29 PM
LordHill
LordHill - avatar
+ 1
Yes 2.0**4 will be 16.0
26th Mar 2017, 6:29 PM
Siddharth Upadhyay
Siddharth Upadhyay - avatar
0
ok..what will be an output for 2.0*4.0 and why?
26th Mar 2017, 6:16 PM
Rishi Sharma
Rishi Sharma - avatar
0
ok thanks guys ..
26th Mar 2017, 6:21 PM
Rishi Sharma
Rishi Sharma - avatar
0
ok..then for 2.0**4 will be 16.0 right?
26th Mar 2017, 6:24 PM
Rishi Sharma
Rishi Sharma - avatar
0
2.0**4 because it usually depends upon your first operand of which it consist by that its response is taken
26th Mar 2017, 6:31 PM
Siddharth Upadhyay
Siddharth Upadhyay - avatar
0
ok am cleared ..introducing float will result float .. Thanks justin and siddharth
26th Mar 2017, 7:26 PM
Rishi Sharma
Rishi Sharma - avatar