Basic data types in Python like integers, floating point numbers, strings, and Booleans.

n Python, there are several built-in data types that you can use to store and manipulate data. These include:

  • Integers (int): Whole numbers, such as 1, 2, or -5.
  • Floating-point numbers (float): Numbers with decimal points, such as 2.5 or -0.1.
  • Strings (str): Sequences of characters, such as “hello” or “python”.
  • Booleans (bool): Logical values that can be either True or False.

Here is an example of how to use these data types in Python:

# Integer
age = 30

# Floating-point number
weight = 75.5

# String
name = "John Doe"

# Boolean
is_happy = True

You can perform various operations on these data types. For example, you can use the + operator to concatenate strings and the * operator to repeat strings, you can use basic mathematical operators such as +, -, *, /, % etc on integers and floating-point numbers. You can also use comparison operators such as >, <, >=, <=, ==, != to compare integers and floating-point numbers.

You can also use various built-in functions to manipulate and get information about these data types, for example, you can use len() to get the length of a string, you can use int(), float() functions to convert data types, you can use str() function to convert any data type to string.

Leave a Reply