Lecture

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!")
Mission
0 / 1

Write code to print the string codefriends. (Use double or single quotes)

print(
)

Lecture

AI Tutor

Publish

Design

Upload

Notes

Favorites

Help

Code Editor

Run
Generate

Execution Result