Python 4.1: The "for" loop
We will continue with our code here we will see the for loop for that I will comment this and if I restart my code nothing is displayed nothing happens everything is ok here we will do the for loop well through the for loop I'm going to write a function that displays on the screen the numbers 1 to 10 for i in range parenthesis zero good to say from 1 to 10 an 11 colon print i I launch the code you will see it starts well 1 2 3 4 5 until 10 the function range is a function that allows to return the numbers according to the interval here the 1 is inclusive in the 11 and exclusive that is if I put for example zero and here I put 5 you will see on the screen 5 times 1 2 3 up to 4 but it doesn't display the 5 because the 5 is exclusive and the 0 is inclusive well to improve our code here we are going to ask the age of 3 persons I'm going to do the name equals person concatenation str plus forgiveness str i plus one and age equals ask for the age of name and then we display name comma age I throw back person 1 what's your no? 20 you see that is displayed directly on the screen you are called person 1 1 year next year you will have you are baby person 2 what is your age I will put 17 that says you you call person 2 you are 17 years old I will have 18 years you are almost eaten I'll put 65 for person 3 you are person 3 you are 65 next year you will be 66, you are senior, so the code works perfectly well here I'm going to declare a constant it's true that constants don't exist but to remedy that we write a variable in capital letters so I'm going to put personal number for person equal to three this is going to make our code more dynamic so we want to modify the number of people we can come and modify at this level been added 4, 14 and so on so that facilitates the improvement of the code if I write this and I have person 1, 12 person 2, 2 years person 3 you see that our code works absolutely and we say to you very soon for a next video on the optional parameters and the numbers with decimal point.