Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Data Types | Basic Syntax
Introduction to Python with Cursor

bookData Types

In Python, every value has a type that defines how it behaves, interacts with other values, and which operations are allowed. Understanding data types is fundamental for writing predictable and reliable code.

Python has three common built-in types: numbers (integers and floating-point), strings, and booleans.

Numeric Types

Python represents numbers with two main types:

  • int for integers like 5, -12, or 0 (without decimals);
  • float for decimal numbers like 3.14, 0.0, or -7.5.

Python automatically assigns the correct type based on how the number is written. These types are used in arithmetic, comparisons, and other operations with quantities.

String

A string is a data type for text β€” a sequence of characters such as letters, symbols, or spaces. They are written inside quotes, for example "Hello" or 'world'. Everything inside the quotes is treated as one string, including spaces and punctuation.

Strings are widely used for messages, names, input, or file data. They can be combined, repeated, and processed with functions and operators.

Boolean

A boolean is a data type with only two values: True or False. It's used to express conditions, like whether something is correct, available, or finished. In Python, booleans are written with capitalized first letters.

They are also the result of comparisons β€” for example, 5 > 3 gives True. Booleans are essential for decision-making and controlling program flow.

Checking the Type

Python assigns types automatically, but you can verify them with the type() function. It takes a value and returns its type, such as int, float, str, or bool.

This is helpful for debugging, learning, or confirming how a value behaves.

Summary

  • Python has built-in data types to represent numbers (int, float), text (str), and logical values (bool);
  • These types control how values behave and interact with each other;
  • You can use the type() function to inspect any value and understand how Python sees it.
question mark

What is the data type of True in Python?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 3

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Awesome!

Completion rate improved to 5

bookData Types

Swipe to show menu

In Python, every value has a type that defines how it behaves, interacts with other values, and which operations are allowed. Understanding data types is fundamental for writing predictable and reliable code.

Python has three common built-in types: numbers (integers and floating-point), strings, and booleans.

Numeric Types

Python represents numbers with two main types:

  • int for integers like 5, -12, or 0 (without decimals);
  • float for decimal numbers like 3.14, 0.0, or -7.5.

Python automatically assigns the correct type based on how the number is written. These types are used in arithmetic, comparisons, and other operations with quantities.

String

A string is a data type for text β€” a sequence of characters such as letters, symbols, or spaces. They are written inside quotes, for example "Hello" or 'world'. Everything inside the quotes is treated as one string, including spaces and punctuation.

Strings are widely used for messages, names, input, or file data. They can be combined, repeated, and processed with functions and operators.

Boolean

A boolean is a data type with only two values: True or False. It's used to express conditions, like whether something is correct, available, or finished. In Python, booleans are written with capitalized first letters.

They are also the result of comparisons β€” for example, 5 > 3 gives True. Booleans are essential for decision-making and controlling program flow.

Checking the Type

Python assigns types automatically, but you can verify them with the type() function. It takes a value and returns its type, such as int, float, str, or bool.

This is helpful for debugging, learning, or confirming how a value behaves.

Summary

  • Python has built-in data types to represent numbers (int, float), text (str), and logical values (bool);
  • These types control how values behave and interact with each other;
  • You can use the type() function to inspect any value and understand how Python sees it.
question mark

What is the data type of True in Python?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 3
some-alt