Friday, August 06, 2021

Day 4 of #30daysofML Learning

Below is my learning for Day 4 of #30daysofML

The datatype for boolean in python is 'bool'

Boolean operators are used for comparison

3.0 == 3

'3'== 3

Comparison operators can be combined with the arithmetic operators 

Remember to use == instead of = when making comparisons.

Booleans are most useful when combined with conditional statements like if then else statement

Python has a functions as below:

  • int() function  which turns things into ints, 
  • float() functon which turns things into floats, 
  • bool() function which turns things into bools.
  • Calling bool() on an integer returns False if it’s equal to 0 and True otherwise. 
  • int(True) is 1, and int(False) is 0.

We can use non-boolean objects in if conditions and other places where a boolean would be expected. Python will implicitly treat them as their corresponding boolean value:

Here is the order of precedence of operators in Python


Operator

Description

(expressions...),

[expressions...]{key: value...}{expressions...}

Binding or parenthesized expression, list display, dictionary display, set display

x[index]x[index:index]x(arguments...)x.attribute

Subscription, slicing, call, attribute reference

await x

Await expression

**

Exponentiation 5

+x-x~x

Positive, negative, bitwise NOT

*@///%

Multiplication, matrix multiplication, division, floor division, remainder 6

+-

Addition and subtraction

<<>>

Shifts

&

Bitwise AND

^

Bitwise XOR

|

Bitwise OR

innot inisis not<<=>>=!===

Comparisons, including membership tests and identity tests

not x

Boolean NOT

and

Boolean AND

or

Boolean OR

if – else

Conditional expression

lambda

Lambda expression

:=

Assignment expression


No comments:

Free Power BI Classes for Week 7 (Last)

Just completed the last class of the F ree  P ower BI  classes of this series.  Today we have covered Adding a canvas background Adding Imag...