Skip to main content
Practice

How to Represent Text, Numbers, and True/False in Python

As mentioned earlier, Python provides a variety of data types to manage different kinds of data.

Let's explore the three fundamental data types: String, Number, and Boolean.


String

A string represents text data and consists of a sequence of characters.

Strings are enclosed in double quotes ("") or single quotes (''), and there is no functional difference between them.

String Example
greeting = "Hello there!"

name = 'CodeFriend'

Number

Numeric data types can be divided into integers (int) and floating-point numbers (float).

Number Example
age = 30            # Integer

temperature = 98.6 # Float

Boolean

The Boolean data type can hold only two values: True or False.

Booleans are commonly used in conditional statements and logical operations.

Boolean Example
is_active = True

is_new_user = False

if is_active and is_new_user:
print("Welcome!")
else:
print("See you next time!")

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.