Tag Archives: #Mastery24

M24 – Creation and use of arrays in C++

24

Hey everybody! In this Mastery post I just show that I know how to create and use arrays.

You can see the full code here:

https://github.com/juanpsantana/WSQs/blob/master/WSQ10.cpp

Mastery 24

24 1017

Como Hacer un Array.

definir que tipos de variables queremos guardar en el arreglo.

 

ya definida nuestra variable  tenemos que pensar cuantos datos queremos guardar en el arreglo

ya definida la anterior información lo que debemos ahcer es empezar a programarlo, la manera para crear un arreglo es casi la misma para crear otras variables

podemos definir el tipo de variable, antes o al momenento de ingresar cuantos datos queremos poner

despues de definirla nos pondremos a definir cuantos espacios (cajas) queremos que tengan este numero siempre tiene que estar entre “[ ]”

ya definida cuantos datos queremos lo que debemos hacer es ingresarlos, empezando por el lugar 0, los datos se empiezan a ingresar desde el lugar cero por lo tanto si decidimos que va a tener 10 lugares  el ultimo lugar va a ser el lugar 9

y asi es como se trabaja con arreglos y acontinuación mostrare la sintaxis con la cual se usan

 

using namespace std

 

int main ( )

 

{

 

int arreglo [10]; // en este arreglo es un arreglo de enteros llamado “arreglo” y con un numero de espacios de 10

 

arreglo[0]=5; //en este momento estamos diciendo que el primer arreglo o el 0 ya que empieza desde el cero es 5

 

arreglo[9]=45; //y en este ultimo arreglo el 9 ya que como se señalaron 10 espacios y empieza en el 0 el 9 es el ultimo

 

return 0;

 

 

}

#TC1017 #mastery24: Arrays

Hey! This is one of the last masteries tutorials for the course. This time, I explained Arrays. I haven’t practiced much with this topic, so I consulted this page for more info (http://www.cplusplus.com/doc/tutorial/arrays/). Besides, I looked at Eduardo Tostado’s mastery tutorial (thanks a lot!).  So, here’s the link to the PDF:

https://drive.google.com/open?id=0B7w3BFfqL9oQakstc25EajJ2MW8&authuser=0

#Mastery24 #TC1017

Creation and use of arrays in C++:

Les dejo un video adjunto a esta publicación como tutorial para crear y usar los arreglos. link del video abajo:

 

 

YOUTUBE:

 

http://youtu.be/gB9LYXXv9Vo?hd=1

#Mastery24

Un arreglo es un conjunto de elementos del mismo tipo, la cantidad de espacios de un arreglo está definida, y no puede ser modificada como en el caso de los vectores.

Para utilizar arreglos no es necesario incluir ninguna librería, puesto que no pueden ser manipulados ya que no son dinámicos.

Para declarar un arreglo es de la siguiente manera:

TipoDeElementos NombreDelArreglo [Espacios]

Por ejemplo sería:

int numeros[5]

Para explicar mejor lo anterior hice una pp, en la cual hablo detalladamente sobre arreglos, pueden encontrarla en el siguiente link:

https://drive.google.com/file/d/0B-NM4ghaDXBvd016NTJpTlliQ2s/view?usp=sharing

Así mismo hice un ejemplo, el cual muestro en las siguientes imágenes:

En este link puedes encontrar el código mostrado en el ejemplo:

https://drive.google.com/file/d/0B-NM4ghaDXBvYmVORW14OGlvaDA/view?usp=sharing

Finalmente, encontré información útil en este link:

http://www.cplusplus.com/doc/tutorial/arrays/

Espero te haya ayudado a aprender un poco sobre arreglos. ¡Bonito día! 🙂

#mastery24 https://www.youtube.com/watch?v=n8pbyJ_KKgg

Mastery 24 Creation and use of ranges in Python

in this mastery I will write about function range. first what does it do? it generates a list of numbers, which is generally used to iterate over with for loops.

function has two sets of parameters, as follows:

range(stop)

wich it will print numbers beginig from zero to (stop-1). For example:

range(4) == [0,1,2,3]

the other parameters is:

range(start,stop,step)

>start it means in wich number it will start

>stop it means  when is going to stop but like this(stop-1)

>step it means the difference between each number in the sequence

examples of using range:

1.-range(0,11,2) == [0,2,4,6,8,10]

2.-range(3,9)==[3,4,5,6,7,8]

this is a link that its very helpful to understand : http://www.pythoncentral.io/pythons-range-function-explained/

mastery24 Creation and use of tuples in Python

In this mastery I will talk about tuples.A tuple is a sequence of immutable Python objects, is like lists, but they have on especially diference, that ones yu create a tuple you can not modify but in lits you can. Also the sintax of tuples are parentheses and lists use square brackets.for example:

tuple1=(“efrain”,”duarte”,”lopez”,20)

you can write strings,numbers is just like lists.

be careful when you just write one thing inside a tuple you have to write it like this:

tuple2=(“ice”,) ——> such is just one thing you have to add a comma to the end

To acces values in tuples  you have to use square brackets.for example:

tuple1=(“efrain”,”duarte”,”lopez”,20)

print tuple[0]——–>the result will be “efrain”

print tuple[0:2]—–>the result will be [“efrain”,”duarte”,”lopez”]

this is counting beging form 0.

You cant modify a tuple but you can create a new tuple with other tuples like this:

tuple3=tuple1+tuple2

tuple3 will be>>>(efrain”,”duarte”,”lopez”,20,”ice”)

Also the tuples respond to the + and * operators much like strings, and this operations will create a new tuple not just strings .For example the basic tuples operations:

tuple4=(1,2,3,4)

print  lent(tuple4)——>resutl= 4

also we can use Concatenation,Repetition,Iteration.

an important point is that we can modify a list inside a tuple, but the tuple we can n ever touch it.

for more information here is a link its very helpful:

http://www.tutorialspoint.com/python/python_tuples.htm

Mastery 24. Creation and use of tuples in Python

In this post I will explain you what tuples are and how to use them.

If we remember from an old post, we saw that we could group items by using lists. Tuples are just like lists, but the main difference is that once you had created a Tuple, you can not modify it, as we could with lists.

The syntax of a Tuple, different from lists where we used brackets, is the following:

     Tuple=(item1,item2,item3,itemN)

Where item1, item2, item3 and itemN can take any value, it doesn’t matter if it is a string, integer number, or even a list or another tuple, etc.

We can refer to values of a tuple as we refer to values of a list. The syntax is the following:

>>Tuple[2]

item3

Where 2 referes to the third item because it starts counting from 0.

 

We may not be able to modify Tuples but we can always modify a list inside the tuple, as soon as we dont wanted to put up any other value instead of the list itself.

 

Creation and use of tuples in Python

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 between parenthesis the items that are going to be inside the tuple, separated each one with a comma and between quotation marks, for example: name = (“Jorge”, “Padilla”)