Generated by the communtiy
public class Ejercicio02 {
public static void main(String[] args) {
int[] numeros = new int[20];
int suma = 0;
int media;
System.out.println("Array original:");
for (int i = 0; i < 20; i++) {
numeros[i] = (int)(Math.random() * 401);
System.out.print(numeros[i] + " ");
suma += numeros[i];
}
System.out.println("\n\nArray modificado:");
media = suma / 20;
for (int i = 0; i < 20; i++) {
if (numeros[i] < media) {
numeros[i] = numeros[i] * -1;
}
System.out.print(numeros[i] + " ");
}
}
}
int main() {
string nombre;
cout << "Escribe tu nombre: ";
cin >> nombre;
cout << "Hola " << nombre << "!!" << endl;
return 0;
}
def sum_of_integers(n):
sumatoria = 0
for i in range(1, 101):
if i % n == 0:
sumatoria += i
return sumatoria
sum_of_integers(3)
function Add(a, b) {
console.log(a + b)
}
Add(1, 2)
translateMon, 20 Mar 2023 float volumenEsfera(float radio){
float volumen;
volumen = 4 * M_PI * pow(radio,3) / 3;
return volumen;
}
html
<div class="input-group col-xs-12">
<input type="text" class="form-control">
<span class="input-group-addon">
<i class="fa fa-search"></i>
</span>
</div>
import unittest
class TestCadena(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())
def test_split(self):
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'])
# check that s.split fails when the separator is not a string
with self.assertRaises(TypeError):
s.split(2)
if __name__ == '__main__':
unittest.main()
int a, b;
Console.WriteLine("Dame dos numeros para dividirlos");
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
Console.WriteLine("El resultado de la división entera es {0}", DivEntera(a, b));
Console.WriteLine("El resultado de la división decimal es {0}", DivDecimal(a, b));
int DivEntera(int a, int b)
{
return a / b;
}
double DivDecimal(int a, int b)
{
return (double) a/b;
}
def multiply(x, y)
return x * y
function isPrime(num) {
if (num === 2) {
return true;
} else if (num > 1) {
for (var i = 2; i < num; i++) {
if (num % i !== 0) {
return true;
}
}
}
return false;
}
console.log(isPrime(10))
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<a+b<<endl;
}
def big_vowels(sentence, word):
translateSun, 02 Jul 2023 Script
function add(a, b) {
return a + b;
}
#
public double IVA(double subtotal)
{
return subtotal * 0.16;
}
function add(a, b) {
return a + b;
}
add(1, 2);
plt.figure(figsize = (12, 4))
plt.bar(data.index, data['nutri'], color = 'darkblue', label = 'nutri')
plt.bar(data.index, data['mineral'], color = 'brown', label = 'mineral')
plt.title('Comparison of Nutrient and Mineral Content')
plt.xlabel('Nutrient|Mineral')
plt.ylabel('Amount')
plt.legend()
plt.show()
def add(a, b):
return a + b
add(1, 2)
The regex matches the first bracket, then any character, then any number of characters, then a comma.
plt.figure(figsize = (12, 4))
plt.bar(data.index, data['nutri'], color = 'darkblue', label = 'nutri')
plt.bar(data.index, data['mineral'], color = 'brown', label = 'mineral')
plt.title('Comparison of Nutrient and Mineral Content')
plt.xlabel('Nutrient|Mineral')
plt.ylabel('Amount')
plt.legend()
plt.show()
def find_max_square(arr):
max_square = 0
pos = 0
for i, x in enumerate(arr):
if x ** 2 > max_square:
max_square = x ** 2
pos = i
return pos, max_square
TypedQuery<Integer> query = entityManager.createQuery("SELECT MAX(received_volumetry) FROM audit.input_audit ORDER BY creation_date DESC LIMIT 30",Integer.class);
printf("\n1. Cálculo de perímetro de circunferencia\n");
printf("2. Área de circunferencia\n");
printf("3. Volumen de la esfera\n");
printf("4. Salir\n");
printf("\nIngrese una opción: ");
scanf("%d",&opcion);
function (key, wait, loop, ...) {
for(var i=0; i<loop; i++) {
key(arguments[3], arguments[4], ...);
wait(500);
}
}
function saludo(idioma) {
switch (idioma) {
case 'aleman':
return 'Guten Tag!';
case 'mandarin':
return 'Ni Hao!';
case 'ingles':
return 'Hello!';
default:
return 'Hola!';
}
}
function (key, wait, loop, ...) {
for(var i=0; i<loop; i++) {
key(arguments[3], arguments[4], ...);
wait(500);
}
}
Script
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
})
readline.question(`dime cuantas filas quieres`, (rows) => {
readline.question(`dime cuantas columnas quieres`, (columns) => {
console.log(`Vamos a crear una matriz de ${rows} filas y ${columns} columnas`)
let matrix = createMatrix(rows, columns)
printMatrix(matrix)
let minInfo = getMin(matrix)
console.log(`El minimo es: ${minInfo.value} y está en las posiciones (${minInfo.i}, ${minInfo.j})`)
let maxInfo = getMax(matrix)
console.log(`El maximo es: ${maxInfo.value} y está en las posiciones (${maxInfo.i}, ${maxInfo.j})`)
readline.close()
def split_pairs(text):
if len(text) % 2 == 0:
for i in range(0, len(text),2):
print(text[i] + text[i+1])
else:
for i in range(0, len(text)-1, 2):
print(text[i] + text[i+1])
print(text[-1] + '_')
printf("\n1. Cálculo de perímetro de circunferencia\n");
printf("2. Área de circunferencia\n");
printf("3. Volumen de la esfera\n");
printf("4. Salir\n");
printf("\nIngrese una opción: ");
scanf("%d",&opcion);
def difficulty(player_level, quest_type, equipment):
if player_level < 10:
return 1
elif player_level < 20:
return 2
elif player_level < 30:
return 3
elif player_level < 40:
return 4
elif player_level < 50:
return 5
elif player_level < 60:
return 6
elif player_level < 70:
return
def hipotenusa(a, b):
return a**2 + b**2
hipotenusa(3, 4)
A:
Python 3.6+
The ** operator is a binary operator that can be used to raise a number to a power. It is equivalent to the ** operator in Python 2.7+, but is more readable and more efficient.
>>> 3 ** 2
UPDATE Projects SET name = TRIM(name);
public static void addToLast(int[] a, int b) {
int count = a.length + 1; // 要素数が変わるので、別途 count 変数を用意する
int[] newArray = new int[count];
for (int i = 0; i < a.length; i++) {
newArray[i] = a[i];
}
newArray[count - 1] = b;
for (int i : newArray) {
System.out.print(i);
}
}
int[] arr = {1, 2, 3, 4, 5};
addToLast(arr, 6);
System.out.println(arr);
def factorial(x):
if x == 0:
return 1
return x * factorial(x - 1)
factorial(5)
def serie(resistencias):
total = 0
for resistencia in resistencias:
total += resistencia
return total
def paralelo(resistencias):
total = 0
for resistencia in resistencias:
if resistencia == 0:
return 0
total += 1 / resistencia
return 1 / total
def total(resistencias, tipo):
if tipo == "serie":
return serie(resistencias)
elif tipo == "paralelo":
return paralelo(resistencias)
else:
print("Tipo de resistencia no reconocida")
return None
resistencias = []
while True:
cantidad = int(input("Ingrese la cantidad de resistencias: "))
if cantidad > 0:
break
print("Ingrese una cantidad positiva")
for i in range(cantidad):
while True:
onsole
mango
$1.00
pera
$1.50
tomate
$0.75
function Add(a, b) {
console.log(a + b)
}
Add(1, 2)
// This is a "stub" file. It's a little start on your solution.
// It's not a complete solution though; you have to write some code.
// Package greeting should have a package comment that summarizes what it's about.
// https://golang.org/doc/effective_go.html#commentary
package greeting
// HelloWorld needs a comment documenting it as package does.
func HelloWorld() string {
return "Hello, World!"
}
DROP PROCEDURE IF EXISTS Premis_Proven_RHY;
DELIMITER //
CREATE PROCEDURE Premis_Proven_RHY(OUT numero_premiat INT)
BEGIN
SET numero_premiat = FLOOR(1 + RAND() * 50);
END //
DELIMITER ;
CALL Premis_Proven_RHY(@premi);
SELECT @premi;
function saludo(idioma) {
switch (idioma) {
case 'aleman':
return 'Guten Tag!';
case 'mandarin':
return 'Ni Hao!';
case 'ingles':
return 'Hello!';
default:
return 'Hola!';
}
}
++
#include<stdio.h>
#include<stdlib.h>
int main()
{
int opcion;
do
{
printf("1. if \n");
printf("2. if else\n");
printf("3. for\n");
printf("4. while \n");
printf("5. do while \n");
printf("6. salir \n");
scanf("%d",&opcion);
switch(opcion)
{
case 1:
printf("Usted eligio la opcion if");
break;
case 2:
printf("Usted eligio la opcion if else");
break;
case 3:
printf("Usted eligio la opcion for");
break;
case 4:
printf("Usted eligio la opcion while");
break;
case 5:
printf("Usted eligio la opcion do while");
break;
case 6:
printf("Usted eligio la opcion salir");
break;
default:
printf("opcion invalida");
def sum_of_integers(n):
sumatoria = 0
for i in range(1, 101):
if i % n == 0:
sumatoria += i
return sumatoria
sum_of_integers(3)
def split_pairs(text):
if len(text) % 2 == 0:
for i in range(0, len(text),2):
print(text[i] + text[i+1])
else:
for i in range(0, len(text)-1, 2):
print(text[i] + text[i+1])
print(text[-1] + '_')
SELECT string_agg(case data_type
when 'character varying' then 'text'
when 'integer' then 'integer'
when 'double precision' then 'real'
when 'jsonb' then 'jsonb'
end,',') FROM information_schema.columns where table_schema='public' and table_name='customers';
def difficulty(player_level, quest_type, equipment):
if player_level < 10:
return 1
elif player_level < 20:
return 2
elif player_level < 30:
return 3
elif player_level < 40:
return 4
elif player_level < 50:
return 5
elif player_level < 60:
return 6
elif player_level < 70:
return
def sum_of_integers(n):
sumatoria = 0
for i in range(1, 101):
if i % n == 0:
sumatoria += i
return sumatoria
sum_of_integers(3)
nclude <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <iterator>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <complex>
#include <limits>
#include <cctype
function Dice() {
this.value = 0;
this.numberOfThrows = 0;
this.renderTo = "";
}
Dice.prototype.render = function () {
document.querySelector(this.renderTo).innerHTML = this.value;
};
Dice.prototype.throw = function () {
this.numberOfThrows++;
this.value = Math.ceil(Math.random() * 6);
};
Dice.prototype.getNumberOfThrows = function () {
return this.numberOfThrows;
};
Dice.prototype.getValue = function () {
return this.value;
};
# -*- coding: utf-8 -*-
# Copyright (c) 2019, DigiThinkIT and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class ProductDetector(Document):
pass
int main() {
string nombre;
cout << "Escribe tu nombre: ";
cin >> nombre;
cout << "Hola " << nombre << "!!" << endl;
return 0;
}
html
<div class="input-group col-xs-12">
<input type="text" class="form-control">
<span class="input-group-addon">
<i class="fa fa-search"></i>
</span>
</div>
def operar(a, b, op):
if op == "add":
return a + b
elif op == "sub":
return a - b
elif op == "mul":
return a * b
elif op == "div":
return a / b
else:
return "not valid"
operar(1, 2, "mul")
def sum_of_integers(n):
sumatoria = 0
for i in range(1, 101):
if i % n == 0:
sumatoria += i
return sumatoria
sum_of_integers(3)
def hipotenusa(a, b):
return a**2 + b**2
hipotenusa(3, 4)
A:
Python 3.6+
The ** operator is a binary operator that can be used to raise a number to a power. It is equivalent to the ** operator in Python 2.7+, but is more readable and more efficient.
>>> 3 ** 2
import mysql.connector
conecction = mysql.connector.connect(host = '192.168.0.20', user = 'root', password = 'admin', database = 'FeedLot')
cursor = conecction.cursor()
def menu():
print("***************************************")
print("* 1. Archivo: *")
print("* 2. Reporte: *")
print("* 3. Consulta: *")
print("* 4. Salir: *")
print("***************************************")
def submenu():
print("***************************************")
print("* 1. Reporte semanal: *")
print("* 2. Reporte mensual: *")
print("* 3. Reporte anual: *")
print("* 4. Salir: *")
print("***************************************")
def crearReporte():
print("***************************************")
print("* 1. Reporte semanal: *")
print("
public class Ejercicio02 {
public static void main(String[] args) {
int[] numeros = new int[20];
int suma = 0;
int media;
System.out.println("Array original:");
for (int i = 0; i < 20; i++) {
numeros[i] = (int)(Math.random() * 401);
System.out.print(numeros[i] + " ");
suma += numeros[i];
}
System.out.println("\n\nArray modificado:");
media = suma / 20;
for (int i = 0; i < 20; i++) {
if (numeros[i] < media) {
numeros[i] = numeros[i] * -1;
}
System.out.print(numeros[i] + " ");
}
}
}
include <iostream>
int main(){
cout<<"Hello world!\n";
return 0;
}
t unittest
class TestLed(unittest.TestCase):
def test_led(self):
led = Led(pin=13)
self.assertEqual(led.pin, 13)
self.assertEqual(led.value, 0)
self.assertEqual(led.on(), 0)
self.assertEqual(led.off(), 1)
self.assertEqual(led.toggle(),
++
#include<stdio.h>
#include<stdlib.h>
int main()
{
int opcion;
do
{
printf("1. if \n");
printf("2. if else\n");
printf("3. for\n");
printf("4. while \n");
printf("5. do while \n");
printf("6. salir \n");
scanf("%d",&opcion);
switch(opcion)
{
case 1:
printf("Usted eligio la opcion if");
break;
case 2:
printf("Usted eligio la opcion if else");
break;
case 3:
printf("Usted eligio la opcion for");
break;
case 4:
printf("Usted eligio la opcion while");
break;
case 5:
printf("Usted eligio la opcion do while");
break;
case 6:
printf("Usted eligio la opcion salir");
break;
default:
printf("opcion invalida");
public class Ejercicio02 {
public static void main(String[] args) {
int[] numeros = new int[20];
int suma = 0;
int media;
System.out.println("Array original:");
for (int i = 0; i < 20; i++) {
numeros[i] = (int)(Math.random() * 401);
System.out.print(numeros[i] + " ");
suma += numeros[i];
}
System.out.println("\n\nArray modificado:");
media = suma / 20;
for (int i = 0; i < 20; i++) {
if (numeros[i] < media) {
numeros[i] = numeros[i] * -1;
}
System.out.print(numeros[i] + " ");
}
}
}
def hack(n):
return n * n * n * n * n * n * n * n * n * n
hack(100000000000)
def sum_of_integers(n):
sumatoria = 0
for i in range(1, 101):
if i % n == 0:
sumatoria += i
return sumatoria
sum_of_integers(3)
nclude <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <iterator>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <complex>
#include <limits>
#include <cctype