The Data Types in Python

Helenjoy
3 min readMay 22, 2023

--

The Data Types- Integer, Floating-Point, and String

Keep in mind that expressions are simply values paired with operators that always evaluate to a single value. A data type is a value category, and each value belongs to exactly one data type. The most popular information

“5+2” is and expression with data as 5 ans 2, and the type of the data “5” is integer

The integer (or int) data type represents whole-number values.

Floating-point numbers (or floats) are numbers with a decimal point, such as 3.14.

Note :Even though the value 42 is an integer, the value 42.0 is a floating-point number.

Strings, or strs (pronounced “stirs”), are text values that can be used in Python programmes. Always use single quotation (‘) characters to surround your string (like in ‘Hello’ or ‘Goodbye harsh world!’) so Python knows where the text begins and finishes. A string with no characters in it, ‘’, is known as a blank string or an empty string.

If you ever see the error message SyntaxError: EOL while scanning string literal, you probably forgot the final single quote character at the end of the string, such as in this example:

String Concatenation

When it operates on two integers or floating-point values, + is the addition operator.

When + is applied to two string values, it joins them as the string concatenation operator.

Note : However, if you try to use the + operator on a string and an integer value, Python will not know how to handle this, and it will display an error message

Interesting Fact:The * operator multiplies two integer or floating-point values. But when the * operator is used on one string value and one integer value, it becomes the string replication operator. Enter a string multiplied by a number .

The * operator can be used with only two numeric values (for multiplication), or one string value and one integer value (for string replication). Otherwise, Python will just display an error message,

Have some fun with strings … will continue with variables tomorrow.. see you ..

--

--

Helenjoy

Research aspirant in deep learning based video compression