Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Training Quiz Unsolved
#1
I'm relatively new to Python, trying to learn. One quiz I am trying to slove contains the following code:
The value of result at the end of code is given 5.25, I don't know why? Where do "True" and "False" come here? I don't understand, can anyone explain? When I run the code, I don't get anything...

x = 20
y = 5
result = (x + True) / (4 - y * False)
Reply
#2
A boolean can be True or False but in binary, it's not stored as 'True or False' but rather a 1 (on) or a 0 (off)
That means:
x + True = 20 + 1 = 21
4 - y * False = 4 - (5 * 0) = 4

21 / 4 = 5.25
Reply
#3
Thank you so much DreamingInsanity!
I am really grateful!
salute!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  QUIZ GUI Form_When admin panel is open, main quiz form is getting freeze Uday 4 745 Aug-25-2023, 08:24 PM
Last Post: deanhystad
  Error doing CV for training and testing datasets Z47 2 988 Aug-17-2022, 08:41 PM
Last Post: Z47
  Clearification on my next 5 lines for def a bot and training it jgaza 0 1,641 Sep-26-2018, 05:13 PM
Last Post: jgaza
  Need Recommendation for Training - Python for WebDev and Dashboards Cory 3 3,440 Apr-24-2018, 09:20 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020