Tag Archives: #Mastery24

MASTERY 24 Creation and use of tuples in Python

CREACIÓN Y USO DE TUPLES

Un “tuple” es como una lista que contiene elementos de cualquier valor y tipo. La principal diferencia entre un “tuple” y una lista es que los “tuples” no son mutables, es decir, no se pueden modificar a la hora de correr el programa. Para diferencia de un “tuple” y una lista visualmente es el uso de paréntesis o “()”. Bueno, de hecho, no se usa mucho los paréntesis; se puede utilizar solo paréntesis y una coma. Otra forma de crear un tiple es utilizar el comando “tuple” y paréntesis. Utilizaremos la mastery anterior
MASTERY 24  Creation and use of tuples in Python
Voy a modificar la primera línea sustituyendo los corchetes con paréntesis:
MASTERY 24  Creation and use of tuples in Python
Vemos que en la línea 3 se quiere sustituir la posición número 1 de la lista “sel” de un 8 a un 3. Intentamos hacer esto con un “tuple” y esto nos mostrará en el output:

MASTERY 24  Creation and use of tuples in Python
Los tupes tienen varias funciones. Uno sería el uso del comando “divmod”. Este toma 2 argumentos y los regresa con 2 valores diferentes que serían el cociente y el residuo. Aquí un ejemplo:
MASTERY 24  Creation and use of tuples in Python
Otra función sería el “zip” con listas. Tenemos 2 variables: una con “tuple” y otra con una lista. Juntamos esto con “zip” y esto nos dará: 
MASTERY 24  Creation and use of tuples in Python

MASTERY 24 Creation and use of tuples in Python

CREACIÓN Y USO DE TUPLES

Un “tuple” es como una lista que contiene elementos de cualquier valor y tipo. La principal diferencia entre un “tuple” y una lista es que los “tuples” no son mutables, es decir, no se pueden modificar a la hora de correr el programa. Para diferencia de un “tuple” y una lista visualmente es el uso de paréntesis o “()”. Bueno, de hecho, no se usa mucho los paréntesis; se puede utilizar solo paréntesis y una coma. Otra forma de crear un tiple es utilizar el comando “tuple” y paréntesis. Utilizaremos la mastery anterior
MASTERY 24  Creation and use of tuples in Python
Voy a modificar la primera línea sustituyendo los corchetes con paréntesis:
MASTERY 24  Creation and use of tuples in Python
Vemos que en la línea 3 se quiere sustituir la posición número 1 de la lista “sel” de un 8 a un 3. Intentamos hacer esto con un “tuple” y esto nos mostrará en el output:

MASTERY 24  Creation and use of tuples in Python
Los tupes tienen varias funciones. Uno sería el uso del comando “divmod”. Este toma 2 argumentos y los regresa con 2 valores diferentes que serían el cociente y el residuo. Aquí un ejemplo:
MASTERY 24  Creation and use of tuples in Python
Otra función sería el “zip” con listas. Tenemos 2 variables: una con “tuple” y otra con una lista. Juntamos esto con “zip” y esto nos dará: 
MASTERY 24  Creation and use of tuples in Python

MASTERY 24 Creation and use of tuples in Python

CREACIÓN Y USO DE TUPLES

Un “tuple” es como una lista que contiene elementos de cualquier valor y tipo. La principal diferencia entre un “tuple” y una lista es que los “tuples” no son mutables, es decir, no se pueden modificar a la hora de correr el programa. Para diferencia de un “tuple” y una lista visualmente es el uso de paréntesis o “()”. Bueno, de hecho, no se usa mucho los paréntesis; se puede utilizar solo paréntesis y una coma. Otra forma de crear un tiple es utilizar el comando “tuple” y paréntesis. Utilizaremos la mastery anterior
MASTERY 24  Creation and use of tuples in Python
Voy a modificar la primera línea sustituyendo los corchetes con paréntesis:
MASTERY 24  Creation and use of tuples in Python
Vemos que en la línea 3 se quiere sustituir la posición número 1 de la lista “sel” de un 8 a un 3. Intentamos hacer esto con un “tuple” y esto nos mostrará en el output:

MASTERY 24  Creation and use of tuples in Python
Los tupes tienen varias funciones. Uno sería el uso del comando “divmod”. Este toma 2 argumentos y los regresa con 2 valores diferentes que serían el cociente y el residuo. Aquí un ejemplo:
MASTERY 24  Creation and use of tuples in Python
Otra función sería el “zip” con listas. Tenemos 2 variables: una con “tuple” y otra con una lista. Juntamos esto con “zip” y esto nos dará: 
MASTERY 24  Creation and use of tuples in Python

#mastery24 #TC1017

24 1017

Creation and use of vectors in C++

C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.

Instead of declaring individual variables, such as number0, number1, …, and number99, you declare one array variable such as numbers and use numbers[0], numbers[1], and …, numbers[99] to represent individual variables. A specific element in an array is accessed by an index.

All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.

Declaring Arrays:

To declare an array in C++, the programmer specifies the type of the elements and the number of elements required by an array as follows:

This is called a single-dimension array. The arraySize must be an integer constant greater than zero and type can be any valid C++ data type. For example, to declare a 10-element array called balance of type double, use this statement:

 

Mastery 24

24 1017

here a link useful for basic use of arrays

https://www.youtube.com/watch?v=dIIQ8rTMV8E

Creation and use of arrays in C++

Hey here’s my 24 on arrays, I hope you like it.

https://www.youtube.com/watch?v=jLOylYuWtgA

1017

Creation and use of tuples in Python

AQUI LES DEJO EL LINK DEL VIDEO DONDE EXPLICO 

https://www.dropbox.com/s/pwg4ik3utjrpu57/Tuple%20Mastery%2024.avi?dl=0

24

1014

Mastery 24

Creation and use of arrays in C++

C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.

Instead of declaring individual variables, such as number0, number1, …, and number99, you declare one array variable such as numbers and use numbers[0], numbers[1], and …, numbers[99] to represent individual variables. A specific element in an array is accessed by an index.

All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.

Declaring Arrays:

To declare an array in C++, the programmer specifies the type of the elements and the number of elements required by an array as follows:

This is called a single-dimension array. The arraySize must be an integer constant greater than zero and type can be any valid C++ data type. For example, to declare a 10-element array called balance of type double, use this statement:

Initializing Arrays:

You can initialize C++ array elements either one by one or using a single statement as follows:

The number of values between braces { } can not be larger than the number of elements that we declare for the array between square brackets [ ]. Following is an example to assign a single element of the array:

If you omit the size of the array, an array just big enough to hold the initialization is created. Therefore, if you write:

You will create exactly the same array as you did in the previous example.

The above statement assigns element number 5th in the array a value of 50.0. Array with 4th index will be 5th, i.e., last element because all arrays have 0 as the index of their first element which is also called base index. Following is the pictorial representaion of the same array we discussed above:

Mastery 24

Credits:

http://www.tutorialspoint.com/cplusplus/cpp_arrays.htm

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

 

1017 24

Mastery 24

Hey everyone here is my video tutorial on Arrays! This is a long video due to the fact that arrays are a complicated format, but after watching my video you will be able to use it like nothing! 

https://www.youtube.com/watch?v=FJSntoVE3FE

1017
24

Creation and use of arrays in C++ #Mastery24

Arreglos 

Podemos relacionas los arreglos con cajas, estas cajas a la vez pueden tener dentro mas cajas chicas y en cada caja se guarda un dato. 

Esa es la utilidad que tienen los arreglos, supongamos que tenemos cierto numero de estudiantes, por ejemplo 20, y queremos crear una variable para la calificacion de cada uno, tardariamos demasiado en crear 20 variables diferentes para cada uno; por lo que la solucion mas practica seria crear un arreglo para las 20 variables. Como antes explicamos la caja grande seria el arreglo, las cajas mas chicas estan representadas por la variable de la calificacion y dentro de esta  variable podemos ingresar un dato.

Ahora que entendimos que es un arreglo y cuando podemos usarlos, veremos como crear uno:

1- Elegir el tipo de variables a guardar en nuestro arreglo.

2- Definir el numero de datos que necesitamos guardar.

3- Ahora tenemos que comenzar a programar el codigo, esto es sencillo, muy parecido a crear variables.

4- Cuando ya tengamos los datos necesarios de los pasos anteriores debemos tomar en cuenta que el numero de espacios siempre tiene que estar entre corchetes “[ ]”.

5- Hay que tomar en cuenta que a la hora de ingresar el numero de espacios, estos se cuentan desde el 0, por lo que si queremos ingresar los 20 espacios, dentro de los corchetes tenemos que escribir 19.

Ejemplo:


using namespace std
int main ( )
{
int arreglo [19];         // En este arregloe las variables son tipo int y cuenta con 20 espacios

arreglo[0]=80;          // Aqui le estamos asignando a la casilla numero 0 el valor de 80

arreglo[19]=100;        //Finalmente asignamos el valor del espacio 19, ultimo espacio dentro de                                                        nuestro arreglo 

return 0;

 

De esta forma podemos crear arreglos, y para hacer mas eficiente la manera de ingresar los datos se recomienda usar algun loop. Ya que dentro de los corchetes del arreglo se pueden ingresar variables como en el siguiente ejemplo: arreglo[alumnos]

 

1017 24