Author Archives: Pablo

Lists

– Lists                                                                                                                       @PablO_CVi

Create a program that asks the user for 10 numbers  (floating point). Store those numbers in a list. Show to the user the total, average and standard deviation of those numbers.

Here is my code: https://github.com/PablOCVi/WSQ/blob/master/WSQ10.py

Ability to create Python project in IDE and run inside the IDE

– Ability to create Python project in IDE and run inside the IDE                    @PablO_CVi

For creating a python project in IDE and run inside I used PyCharm.

here is my video.

 

Creation and use of tuples in Python

– Creation and use of tuples in Python                                                            @PablO_CVi

To make easy the explanation of tuples, we can compare them with lists, this lists called tuples have something different, the items that are inside the tuple can not be changed, all the items that are inside are going to stay there as they where typed when the tuple was created. To create a tuple, you just have to type the name of the tuple followed by an equal and then inside parenthesis the items that are going to be inside the tuple separated each one with a comma, like this. Macalana=(dale,a,tu,cuerpo,alegria,macarena,eeeeeeeeee,macarena).

My code: https://github.com/PablOCVi/Mastery/blob/master/Mastery24.py

Creation and use of lists in Python

– Creation and use of lists in Python                                                                @PablO_CVi

To create a list you just have to type a name and in [] the things you want in the list, like this list=[1,6,5,4,] each of the components of the list has to be separated with a comma or they will be recognized as one component, the lists components have numbers, the first one is the number 0, ne next one 1 and like that untill the end, the last component also could be -1, the one before -2 and like that until the first one. to use list this commands has to be known.

list.append(x)

Add an item to the end of the list. Equivalent to a[len(a):] = [x].

list.extend(L)

Extend the list by appending all the items in the given list. Equivalent to a[len(a):] = L.

list.insert(ix)

Insert an item at a given position. The first argument is the index of the element before which to insert, so a.insert(0, x) inserts at the front of the list, and a.insert(len(a), x) is equivalent to a.append(x).

list.remove(x)

Remove the first item from the list whose value is x. It is an error if there is no such item.

list.pop([i])

Remove the item at the given position in the list, and return it. If no index is specified, a.pop() removes and returns the last item in the list. (The square brackets around the i in the method signature denote that the parameter is optional, not that you should type square brackets at that position. You will see this notation frequently in the Python Library Reference.)

list.clear()

Remove all items from the list. Equivalent to del a[:].

list.index(x)

Return the index in the list of the first item whose value is x. It is an error if there is no such item.

list.count(x)

Return the number of times x appears in the list.

list.sort()

Sort the items of the list in place.

list.reverse()

Reverse the elements of the list in place.

list.copy()

Return a shallow copy of the list. Equivalent to a[:].

Source: docs.python.org

My code: https://github.com/PablOCVi/Mastery/blob/master/Mastery23.py

Creation and use of strings in Python

– Creation and use of strings in Python                                                          @PablO_CVi

In phyton, numbers can be called integers or floats, the stings are evrything else, that is considered as a letter or a word and any operation can not be made with strings as it can with integers, to create strings you just have to enter str() , int() for integers and float() for floats, for example:

str(2)+str(5)       pyhton will print ——–>    25

int(2)+int(5)       python will print ——–>     7

here is my code: https://github.com/PablOCVi/Mastery/blob/master/Mastery26.py

Creation and use of ranges in Python

– Creation and use of ranges in Python                                                           @PablO_CVi

Loops can be created with while(You can see here how to make loops with while) and for making loops with ranges, the loop has to  be with for, the next steps must be followed, first write for, then the variable this loop is applying like x, after this goes in range, and in parenthesis the number it will stop, and it will start from 0 (8), another option is to separate with a comma the number you want to start and the number you want it to stop, (0,-8), the last way of using the range is first the numer it is going to start, then separated with a comma the number it is going to end, and sepparated from another comma the number of numbers it will count per time. For example: for i in range (1,sz+1):).

Here is my code: https://github.com/PablOCVi/Mastery/blob/master/Mastery25.py

 

 

 

Use of loops with “for”

– Use of loops with “for”                                                                                   @PablO_CVi

Loops can be created with while(You can see here how to make loops with while) and for making loops with for, the next steps must be followed, first write for, then the variable this loop is applying like x, after this goes in range, and in parenthesis separated with a coma goes the number you want to start and the number you want it to stop, is important to know that this loop always stats from 1, so if it is supposed to start from 0 to a negative it is going to llok like this (0,-8). For example: for x in range (1,100).

Here you can see my code: https://github.com/PablOCVi/Mastery/blob/master/Mastery20.py

Creating Python functions

– Creating Python functions                                                                           @PablO_CVi

To create a function in python you have to know a command it is def, after this you put the name of your function and between it the variables that your function will work, the next step is writing your function, you can use loops and statements, when your function is done, the last step is a return this means that your function is done.

Here is my example code: https://github.com/PablOCVi/Mastery

Calling Python functions

– Calling Python functions                                                                              @PablO_CVi

To call a function, first you have to create one(You can see how to here) then you give the values or ask the user to input value or values to the function to work, the next step is to create a new variable and asign it the function, now you are up to call the function using a print you can print the valiabre you assigned to the function, it will print the result of the function with the numbers you or the user gived.

Here is the code of my example: https://github.com/PablOCVi/Mastery/blob/master/Mastery11.py

Use of comments in Python

 – Use of comments in Python                                                                          @PablO_CVi

Comments are tracks that the programer can add to the code, this won`t change anything in the program, this is just for helping the person that is going to use the code. For adding a comment in Python you just have to put a hashtag like this:   goes your comment. This is how you can add comments to your code in python. Here you can see that this does not modify the program.

Here is the code i used for this program: https://github.com/PablOCVi/Mastery/blob/master/Mastery07.py