Flash Sale: Flat 70% + Addl. 25% Off on all Courses | Use Coupon DS25 in Checkout | Offer Expires In

  Enroll Now

Boolean Expressions

A boolean expression is either true or false. The following examples use the operator ==, which compares two operands and produces True if they are equal and False otherwise:

1 == 1

It returns True.

2 == 1

It returns False.

True and False are special values that belong to the class bool,

print(type(True))

It returns <class 'bool'>

The == operator is one of the comparison operators; the others are:

x != y               # x is not equal to y
x > y                # x is greater than y
x < y                # x is less than y
x >= y               # x is greater than or equal to y
x <= y               # x is less than or equal to y
x is y               # x is the same as y
x is not y           # x is not the same as y
  • Avoid the mistake of using a single equal sign (=) instead of a double equal sign (==).

  • = is an assignment operator and == is a comparison operator.

  • There is no such thing as =< or =>.

INSTRUCTIONS

Define a function with the name bool_func which take 4 arguments as num1, num2, num3, num4. Inside the function, write statements to check,
1.) if num1 is greater than num2 and store result in exp1 after converting it into str
2.) if num1 is equal to num3 and store result in exp2 after converting it into str
3.) if num2 is less than or equal to num3 and store result in exp3 after converting it into str
4.) if num4 is not equal to num1 and store the result in exp4 after converting it into str
5.) Return the value which is the concatenation of exp1, exp2, exp3, and exp4 respectively.

If you call the function like this: bool_func(1,2,3,4), it should return 'FalseFalseTrueTrue'.


No hints are availble for this assesment

Answer is not availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...