Tag Archives: #Mastery24

Mastery 24


TUPLES (tuplas) 

Una Tupla es vista del mismo modo que una lista con la diferencia de que todo el conjunto se encuentra encerrado entre paréntesis en vez de ser corchetes y aparte NO SE PUEDEN MODIFICAR, sin embargo estos también tienen un orden o “posición” determinada.

Así como se ve en la imagen, en las tuplas cada elemento del conjunto también tiene una “posición negativa”, es decir, puedes localizar elementos utilizando números negativos, además que esta vez las posiciones se consideran de derecha a izquierda empezando por el “-1”.

Also on this episode: https://www.youtube.com/watch?v=PyTCm-hqsA4 there was confirmation of #Mastery24 for #TC1017!

Also on this episode: https://www.youtube.com/watch?v=PyTCm-hqsA4 there was confirmation of for !

#Mastery24 Tuples

A tuple is the same thing that a list in python. Click here to learn about lists.
But thiferent from lists a tuple uses the “( )” signs to enclose the group rather than the “[ ]” of the lists.

The main difference it has is that Tuples CAN’T BE MODIFIED, so al the append, erase and replace functions that work with lists Wont work with a touple. Click here to learn more about Touples.

#Mastery24 Tuples

#Mastery24 Tuples

A tuple is the same thing that a list in python. Click here to learn about lists.
But thiferent from lists a tuple uses the “( )” signs to enclose the group rather than the “[ ]” of the lists.

The main difference it has is that Tuples CAN’T BE MODIFIED, so al the append, erase and replace functions that work with lists Wont work with a touple. Click here to learn more about Touples.

#Mastery24 Tuples

#Mastery24 Tuples

A tuple is the same thing that a list in python. Click here to learn about lists.
But thiferent from lists a tuple uses the “( )” signs to enclose the group rather than the “[ ]” of the lists.

The main difference it has is that Tuples CAN’T BE MODIFIED, so al the append, erase and replace functions that work with lists Wont work with a touple. Click here to learn more about Touples.

#Mastery24 Tuples

Uso de ‘tuples’ en python #Mastery24 #TC1014

Uso de ‘tuples’ en python #Mastery24 #TC1014

Creating and using Tuples in Python 3

Tuples are much like lists in Python, for the little exception that they are inmutable, this means, once created you can’t make changes to it.

In order to create a Tuple you type the elements inside parenthesis ( … ) sepparated by a coma, just like lists.

>>>tuple=( 4, 5 , 7)

Hint: When you want to make a one element Tuple you should always put a coma after the element, this way Python won’t think that you only have an extra pair of parenthesis.

>>>tuple_1=(1,)

Since Tuples are inmutable, the methods used to modify them doesn’t exist; methods like append, remove, extend, etc. are no available for Tuples.

You can slice Tuples in order to create a new one that is a section of the one it is generated from. You can make a new Tuple from the slice of one like this:

>>>new_tuple=tuple[1:]

[ 5, 7]

And you can check if a value exists inside a Tuple the same way you do in Lists. 

  • in Tuple

In this way we can check if a certain value exists inside a Tuple, if it exists it will return True, if it doesn’t it returns False

>>> 5 in tuple

True

>>> 9 in tuple

False

  • tuple.index()

This way you can know the index of a certain value inside a Tuple, remember that this returns the index of the first apperance of the value. 

>>>tuple.index(5)

1

Booleans of Tuples

As in Lists, Tuples have the same booleans. Whenever a Tuple has at least one element, whatever the element may contain, it will return True to a boolean expresion. 

Asigning multiple values

One thing about Tuples that I tought was very interesting is the capacity to asign multiple values in one line. Her’es a little example:

>>>tuple=(5,4,6)

>>>(x, y, z)  = tuple

>>> x

5

>>> y

4

>>> z

6

This is my of my

#Mastery24

Mastery24

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:

type arrayName [ arraySize ];
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:

double balance[10];

link:

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

TC1017

Learn To Program 2015-04-06 19:54:00

Mastery24

Un tuple es una secuencia de datos inmutables. Es una secuencia similar a la lista, con la diferencia que los tuples no pueden modificarse y usan parentesis para declararse. Me bastó con leer la siguiente información para comprender su funcionamiento:
https://docs.python.org/3.3/tutorial/datastructures.html
http://www.tutorialspoint.com/python/python_tuples.htm

*******
Mi video:
*******
https://www.youtube.com/watch?v=HPRfJJg_n4I
**********************
Programa hecho en Python:
**********************
https://github.com/A01630323/Learn-To-Program/blob/master/Mastery24.py