Back to PYTHON FUNDAMENTALS

Python Basic Datatypes

Learn about Python’s primary datatypes—integers, floats, booleans, strings—and where each is used in analytics.

9 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.

Ready to continue?

Mark this lesson as complete when you're ready to proceed.

Key moments

  1. Integers and Floats — Numbers are categorized as integers (whole) or floating points (decimals).
  2. Checking Data Type — The built-in type() function verifies the data type of a variable or value.
  3. Type Conversion — int() and float() functions convert values between numeric types.
  4. Boolean Values — The Boolean type holds True or False, which must be capitalized.
  5. Defining Strings — Strings are text values enclosed in single or double quotation marks.
  6. Type Mismatch Error — Python raises an error if you try to combine different types (like int and str) using the + operator.
  7. String Conversion — The str() function converts numeric values into text for concatenation.
  8. Handling Quotes — Use differing outer and inner quotes or the backslash escape character to include quotes within a string.
  9. String Concatenation — The plus sign (+) joins two strings, while a comma in print() separates them with a space.
  10. Printing Multiple Values — Listing values separated by commas without print() displays them as a tuple in parentheses.
PDF notes

Frequently asked questions

Why does int(4.75) result in 4, not 5?

The int() function truncates the decimal part of a float; it does not perform standard mathematical rounding.

Can I use single quotes inside a string defined by single quotes?

Yes, but you must precede the inner single quote with a backslash (\) to escape it, like 'I\'m fine'.

Does Python require me to declare variable types?

No, Python automatically guesses the type of data you are entering, unlike some other programming languages.

What is the difference between using + and using a comma in the print() function?

The + operator concatenates strings without adding spaces; the comma automatically separates printed values with a blank space.

How was this lesson?

Your feedback helps us refine explanations and catch bugs.