This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
namespace Recetas.Multithreading.Cap04.R0109 | |
{ | |
// Representa una cuanta Bancaria: | |
public class Cuenta | |
{ | |
// Instancia Object para el bloque concurrente | |
// a un sección crítica: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Factura | |
{ | |
// Variables de instancia | |
private String numDePieza; // Número de la pieza | |
private String descPieza; // Descripción de la pieza | |
private int qtyArticulo; // Cantidad del artículo | |
private double vlrArticulo; // Valor del artículo | |
// Constructur personalizado | |
public Factura( String pNumDePieza , String pDescPieza , int pQtyArticulo , double pVlrArticulo ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
df = pd.DataFrame({'uno': [1, 2, 3], 'dos': [4, 5, 6], 'tres': [7, 8, 9]}, index=['x', 'y', 'z']) | |
# Iteración por columnas del DataFrame: | |
for col in df: | |
print(df[col].mean()) | |
print() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ejercicio 197: Crear una clase para representar los datos de una persona. | |
class Persona{ | |
constructor(nombre, apellido, edad, email){ | |
this.nombre = nombre; | |
this.apellido = apellido; | |
this.edad = edad; | |
this.email = email; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
class Pruebas(unittest.TestCase): | |
def mensaje(self): | |
return 13 | |
def test_resultado(self): | |
self.assertEqual(self.mensaje(), 13) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ejercicio 191: Contar las ocurrencias de los elementos de un arreglo con forEach. | |
// Solución: | |
let numeros = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 5, 6, 7, 8]; | |
let conteo = {}; | |
numeros.forEach((valor) => { | |
if(conteo[valor]){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ejercicio 288: Uso del evento onchange sobre el elemento select de HTML. | |
function seleccionarLenguaje(){ | |
let cbxLenguajes = document.getElementById('cbxLenguajes'); | |
let lenguaje = cbxLenguajes.value; | |
document.getElementById('lblLenguajeSeleccionado').innerText = `Ud. ha seleccionado el lenguaje ${lenguaje}.`; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ejercicio 295: Crear una función para sumar todos los elementos de una lista. | |
def sumar_lista(lista): | |
""" | |
Suma un conjunto de valores en una lista. | |
""" | |
suma = 0 | |
for numero in lista: | |
suma += numero |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ejercicio 313: Crear un archivo de texto plano usando un objeto Promise en Node.js. | |
const fs = require('fs'); | |
let promesaEscrituraArchivo = new Promise((resolve, reject) => { | |
fs.writeFile('ex313_archivo_texto.txt', 'Node.js v. 10.0', (error) => { | |
if(error){ | |
reject(error); | |
} else { | |
resolve(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ejercicio 339: Particionar una lista y guardar las partes en variables. | |
colores = [('Rojo', 'RGB(255, 0, 0)', '#FF0000'), ('Verde', 'RGB(0, 255, 0)', '#00FF00'), ('Azul', 'RGB(0, 0, 255)', '#0000FF')] | |
rojo, verde, azul = colores | |
print(colores) | |
print(rojo) | |
print(verde) | |
print(azul) |