• Register
1 vote


I am new in python programming an I have been learning for this some days. As a newbee I am still learning and and I am cofused about some things. My question is “In an if/else statement, if the boolean expression is always false?”


10 7 2
6,060 points

Please log in or register to answer this question.

1 Answer

0 votes


A boolean or bool is a data type that has two possible values: it is either true, or false.
Very often when you write code, you want to perform different actions for different decisions. 
You can use conditional statements in your code to do this. 
Use if to specify a block of code to be executed, if a specified condition is true. Use else to specify a block of code to be executed.
A Boolean variable has only two possible values: true or false. It is common to use Booleans with control statements to determine the flow of a program. In this example, when the boolean value "x" is true, vertical black lines are drawn and when the boolean value "x" is false, horizontal gray lines are drawn

If you want to know more you can go to:


or visit:



11 6 4
34,950 points

Related questions

1 vote
1 answer 36 views
Problem: Let me put it as sim as I can. I have an if statement in my code and it returns a value. Since IF is a boolean statement it should return value whether it’s true or false. So, in my program when a method tests an argument and returns a true or ... as a parameter in a different method inside an IF statement. How should I do that? Any kind of help is appreciated by my side. Thanks.
asked Mar 17, 2020 Gavin 15.3k points
0 votes
1 answer 118 views
Problem: Hello programmers! I am learning to program, and I just got a little confused about boolean values and logical operators. I tried to run the following program: #include<iostream> using namespace std; int main() { bool check = false && true || true; ... program, I got the following output: Condition evaluated to true I am so confused about how this condition evaluates to true. Any help?
asked Dec 18, 2020 Code Learner 6k points
2 votes
1 answer 42 views
Problem: Hello I am a new learner of programming. I&rsquo;ve started with Java programming language. I am learning step by step. I stuck somewhere in an if-else statement. I&rsquo;ve written a basic program for practice purpose but it&rsquo;s not running. I am unable to figure out the ... ==0) System.out.println("a is not present\n"); System.out.println("It is outside of the if-else-if"); } }
asked Mar 26, 2020 Gavin 15.3k points
0 votes
1 answer 189 views
Problem: I am new in programming and stuck in a query, can anyone guide me? Write an expression that evaluates to True if the str associated with s starts with "p"?
asked Feb 17, 2020 maddi86 5.4k points
0 votes
1 answer 45 views
Problem : My function accepts the two arrays of integers and returns true if below conditions are met 1. Arrays have the same length and 2. Each m.element should be less than each n.element of the same index All my test cases are passing except when int[] m = {1, 2, 3} and int[] n = ... = (m[j] < n[j]); for (j = 0; j <= m.length - 1; j++) {} return (sameLength && digitDifference); }
asked Dec 3, 2019 alecxe 7.5k points
0 votes
1 answer 130 views
Problem : I am facing following error with the below query in SQL Server 2012. An expression of non-boolean type specified in a context where a condition is expected, near 'RETURN'. SQL Query: CREATE FUNCTION [dbo].[GetMYPMResources](@UserResourceNo ... JOIN JobTask t ON t.JobTaskNo = m.JobTaskNo WHERE t.TaskManagerNo = @UserResourceNo OR t.AlternateTaskManagerNo = @UserResourceNo ) RETURN END
asked Dec 4, 2019 alecxe 7.5k points
1 vote
1 answer 13 views
Problem: I understand the basic flow of an if-else statement very well. Today I was reading somewhere that it is possible to set a ternary condition using the if-else statement. Let&rsquo;s say, I have a set of conditions like below: if i > 100: x = 2 elif i < 100: x = 1 else: x = 0 How can I put all the conditions and statements within a single line? Could you please help me out?
asked May 31, 2020 adamSw 11.3k points
0 votes
1 answer 4 views
Problem: Can any one explain php if else statement with multiple conditions to me?
asked 6 days ago jyoti goyal 2.1k points
0 votes
1 answer 55 views
1 vote
2 answers 2.2K views
Problem : Currently I am learning Javascript. I know the expression false && anything is short-circuit evaluated to false. According to this information I can certainly expect false && true || true must be evaluate to the false. But this is not the case. I saw ... me in finding correct solution of below question. &ldquo;What is the value of the following expression? true || true && false&rdquo;?
asked Apr 6, 2020 morrisBson 3.2k points