Archives de catégorie : "Python with practice"

Following the last example (exercice) of the previous course about conditional structures in Python, we would add skills to the user resume. This is our actual program of our resume software : If we wanted to add skills to the resume, we would ask user for his skills and save them as a string. We can imagine something like : Output We can add the user skills in that way but it is not pratical, beacause if we want to add new skill or remove on, it will be a bit difficult and will take time to write our code. Python helps us with Lists, a list is a another type of data or another data structure. In a List we can add elements, iterate them and remove them, check if element is in a list or not … etc. Before starting studying lists, I would like teach you how…

Lire la suite

Following the previous lesson, we were asking how to check if the user has the same age as you for example : If you didn’t understand well indentation in Python, you will understand them right now in this chapter … We can excute some lines of our code with conditions, for example print « We have the same age » only if user’s age is the same us yours. Start by running the following code in your computer : You see ! It prints a is equal to 20 and End of program ! Change the value of a to 21 and run again your program. a is equal to 20 is not printed, because the value of a is 21 and 21 is not equal to 20 ! We can compare variable to variable too : Please answer the following quiz then continue DO NOT RUN THE CODE, TRY TO ANSWER…

Lire la suite

As we saw in the last article, we use functions to do something like print text, count string length, get data type. In fact, Python offers us as any other programming language a large list of functions that we can use to do amazing things. Let’s firstly review functions we talked about in the previous article, type(…). When you write some code lines, that’s a script and it is executed directely when you lunch the program ($ python main.py). type(…) too is a script in fact, wrote somewhere by some developer and everything you need to use that program inside yours is call that function. Inside parenthesis we specify some value called parameter or argument. The argument can be a value (data) or a variable name, for example : The parameter can also be a call for another function, that’s the case with print(type(user_name)), here the argument of print function…

Lire la suite

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…

Lire la suite

Welcome to this first course about learning Python with practice. Learning by practice will let you understand theory behind programming by yourself, you don’t  need teacher to become a programmer.   To start, you need some tools like in real life, we need everytime tools to build something. You will need here just Python installed in your computer, text editor and command line tool (Terminal in Linux OS or CMD on Windows OS). Step #1 : download Python from here. Step #2 : a text editor : You can use a simple text editor like Note on Windows or Gedit on Linux but, I suggest you to download a text editor dedicated to write codes like Visual Studio Code, Sublime Text … etc. (some are 100% free). One you downloaded and installed Python and a text editor, create now a folder named python-projects  inside this folder, create another folder named intro…

Lire la suite

5/5