⬅ Previous Topic
Python ConstantsNext Topic ⮕
Python Strings⬅ Previous Topic
Python ConstantsNext Topic ⮕
Python StringsIn Python, data comes in different types. Just like in real life, where you have different kinds of things — like numbers, words, and yes/no answers — Python also needs to know what kind of data you're using.
Python uses data types to decide what you can do with the data. For example, you can add two numbers, but you can’t add a number to a word directly.
Here are some of the most common data types you'll use:
5
, -2
, 100
)3.14
, -0.5
, 2.0
)"Hello"
, "Python"
)number = 10 # int
pi = 3.14 # float
name = "Alice" # str
is_happy = True # bool
You can use the type()
function to see what kind of data something is:
print(type(10)) # <class 'int'>
print(type("Hi")) # <class 'str'>
print(type(3.5)) # <class 'float'>
print(type(False)) # <class 'bool'>
Every value in Python has a type. Understanding these basic data types will help you store, use, and work with information in your programs.
⬅ Previous Topic
Python ConstantsNext Topic ⮕
Python StringsYou can support this website with a contribution of your choice.
When making a contribution, mention your name, and programguru.org in the message. Your name shall be displayed in the sponsors list.