Basic Types in Python

This article deals with the basic data types of Python. Every value in Python has a datatype. Since everything is an object in Python programming, data types are actually classes and variables are instance (object) of these classes. In soccer there are different types of players as well. Furthermore, the skillsets of the players differ so that the coach uses them when he needs them. You do the same in Python, you need the right data type to be able to code the way you want it.

Some of the important types are listed below:

Data types:

  • int (integer, whole numbers)
  • float (floating point numbers, decimal numbers)
  • complex
  • str (strings)
  • bool (truth values)
  • tuple
  • list
  • set
  • dictionary

How to use them in Python? We will deal with int, floats, lists, tuples & strings

Most important points here:
– You can get the type of a variable with the first print statement (#Showing which type a variable
has)
– A list starts counting at zero
– With the print statement you can ask for certain elements in the list or an intervall of elements
– The difference between a list and a tuple is that the order of the tuples can’t be changed
For Strings it can be kind of useless to ask for the position of the letter, but I wanted to show it to you here

#mastery04 #mastery05

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s