- 1

Error in output

Hello everyoneâ˜ș I’m new here and I tried to play around print. I tried outputting print(2*3/4^6) and it didn’t work. But before this I printed 2*3 and 6 was displayed. Looking forward for your help

26th Jul 2021, 3:23 AM
Sally Aba
2 Answers
+ 1
Sally Aba print (2*3/4^6) 2*3 calculated to integer 6 2*3/4 calculated to float 1.5 2*3/4^6 raises exception since it calculated as 1.5^6 where 1.5 is float variable and 6 is integer operator ^ expects two integer as operands for exclusive or operation in this print statement it is float and integer so it raises exception. It can be used as bellow print(2*3//4^6) It prints evaluated value as 7 2*3//4 calculated as 1 1^6 calculated as 7 binary representation are 1 -> 0001 6 -> 0110 1^6 -> 0111 Answer is 7 DHANANJAY PATEL
26th Jul 2021, 4:53 AM
DHANANJAY PATEL
DHANANJAY PATEL - avatar
0
Alright thank you very much
31st Jul 2021, 9:03 AM
Sally Aba