Tag Archives: #333333

Mastery11 and 12

Calling and Creating Python functions

11 12 1014

Mastery02

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

02 1014

Mastery01

Ability to create Python file and run from command line

01 1014

 

#TC1017 #BONUS

Aquí dejo el video para el punto extra!! 

http://youtu.be/Um78Bitbx58 

Creation and use of matrixes in C++ #Mastery26 #TC1017

Creation and use of matrixes in C++ 26 1017

Usually this is the way people represented

or in this way 

 

Matrices are used to represent complicated or time-consuming mathematical operations. A single matrix can hold an infinite number of calculations, which can then be applied to a number, vector, or another matrix. There are several operations that can be done on matrices, including addition, multiplication and inverse calculation; some of which will be discussed shortly.

 

Matriz are declaraed in this way 

 

[][]; 

 

For example if we want to declarate the matriz called matr  with a dimension  of   15×4 and you can store character data type we write

matr : matriz [15][4] character

Usefull links 🙂 

http://www.cpp-home.com/archives/185.html

http://dis.unal.edu.co/~programacion/book/modulo3.pdf

Mastery14

Creating and using a Python module

A module is a file containing Python definitions and statements. The file name is the module name with the suffix “.py”

Example:

  • Create “hello.py” then write the following function:
def helloworld():
   print "hello"

import hello
hello.helloworld()
>>>'hello'

AWESOME PAGE

14 1014

#Mastery28

Reading and writing of files in C++

Primero llamamos a la libreria ademas de using namespace std;

Segundo tenemos que escribir en el documento que vamos a leer.

Ademas debemos de incluir una libreria que nos permite leer archivos que esten en la carpeta donde esta nuestro codigo. Esta libreria se llama

Empezamos con nuestra fiuncion principal int main y abrimos nuestro archivo como se muestra en la imagen abajo de nuestro codigo. (El nombre del documento esta entre “”)

Para escribir en el documento debemos de usar

Cerramos el documento y compilamos y corremos para ver que no haya ningun error.

Aqui esta un ejemplo de lo que hicimos anteriormente:

28

Mastery27:: Validated user input in c++

27

Inputs have to be validated before allowing any kind of processing or operations to be performed on it. This is extremely important because , an unhandled wrong input  might have the complete ability to crash a system.  C++ has some  good  validation techniques that  can be used to validate most kind of inputs. This post  discusses some of the techniques and its shortcomings and  what could be done to improve the quality of validation.

Now, consider a program has to accept only integer inputs and reject all the others. So, the developer would have declared to store the integer value in say “int a;”. So “a” will store the input value.

When the user input is accepted using the “cin>>a” statement, we can use the inbuilt methods surrounding the “cin”  statement to test its status.

1017

Mastery26:: Creation and use of matrices

26

La sintaxis de una matriz es C++ es la siguiente:

 
int matrix[rows][cols];

En este ejemplo int es el tipo de dato, matrix es el nombre del todo el conjunto de datos y debo de especificar el numero de filas (rows) y columnas (cols).

Las matrices también pueden ser de distintos tipos de datos como char, float, double, etc. Las matrices en C++ se almacenan al igual que los vectores en posiciones consecutivas de memoria.

Podriamos imaginarnos que una matriz es como un tablero, pero en realidad el manejo es como su definición lo indica, un vector de vectores, es decir, los vectores están uno detrás del otro juntos.

Para acceder a los elementos de la matriz es utilizando su nombre e indicando los 2 subíndices que van en los corchetes.

Si coloco int matriz[2][3] = 10; estoy asignando al cuarto elemento de la tercera fila el valor 10.

Es importante tener en cuenta que tanto filas como columnas se enumeran a partir de 0. 

1017

#Mastery25

Creation and use of strings in C++

Primero llamamos a la libreria usamos using namespace std;  y llamamos a nuestra funcion principal int main.

Despues definimos nuestras variables string, int, y char. Un string es un contenedor diseñado para operar con strings de caracteres de un solo byte.

Despues usamos la funcion legnth para tener el numero de digitos en el numero.

Usamos un ciclo for para comparar el digito con todos los digitos en un numero.

Si el digito del numero es igual al numero de digito, el contador incrementa.

Imprimimos el numero de veces que el digito esta en nuestro numero con un simple cout.

Usamos return 0 para terminar el programa, compilamos y corremos para ver que no haya ningun error.

Aquí esta un ejemplo de un programa corriendo utilizando strings:

25