#2 – Learn Python with practice – Data types

#2 – Learn Python with practice – Data types

Information and data

In computer science it’s important to understand the difference between data and information, data is unorganized facts that need to be processed. When data is orgnized, structured and/or presented, it is called information. For exemple, your name, age are your data and you’re learning Python is an information.

Strings and integers

In computer science as in real life, each data has its own type for exemple, your age data and your name data haven’t the same type. The first data (age) is an integer, for exemple 20, and your name is a string for exemple Alex.

Go to your terminal and tape python.

Then, write type(« Hello ») and press enter.

You should see something like <class ‘str’>

str is comming from string

Now, write type(20) and you should get something like <class ‘int’>

strings are always surrounded by two quotes like « hello, my name is Adel »

Integers are number without comma (,).

Now, go to your terminal and write type(20.5) and you should get something like <class ‘float’>

20.5 is not an integer, it is a float number !


A character is a string also in Python, but it’s important to understand the difference between characters and strings. String in fact is a set of character. For exemple, ‘c’ is a character and ‘clean’ is a set of characters (‘c’, ‘l’, ‘e’, ‘a’, ‘n’) and it’s so a string.

Go to your terminal and type len(« clean ») and you should get 5.

When we ask the computer to calculate the length of a string, he is only counting the number of characters in that string.


Boolean types are very different from previous types when saw beacause we don’t use them in real life.

Booleans accept only two values : True and False.

Write in your terminal type(True) and you should get something like <class ‘bool’>.

Congralutations ! You learn data types in computer science and how to use the in Python programming language.

Python has untyped variables that means you should not specifty variables types. In the previous chapter, we talked about variable if you remember user_input. We created it without specifying its type unlike many other programming langage like C or Java, we have to specify variable type when we create it.

Your resume : name, age, school, is looking for new job

Create new folder inside python-projects named resume and open your terminal then change directory to that folder you created.

Create new file named main.py inside python-project/resume folder.

print("This program will help you to create awesome resume and find \n new job")
user_name = input("What is your full name ?")
user_age = input("What is your age ?")
user_school = input("What is your school name ?")
user_looking_for_new_job = input("Are you looking for new job ?\n if yes tape 'YES'")

# let's print the user resume

print("Name : ", user_name)
print("age : ", user_age)
print("School : ", user_school)
print("Looking for new job : ", user_looking_for_new_job)

Change variables names, code format as you want to understand more this code, it’s easy but if you didn’t understant, don’t worry you will continue on this code later.

A question for you

I imagine that you don’t understand what means insctructions like len(« hello »), type(« hello »), print(« hello »), input(« what is your name ») ?

len, type, print, input are functions. Functions help us as programmers and that’s what we will see in the next chapter.

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *