Custom ChatGPT Plugin development

ConversAI Solutions

Code faster with the help of AI

Generate code just by typing a text description. AI will create the code for you. Test it now

Questions about programming?Chat with your personal AI assistant

How others used it recently

Generated by the communtiy

testsSat, 22 Apr 2023

Crear un código de una calculadora

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()

Guest
generate functionFri, 21 Apr 2023

標準入力から 2 つの整数を入力し、大きいほうの値を表示するプログラムを作成せよ。 (ヒント:2 つの変数を a、b とすると、a>b が「正しいとき」と「正しくないとき」でそれぞれどちらを表 示すればよいかが判断できるはずである。もし両者が同じ値のときは、a と b のどちらを表示してもよい)

a = input("a:") b = input("b:") if a > b: print(a) else: print(b)

Java
Guest
generate functionSat, 06 May 2023

Login con conexión a MySQL con contraseña encriptada

import mysql.connector import hashlib import sys def login(username, password): """ """ # Create connection mydb = mysql.connector.connect( host="localhost", user="user", passwd="pass", database="mydatabase" ) # Create cursor to execute queries cursor = mydb.cursor() # Create query and execute query = f"SELECT * FROM login WHERE username = '{username}'" cursor.execute(query) # Fetch all results result = cursor.fetchall() # Check if query was successful if result == []: print("Invalid username and/or password") return # Check if user exists if len(result) != 1: print("ERROR: More than one user exists") return # Check if password is correct # Load password from database db_password = result[0][1] # Encrypt password

Python
Guest
generate functionFri, 21 Apr 2023

suma de matrices con vectores

import numpy as np def add_matrix_and_vector(x, y): return x + y matrix = np.array([[1, 2], [3, 4]]) vector = np.array([6, 7]) add_matrix_and_vector(matrix, vector)

Python
Guest
generate functionTue, 18 Apr 2023

> m2 <- clm(categorical_FOD_FODs ~ 0 + Condition_FODs:Language_used_FODs - 1, random = ~1|subject, data = indvar_FODs) > summary(m2) formula: categorical_FOD_FODs ~ 0 + Condition_FODs:Language_used_FO...

#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")

generate functionSat, 26 Nov 2022

masonry layout grid vue js

import { Vue, Component, Prop, Watch } from "vue-property-decorator"; @Component({ name: "Masonry", }) export default class GridLayout extends Vue { @Prop({ default: false }) horizontal!: boolean; @Prop({ default: 200 }) gutter!: number; @Prop({ default: 0 }) column!: number; @Prop({ default: null }) minWidth!: number | null; @Prop({ default: null }) maxWidth!: number | null; @Prop({ default: null }) breakpoint!: number | null; @Prop({ default: true }) transition!: boolean; @Prop({ default: "fade" }) transitionMode!: string; @Prop({ default: 300 }) transitionDuration!: number; private $slots = this.$slots; private $props = this.$props; private currentWidth: number = 0; private currentGutterSize: number = 0; private transitionDurationStyle

TypeScript
Guest
generate functionMon, 20 Mar 2023

Suma y resta

int add(int a, int b) { return a + b; } int sub(int a, int b) { return a - b; } int main() { int a = 0, b = 0; cin >> a; cin >> b; cout << add(a, b) << endl; cout << sub(a, b) << endl; return 0; }

C++
Guest
generate functionFri, 31 Mar 2023

arduino nanoで、奇数回ボタンを押せばサーボモータが動きながらLEDが光り、偶数回ボタンを押せばサーボモータが元の状態に戻り、LEDが消えるプログラムをC言語で書いてください。

#include <Servo.h> Servo myservo; int ledPin = 13; int servoPin = 9; int buttonPin = 2; int buttonValue = 0; int counter = 0; void setup() { myservo.attach(servoPin); pinMode(ledPin, OUTPUT); pinMode(servoPin, OUTPUT); pinMode(buttonPin, INPUT); } void loop() { buttonValue = digitalRead(buttonPin); if (buttonValue == HIGH) { counter++; digitalWrite(ledPin, HIGH); myservo.write(180); delay(1000); digitalWrite(ledPin, LOW); myservo.write(0); delay(1000); } else { if (counter % 2 == 1) { digitalWrite(ledPin, HIGH); myservo.write(180); delay(1000); digitalWrite(ledPin, LOW); myservo

C
Guest
code to explanationFri, 06 Jan 2023

if(dw_hourmeter_value >= HOUR_METER_MAX) /*if hour meter cross the maximum value, so roll-over hour meter value and trip meter shold rese...

the if statement checks the value of dw_hour_meter_value and if the value is greater or equal to the HOUR_METER_MAX then the value of dw_hour_meter_value is set to 0, the gsw_hour_meter_count is set to 0, the fnby_WritePort function is used to write 0 to the AMIL, the fnv_TripA_reset function and the fnv_TripB_reset function are called to reset the trip a and trip b variables.

Guest
generate functionFri, 31 Mar 2023

arduino nanoで、奇数回ボタンを押せばサーボモータが動きながらLEDが光り、偶数回ボタンを押せばサーボモータが元の状態に戻り、LEDが消えるプログラムをC言語で書いてください。

#include <Servo.h> Servo myservo; int ledPin = 13; int servoPin = 9; int buttonPin = 2; int buttonValue = 0; int counter = 0; void setup() { myservo.attach(servoPin); pinMode(ledPin, OUTPUT); pinMode(servoPin, OUTPUT); pinMode(buttonPin, INPUT); } void loop() { buttonValue = digitalRead(buttonPin); if (buttonValue == HIGH) { counter++; digitalWrite(ledPin, HIGH); myservo.write(180); delay(1000); digitalWrite(ledPin, LOW); myservo.write(0); delay(1000); } else { if (counter % 2 == 1) { digitalWrite(ledPin, HIGH); myservo.write(180); delay(1000); digitalWrite(ledPin, LOW); myservo

C
Guest
generate functionMon, 12 Dec 2022

get a list of users from active directory from police department, output to spreadsheet, order column by name

def get_police_users(department): import ldap import re from openpyxl import Workbook from openpyxl import load_workbook wb = Workbook() ws = wb.active # connect to active directory conn = ldap.initialize('ldap://ldap.yourdomain.com') # search for users in department in active directory results = conn.search_s('dc=yourdomain,dc=com', ldap.SCOPE_SUBTREE, "department=" + department, ['cn']) # create spreadsheet and add users in department to it ws.append(["Users"]) for result in results: ws.append([re.findall('(?<=cn=).*', result[1]['cn'][0].decode('utf-8'))[0]]) wb.save("output.xlsx") # open spreadsheet and sort by last name wb = load

Python
Guest
generate functionThu, 27 Jul 2023

La automotora “Auto Seguro” necesita registrar todos los datos de los vehículos que en este periodo tienen a la venta. En el registro de vehículos que pertenece a la región metropolitana de Santiago d...

vehiculos = [] def grabar(tipo, patente, marca, precio, multa_monto, multa_fecha, reg_fecha, dueño): vehiculos.append([tipo, patente, marca, precio, multa_monto, multa_fecha, reg_fecha, dueño]) def buscar(patente): for vehiculo in vehiculos: if vehiculo[1] == patente: print(vehiculo) return True return False

Python
Guest
code to explanationMon, 14 Nov 2022

function checkValidOrderId(orderid, account, platid, outputObject) { if (typeof orderid !== 'string') { throw new Error('参数错误,orderid非法'); } //格式:代理编号 +yyyyMMddHHmmssSSS+ account if (account !=...

function checkValidOrderIdOnly(s) { let len = s.length; if (len !== 17) throw new Error('参数错误,orderid非法'); let v = parseInt(s); if (!Number.isFinite(v)) throw new Error('参数错误,orderid非法'); let d = new Date(v); if (d.getTime() !== v) throw new Error('参数错误,orderid非法'); let now = Date.now(); if (v > now || v < now - 24 * 60 * 60 * 1000) throw new Error('参数错误,orderid非法'); }

Guest
generate functionSat, 03 Dec 2022

void型の関数 histgram2() は、4つの引数をもち、順に [0,100] の範囲の値を要素にもつint型の配列変数 a[]、配列 a[] のサイズを表すint型の値 n、および、ヒストグラムの値を代入するためのint型の配列変数 h[]、ヒストグラムの区間の幅を表す int型の値 m である。 histgram2() は、与えられた配列変数 a[] の要素の値が、[0,m-1], [m...

void histgram2(int a[], int n, int h[], int m) { int i, j, k; i = 0; j = 0; k = 0; while (i < n) { if (m * k <= a[i] && a[i] < m * (k + 1)) { h[k]++; } else { k++; h[k]++; } i++; } }

C
Guest
generate functionSun, 30 Apr 2023

Implementar una Calculadora de Números Enteros, mediante un proyecto de consola en C++, cuyo algoritmo permita: 1. Mostrar un menú de 6 opciones: • 1. Sumar dos números. • 2. Restar dos números. • 3. ...

#include <iostream> using namespace std; int menu(){ int option; cout << "1. Sumar dos numeros.\n"; cout << "2. Restar dos numeros.\n"; cout << "3. Multiplicar dos numeros.\n"; cout << "4. Dividir dos numeros.\n"; cout << "5. Número Primo?.\n"; cout << "6. Salir.\n"; cout << "Ingrese opción: "; cin >> option; return option; } int suma(int a, int b){ return a+b; } int resta(int a, int b){ return a-b; } int multiplicacion(int a, int b){ return a*b; } int division(int a, int b){ if (b == 0){ return 0; } return a/b; }

C++
Guest
generate functionSat, 03 Dec 2022

void型の関数 histgram2() は、4つの引数をもち、順に [0,100] の範囲の値を要素にもつint型の配列変数 a[]、配列 a[] のサイズを表すint型の値 n、および、ヒストグラムの値を代入するためのint型の配列変数 h[]、ヒストグラムの区間の幅を表す int型の値 m である。 histgram2() は、与えられた配列変数 a[] の要素の値が、[0,m-1], [m...

void histgram2(int a[], int n, int h[], int m) { int i, j, k; i = 0; j = 0; k = 0; while (i < n) { if (m * k <= a[i] && a[i] < m * (k + 1)) { h[k]++; } else { k++; h[k]++; } i++; } }

C
Guest
generate functionWed, 10 May 2023

Un carrusel de productos.

var products = [ { name: 'Galletas', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.' }, { name: 'Bebidas', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.' }, { name: 'Comida', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.' }, { name: 'Papas', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.' }, { name: 'Tortas', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.' }, ] var carousel = document.getElementById('carousel'); var html = ''; html += '<div class="products">' for (var i = 0; i < products.length; i++) { html += '<div class="product">'; html += '<

Javascript
Guest
generate functionThu, 01 Jun 2023

(Lista simplemente enlazada) Se pide a Ud. realizar un aplicativo en java correspondiente a una lista simplemente enlazada, la cual ejecute las siguientes instrucciones: • Insertar al inicio de la lis...

// 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

Java
Guest
generate functionFri, 05 May 2023

Programa en switch que realice 6 opciones q contenga en la opción 1 un programa con ciclo if en la opción 2 con if else opción 3 for opción cuatro while opcion 5 do while opción 6 salir

++ #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");

C
Guest
generate functionSat, 13 May 2023

Mínimo debe haber 2 empleado por cada cargo y solo 1 empleado por cargo debe estar en turno. (no debe haber identificación repetida, cuando se cree un empleado, se debe verifica que no exista el númer...

import java.util.Scanner; public class Empleado{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String nombre, cargo; int id, horario, salario, numeroID; boolean horarioTurno = false, identificacion = true; System.out.println("Ingrese el número de empleados a registrar: "); int numeroEmpleados = sc.nextInt(); for(int i=0; i < numeroEmpleados; i++){ if(numeroEmpleados <= 10){ System.out.println("Ingrese el nombre: "); nombre = sc.nextLine(); System.out.println("Ingrese el cargo: "); cargo = sc.nextLine(); System.out.println("Ingrese el número de identificación: "); numeroID = sc.nextInt(); System.out.println("

Java
Guest
code to explanationFri, 06 Jan 2023

if(dw_hourmeter_value >= HOUR_METER_MAX) /*if hour meter cross the maximum value, so roll-over hour meter value and trip meter shold rese...

the if statement checks the value of dw_hour_meter_value and if the value is greater or equal to the HOUR_METER_MAX then the value of dw_hour_meter_value is set to 0, the gsw_hour_meter_count is set to 0, the fnby_WritePort function is used to write 0 to the AMIL, the fnv_TripA_reset function and the fnv_TripB_reset function are called to reset the trip a and trip b variables.

Guest
generate functionTue, 25 Apr 2023

suponga que el precio unitario de las pelotas de baseball es de 6.50 dolares si se compran 10 o mas y 7.00 dolares en caso de comprar menos. imprima no solo el costo sino tambien el mensaje descuento o el mensaje sin descuento

#include <iostream> using namespace std; int main() { int n = 0; float costo = 0; cout << "Ingrese la cantidad de pelotas que desea comprar: \n"; cin >> n; if (n <= 10){ costo = n * 7.00; cout << "El valor total a pagar es: " << costo << " dolares" << endl; } else{ costo = n * 6.50; cout << "El valor total a pagar es: " << costo << " dolares" << endl; } return 0; }

C++
Guest
generate functionMon, 27 Mar 2023

1 2

def add(a, b): print(a) print(b) return a + b add(1, 2)

Python
Guest
generate functionTue, 02 May 2023

- uso de variables y condicionales - presentación al estilo PowerPoint - temática Animal (comision2) -- Los datos a evaluar son: - Debe haber al menos 3 pantallas, donde cada pantalla posea una ima...

/* 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() {

Java
Guest
generate functionTue, 18 Apr 2023

> m2 <- clm(categorical_FOD_FODs ~ 0 + Condition_FODs:Language_used_FODs - 1, random = ~1|subject, data = indvar_FODs) > summary(m2) formula: categorical_FOD_FODs ~ 0 + Condition_FODs:Language_used_FO...

#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")

generate functionWed, 21 Dec 2022

dice gambling script

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()

Python
Guest
ContactPrivacy Policyzigarettenautomatkarte.de