Python Basic Tutorials

Python is a high level general purpose programming language which has a clear/easy learning curve. Python programming language is massively used in various domains like Artificial Intelligence, Data Science, Web Development, Utilities Tools and Scripts and many more

Python is a Programming language, and the default Python we use is written in C programming language which is also referred to as CPython (Python implementation in C). There are various implementation of Python Programming language i.e Jython(in JAVA), Skulpt(in JS) e.t.c

To make everything easy: We refer CPython as Python

Python Booleans

Booleans data types mean the representation of True or False(i.e, 0 or 1)

Any python datatypes have two values: True or False

If a given expression is correct then the expression would return True boolean otherwise False boolean value

Example

>>>2>3
   False

>>>3>2
   True

>>>a=True
>>>print(type(a))
   <class'bool'>

>>>b=False
>>>print(b)
   <class'bool'>

Boolean Arithmetics

In booleans arithmetic, Simply the true or false logic is implemented. With the help of the various boolean operator, boolean expressions are manipulated. Boolean arithmetic is basically the operations between boolean values true and false.

Boolean Operators

  • or
  • and
  • not
  • equivalent
  • non-equivalent
Boolean operation examples

>>>x=True
>>>y=False

>>>x or y
   True

>>>x and y
   False

>>>not x
   False

>>>not y
   False

>>>x==y
   False

>>>a!=y
   True

These expressions can be combined and can be made a compound boolean expression


>>>x=True
>>>y=False

>>>x or (x and y)
   True
>>>y and (x or y)
   False

The bool() function

The bool() function returns two boolean values either True or False depending upon the expression or values given by us

Example

>>>bool(0)
   False
>>>bool(12)
   True
>>>bool('Hi')
   True
>>>bool('') # boolean of empty objects is False
    False