Is there an error in this piece of code

Taiyan Paige 0 Reputation points
2024-11-21T02:16:47.0666667+00:00
a = 16
b = 25
c = 27
if a > b:
    if b > c:
        print ("a is greater than b and b is greater than c")
    else: 
        print ("a is greater than b and less than c")
elif a == b:
    print ("a is equal to b")
else:
    print ("a is less than b")



I believe there might be an error in the examples code. Can anyone inform me if I am correct or not.

it gave three variables to use as an example of how to write conditional code but it seems to be missing a condition. For example if A was greater than B and C but C is greater than B, wouldn't that make the first else statement incorrect. Wouldn't you have to add another condition considering a > c > b or even a = c > b

This question is related to the following Learning Module

Visual Studio Training
Visual Studio Training
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Training: Instruction to develop new skills.
25 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Andreas Sury 0 Reputation points
    2024-11-25T11:00:33.62+00:00
    16 is less than 25
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.