top of page

Boolean and None Type in Python

  • Writer: Abhinaw Tripathi
    Abhinaw Tripathi
  • Dec 12, 2017
  • 1 min read

As you know about boolean in other programming language. it is same in python too but with small differences .boolean can be a true or false value.can be declared as either of them. eg: python_course = True java_course = False Simply type a name and assign a value "True" or False . if you have noticed only difference with other programming language is that it starts with Capital letter T for True and Capital letter F for False .interestingly you can convert Boolean value to int and it will give you values 1 and 0 in case of True and False like below. eg: int(python_course) == 1 int (java_course) == 0 str(python_course) == "True" And for string it will simply give textual representation "True" or "False". Now coming to None: it is similar to null like other programming languages. eg: aliens_found = None I find it useful as a place holder variable.Something that I will use later.However there is difference between variable you have defined None and other the variable not defined at all. Simply type k in idle and idle will tell you that k has not been defined but if I assign None to k then it will not give any result but normal for None and also it will not cause any error to show either.So None is called None type. 


Recent Posts

See All
Lambda Functions in Python

So Lambda Functions are just an anonymous function.they are very simple just saves your space and time.they are useful in case of higher ...

 
 
 
Generator Function - Yield Python

So Yield is a keyword.first let's take an example. student = [] def read_file(): try: f=open("students.txt","r") for student in...

 
 
 
Opening,Reading and Writing Python

Let's save our data in a file and read from that file again when we re-open our app. So let's take an example: Let's take an example: ...

 
 
 

Comments


© 2016 by Abhinav Tripathi

  • Facebook Clean Grey
  • Twitter Clean Grey
bottom of page