Basic Data Types

String

You've just learned how to call print() to display some text. The message inside the print() is a string:

'Hello, Buzz Coders!'

String is one of the basic data types in Python. They can be enclosed in either single or double quotation marks.

More string examples:

  • "I can write code" is a string in double quotes
  • 'Python is fun!' is a string in single quotes

Integer

Another basic data type is the integer:

  • 8 is an integer
  • 10588 is another integer
  • -75 is a negative integer

There are no quotation marks around numbers. If you use quotation marks, then it becomes a string that contains digits.

Try it! Print out an integer using print() function, like so:

print(28)

Simple math

We all know that computers are good at math. Here is how we can use Python to calculate numbers:

print(3 + 15)
print(10 - 2)
print(3 * 8)
print(25 / 5)
print((2 + 4) * (10 - 5))

Console results:

18
24
8
5
30

results matching ""

    No results matching ""