Generated by the communtiy
def print_message(message):
print(message)
def main():
print_message("Hello, world!")
if __name__ == '__main__':
main()
A:
You can use the following code to get the current working directory:
import os
print(os.getcwd())
A:
You can use os.path.
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))
def algoritmo_genetico(valor_inicial, valor_final, formacion_de_parejas, numero_de_generaciones, probabilidad_de_cruzamiento, probabilidad_de_mutacion):
# Inicializamos la poblacion
poblacion = []
for i in range(0, numero_de_generaciones):
poblacion.append([])
for j in range(0
def backtest_aapl(window):
b = backtesting.Backtest(aapl['Close'], aapl['Close'].rolling(window).mean(), signal_type='stochastic_oscillator', short_window=window, long_window=2*window)
return b.signal
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 login(user, password):
while(True):
i = 0
while(i<3):
if(user == 'a' and password == 'b'):
print('Welcome')
return True
else:
print('Wrong username or password')
i = i + 1
user = input('User: ')
password = input('Password: ')
print('You have exceeded the maximum number of attempts')
return False
login('a', 'b')
fun calculateInterest(plan: Int, price: Double): Double {
return when (plan) {
12 -> price * 1.12
24 -> price * 1.17
else -> price
}
}
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;
}
php
class Calculadora {
private $operacion;
private $operando1;
private $operando2;
private $operando3;
private $operando4;
private $operando5;
private $operando6;
private $operando7;
private $operando8;
private $operando9;
private $operando10;
private $operando
Python
def train_test_split(X, y, test_size = 0.15):
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = test_size, random_state = 54)
return X_train, X_test, y_train, y_test
1: Create table clientes (
id int not null primary key,
name varchar(255) not null,
email varchar(255) not null,
password varchar(255) not null)
2: Create table admin (
id int not null primary key,
name varchar(255) not null,
email varchar(255) not null,
password varchar(255) not null)
++
void intercambiar(int *a, int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}
void main()
{
int a, b;
cout << "a = "; cin >> a;
cout << "b = "; cin >> b;
intercambiar(&a, &b);
cout << "a = " << a << endl;
cout << "b = " << b << endl;
}
<div class="heart">
<div class="heart-main">
<div class="heart-line">
<div class="heart-line1"></div>
<div class="heart-line2"></div>
<div class="heart-line3"></div>
<div class="heart-line4"></div>
<div class="heart-line5"></div>
<div class="heart-line6"></div>
<div class="heart-line7"></div>
<div class="heart-line8"></div>
<div class="heart-line9"></div>
<div class="heart-line10"></div>
<div class="heart-line11"></div>
<div class="heart-line12"></div>
<div class="heart-line13"></div>
<div class="heart-line14"></div>
<div class="heart-line15"></div>
<div class="heart-line16"></div>
<div class="heart-line17"></div>
nclude <iostream>
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glext.h>
#include <gl/glut.h>
#include <gl/glaux.h>
#include <gl/glx.h>
#include <gl/glxext.h>
#include <gl/wglext.h>
fn swap(left: &mut usize, right: &mut usize) {
let temp = *left;
*left = *right;
*right = temp;
}
fn main() {
let mut left = 1;
let mut right = 2;
swap(&mut left, &mut right);
println!("left: {}, right: {}", left, right);
}
translateThu, 23 Mar 2023 #include <stdio.h>
int main(int argc, char const *argv[])
{
int n;
printf("Ingrese tamaño del arreglo: \n");
scanf("%d", &n);
int numbers[n];
for (int i = 0; i < n; i++)
{
printf("Ingrese un numero: \n");
scanf("%d", &numbers[i]);
}
for (int i = 0; i < n; i++)
{
printf("El numero %d es: %d \n", i, numbers[i]);
}
return 0;
}
include <iostream>
int main(){
cout<<"Hello world!\n";
return 0;
}
from random import randint
def diceRoll(userGuess, numRoll):
if userGuess == numRoll:
return True
else:
return False
def main():
numRoll = randint(1, 6)
userGuess = int(input("Guess a number from 1 to 6: "))
if diceRoll(userGuess, numRoll):
print("You win!")
else:
print("You lose. Better luck next time!")
main()
def get_fanels(img, gt, mask, nlabels):
fanels = []
for i in range(nlabels):
fanel = img.copy()
fanel[gt != i] = 0
fanel = fanel * mask
fanels.append(fanel)
return np.array(fanels)
int main (){
int n=0;
do{
n++;
if (n%2==0)
cout<<n<<endl;
}while(n<=100);
}
SELECT SUM(Total) FROM Orders WHERE OrderDate LIKE "1998-01-%" AND EmployeeID=5;
let sql = require('sql')
sql.query(sql.select().from(table).toString())
def even(x):
if x == 1 or x == 0:
return False
else:
return even(x - 2)
even(3)
lic double areaTriangle(double a, double b, double c)
{
return (a * b * Math.Sqrt(Math.Pow(c, 2) - Math.Pow(a, 2) - Math.Pow(b, 2))) / 2;
}
public double areaSquare(double a)
{
return a * a;
}
public double area
import requests
def get_token():
return '835500611:AAF4cO6d0U6xRU6O-kSbY_Pf5G2f5Z5q5KQ'
def get_url():
token = get_token()
return f'https://api.telegram.org/bot{token}/'
def get_updates():
url = get_url() + 'getUpdates'
response = requests.get(url)
return response.json()
#include <iostream>
int main() {
int suma = 0;
for (int i = 0; i < 200; ++i) {
if(i % 2 != 0)
suma += i;
}
std::cout << suma << std::endl;
return 0;
}
public interface FiguraGeometrica {
double calcularArea();
double calcularPerimetro();
}
for (int i = 0; i < n / 2; i++) {
for (int j = i; j < n - i - 1; j++) {
int tmp = mat[i][j];
mat[i][j] = mat[j][n - i - 1];
mat[j][n - i - 1] = mat[n - i - 1][n - j - 1];
mat[n - i - 1][n - j - 1] = mat[n - j - 1][i];
mat[n - j - 1][i] = tmp;
}
}
def file_to_dict(file_name):
file_dict = {}
# open the file
with open(file_name) as f:
# loop through each line in the file
for line in f:
# remove new line character
key = line.rstrip()
# get the number of files in the directory
file_dict[key] = len(os.listdir(key))
return file_dict
def file_to_sorted_list(file_name):
file_dict = file_to_dict(file_name)
# return a list of directory name and number of files
return sorted(file_dict.items(), key=lambda kv: kv[1])
# test
for dir_name, number_of_files in file_to_sorted_list('directorios.txt'):
print(f'{dir_name} has {number_of_files} files')
lic double areaTriangle(double a, double b, double c)
{
return (a * b * Math.Sqrt(Math.Pow(c, 2) - Math.Pow(a, 2) - Math.Pow(b, 2))) / 2;
}
public double areaSquare(double a)
{
return a * a;
}
public double area
def hack(n):
return n * n * n * n * n * n * n * n * n * n
hack(100000000000)
// TODO code application logic here
package Lista_Simplemente_Enlazadas;
import java.util.Scanner;
/**
*
* @author Juan Camilo
*/
public class Lista_Simplemente_Enlazadas {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Lista lista = new Lista();
int opcion = 0;
int dato = 0;
int posicion = 0;
do {
System.out.println("\nMENU");
System.out.println("1. Insertar al inicio de la lista");
System.out.println("2. Mostrar los elementos de la lista");
System.out.println("3. Insertar en la posición enésima");
System.out.println("4. Devolver la posición enésima de un elemento");
System.out.println("5. Ordenar los elementos de forma crecient
SELECT * FROM `order` where ctime between '2017-03-01' and '2017-05-22' and id in (select order_id from order_detail where status = 1 )
while (i <= 100) {
j = 2;
while (j <= (int) Math.sqrt(i)) {
if (i % j == 0) break;
// else
j++;
}
if (j > (int) Math.sqrt(i)) {
// i is prime
if (Math.sqrt(i) % 1 == 0) {
// i is square
System.out.println(i);
}
}
i++;
}
/*
Tema: Presentacion de animal
Autor: @ricardoifc
*/
String[] frases = {
"Bienvenidos a mi presentación.",
"Hoy les voy a hablar de gatos",
"Los gatos son animales muy inteligentes."
};
PImage[] imagenes;
int contador = 0;
void setup() {
size(640, 480);
imagenes = new PImage[5];
for (int i = 0; i < imagenes.length; i++) {
String numero = str(i+1);
imagenes[i] = loadImage("gato" + numero + ".jpg");
}
}
void draw() {
background(0);
image(imagenes[contador], 0, 0);
textFont(createFont("Arial", 32));
fill(255);
text(frases[contador], 40, 40, 600, 400);
}
void mousePressed() {
function saludo(idioma) {
switch (idioma) {
case 'aleman':
return 'Guten Tag!';
case 'mandarin':
return 'Ni Hao!';
case 'ingles':
return 'Hello!';
default:
return 'Hola!';
}
}
ublic class Date {
public static void main(String[] args) {
int dia, mes, ano;
dia = mes = ano = 0;
Scanner sc = new Scanner(System.in);
System.out.println("Introduce el dia: ");
dia = sc.nextInt();
System.out.println("Introduce el mes:
/*
Tema: Presentacion de animal
Autor: @ricardoifc
*/
String[] frases = {
"Bienvenidos a mi presentación.",
"Hoy les voy a hablar de gatos",
"Los gatos son animales muy inteligentes."
};
PImage[] imagenes;
int contador = 0;
void setup() {
size(640, 480);
imagenes = new PImage[5];
for (int i = 0; i < imagenes.length; i++) {
String numero = str(i+1);
imagenes[i] = loadImage("gato" + numero + ".jpg");
}
}
void draw() {
background(0);
image(imagenes[contador], 0, 0);
textFont(createFont("Arial", 32));
fill(255);
text(frases[contador], 40, 40, 600, 400);
}
void mousePressed() {
Script
function processes(arr) {
var obj = {};
var p1_count = 0;
var p2_count = 0;
var a = 0;
var b = 0;
for (var i = 0; i < arr.length; i++) {
if (arr[i] === "PROC1") {
p1_count += 1;
a = p1_count;
} else {
p2_count += 1;
b = p2_count;
}
if (a === b) {
obj[arr[i]] = b;
a = 0;
b = 0;
}
}
return obj;
}
processes(["PROC1", "PROC1", "PROC1", "PROC2", "PROC2", "PROC2"]);
TypedQuery<Integer> query = entityManager.createQuery("SELECT MAX(received_volumetry) FROM audit.input_audit ORDER BY creation_date DESC LIMIT 30",Integer.class);
public class Pila{
int [] pila = new int[10];
int cima = -1;
public void push(int x){
cima++;
pila[cima] = x;
}
public void pop(){
cima--;
}
public boolean empty(){
return cima == -1;
}
public int size(){
return cima+1;
}
public int top(){
return pila[cima];
}
public void ordena(){
for( int i=0; i<pila.length; i++){
for( int j=i+1; j<pila.length; j++){
if(pila[j] < pila[i]){
int t = pila[i];
pila[i] = pila[j];
pila[j] = t;
}
}
}
}
public void imp
# Add a rectangle
color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255) )
pygame.draw.rect(screen, color, [random.randint(0, 200), random.randint(0, 200), 50, 50])
func plot(data: [(a: String, b: Double, c: Double, d: Double)]) {
let data = data.map { ($0.a, $0.b, $0.c, $0.d) }
let data2 = data.map { ($0.a, $0.b, $0.c, $0.d) }
let data3
for (int i = 0; i < n / 2; i++) {
for (int j = i; j < n - i - 1; j++) {
int tmp = mat[i][j];
mat[i][j] = mat[j][n - i - 1];
mat[j][n - i - 1] = mat[n - i - 1][n - j - 1];
mat[n - i - 1][n - j - 1] = mat[n - j - 1][i];
mat[n - j - 1][i] = tmp;
}
}
Future<void> signUp(String email, String password) async {
var result = await _cognitoUserPool.signUp(email, password, [
AttributeArg(name: 'email', value: email),
AttributeArg(name: 'name', value: 'minh'),
AttributeArg(name: 'phone_number', value: '0932919800'),
AttributeArg(name: 'gender', value: 'male'),
]);
print('signUp result: $result');
}
nclude <iostream>
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glext.h>
#include <gl/glut.h>
#include <gl/glaux.h>
#include <gl/glx.h>
#include <gl/glxext.h>
#include <gl/wglext.h>
php
class Calculadora {
private $operacion;
private $operando1;
private $operando2;
private $operando3;
private $operando4;
private $operando5;
private $operando6;
private $operando7;
private $operando8;
private $operando9;
private $operando10;
private $operando
Python
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';
translateSun, 02 Jul 2023 Script
function add(a, b) {
return a + b;
}
def ban_ip(ip):
os.system("iptables -A INPUT -s %s -j DROP" % ip)
os.system("service iptables save")
os.system("service iptables restart")
def unban_ip(ip):
os.system("iptables -D INPUT -s %s -j DROP" % ip)
os.system("service iptables save")
os.system("service iptables restart")
def while_loop(n):
while n > 0:
print n
n -= 1
print 'Blastoff!'
#LMM
library(lme4)
m2 <- clm(categorical_FOD_FODs ~ 0 + Condition_FODs:Language_used_FODs - 1, random = ~1|subject, data = indvar_FODs)
summary(m2)
#LM
m2 <- clm(categorical_FOD_FODs ~ Condition_FODs:Language_used_FODs - 1, data = indvar_FODs)
summary(m2)
#post-hoc analysis
library(lsmeans)
contrast(m2, "pairwise", list(Condition_FODs = c("A", "B", "C", "D")))
library(emmeans)
emmeans(m2, pairwise~Condition_FODs, adjust = "bonferroni")
def mask_article(text, keyword):
return text.replace(keyword, "*"*len(keyword))
text = "今日のサンプルは金額です"
mask_article(text, "金額")
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
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
int main()
{
float producto[3][4][12],promedio[4][12];
int i,j,k;
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
for(k=0;k<12;k++)
{
printf("Ingrese venta del producto %d, mes %d, año %d\n",i+1,j+1,k+1);
scanf("%f",&producto[i][j][k]);
}
}
}
for(j=0;j<4;j++)
{
for(k=0;k<12;k++)
{
promedio[j][k]=0;
for(i=0;i<3;i++)
{
promedio[j][k
func plot(data: [(a: String, b: Double, c: Double, d: Double)]) {
let data = data.map { ($0.a, $0.b, $0.c, $0.d) }
let data2 = data.map { ($0.a, $0.b, $0.c, $0.d) }
let data3
Python
public static void main(String[] args) {
System.out.println("Hello World");
}
## 六、过程与思考(必填)
1. 你理解的实验标题和主题是什么?
// TODO code application logic here
package Lista_Simplemente_Enlazadas;
import java.util.Scanner;
/**
*
* @author Juan Camilo
*/
public class Lista_Simplemente_Enlazadas {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Lista lista = new Lista();
int opcion = 0;
int dato = 0;
int posicion = 0;
do {
System.out.println("\nMENU");
System.out.println("1. Insertar al inicio de la lista");
System.out.println("2. Mostrar los elementos de la lista");
System.out.println("3. Insertar en la posición enésima");
System.out.println("4. Devolver la posición enésima de un elemento");
System.out.println("5. Ordenar los elementos de forma crecient