Articles → Python → Data Types In Python

Data Types In Python






What Are Data Types?





Different Types Of Data


  1. Integer → Any value that is
    1. A number
    2. Positive or negative
    3. Does not contain decimals
  2. PositiveValue = 25
    NegativeValue = -12


  3. Float → Any value that is
    1. A number
    2. Positive or negative
    3. Contains decimal
  4. PositiveValue  = 40000.35
    NegativeValue  = -40000.35


  5. String → It is the sequence of characters
  6. message = "Hello world"




    string_with_single_quotes = 'value 1'
    string_with_double_quotes = "value 2"


  7. Boolean → This data type has 2 permissible values i.e., true, or false
isFlag = True



How To Access String Variables?




message = "Hello"
print(message[0])
print(message[1])
print(message[2])
print(message[3])
print(message[4])




Picture showing the output of accessing the string values in the loop



Escape Characters In The String




  1. \n → Insert a new line between the string
  2. \t → Insert tab space between the string


message1 = "Hello \n world"
message2 = "Hello \t world"

print ("message1 is :", message1)
print ("message2 is :", message2)




Picture showing the output of escape characters in string



Posted By  -  Karan Gupta
 
Posted On  -  Thursday, January 31, 2019
 
Updated On  -  Tuesday, March 26, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250