← 목록

Synth · CodeAlpaca일부

총 20,022개 · 페이지 424/668
🔀 랜덤
불러오는 중…

[output] | <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $name = $_POST['name']; $age = $_POST['age']; // Store data in database $servername = "localhost"; $username = "root"; $password = ""; $dbname = "myDB"; // Connect to database $conn = new mysqli($servername, $use [instruction] | Create a PHP program to store data submitted by an HTML form. [input] |

[output] | function truncateString(str, num) { if (str.length <= num) { return str; } return str.slice(0, num) + "..."; } [instruction] | Write a function in JavaScript to truncate a string to a given length. [input] |

[output] | function myFunction(str) { // code here } [instruction] | Create a function in Javascript that accepts a string as an argument. [input] |

[output] | int listLength = sizeof(list) / sizeof(list[0]); printf("Number of elements in the list: %d \n", listLength); [instruction] | Print the number of elements present in a list in C. [input] | int list[20] = {1, 4, 6, 8, 9};

[output] | Scanner input = new Scanner(System.in); System.out.println("Please enter a number: "); int number = input.nextInt(); [instruction] | Write code in Java for a user input prompt that states "Please enter a number". [input] |

[output] | def rgb_to_hex(rgb_color): hex_code = '' for color in rgb_color: hex_code += f'{color:02x}' return hex_code hex_code = rgb_to_hex(rgb_color) # hex_code = "ffe89a" [instruction] | Implement a function in Python to convert a given RGB color to Hexadecimal format. [input] | rgb_color = [255, 232, 154]

[output] | SELECT * FROM mytable WHERE mycolumn > 5; [instruction] | Create a SQL query to select the records of the table with column value greater than 5. [input] |

[output] | MOV AX, 12 ; Move 12 to AX MOV BX, 12 ; Move 12 to BX CMP AX, BX ; Compare AX and BX JE Equal ; Jump if equal JNE NotEqual ; Jump if not equal Equal: ;Statements NotEqual: ;Statements [instruction] | Write an assembly language program to check if two given numbers are equal or not. [input] |

[output] | int num1 = 10; int num2 = 5; int result = num1 * num2; printf("Result: %d\n", result); [instruction] | Generate C code that prints the result of multiplying two numbers. [input] | int num1 = 10 int num2 = 5

[output] | package main import ( "net/http" "fmt" ) func main() { http.HandleFunc("/", handlerFunc) http.ListenAndServe(":8080", nil) } func handlerFunc(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "<h1>Welcome to my Go web server!</h1>") } [instruction] | Write code to create a web server in Go. [input] |

[output] | fn main() { let numbers = [1, 4, 6, 8]; let sum = 0; for num in numbers.iter() { sum += num; } println!("The sum of the elements in the array is {}", sum); } [instruction] | Write a Rust program to take an array of integers and print the sum of the elements in the array. [input] |

[output] | <button style="font-size: 20px; color: rgb(255, 0, 128); background-color: #6790FF;">Click Here</button> [instruction] | Create a one-click web button with the following properties: font size of 20px; font color rgb(255, 0, 128); background-color #6790FF [input] |

[output] | def query_trips(): start_date = datetime.datetime.now() - datetime.timedelta(days=90) end_date = datetime.datetime.now() sql = 'SELECT * FROM trips WHERE date_of_trip >= %s AND date_of_trip <= %s' try: conn = connect_to_database() cur = conn.cursor() cur. [instruction] | Write a function to query a database table 'trips' and return a list of all trips made over the past three months. [input] |

[output] | def insert_row_products(title, description, price): sql = 'INSERT INTO products (title, description, price) VALUES (%s, %s, %s)' try: conn = connect_to_database() cur = conn.cursor() cur.execute(sql, (title, description, price)) conn.commit() cur.close [instruction] | Design an algorithm to insert a new row into a table named 'products' with the following columns: title, description and price. [input] | title: "New product" description: "This is an amazing product, it can do anything!" price: 10

[output] | def add_user(name, email, password, address): sql = 'INSERT INTO users (name, email, password, address) VALUES (%s, %s, %s, %s)' try: conn = connect_to_database() cur = conn.cursor() cur.execute(sql, (name, email, password, address)) conn.commit() cur. [instruction] | Write an algorithm to add a new user (name, email, password, address) to a table called 'users'. [input] | name: John email: john@example.com password: 1234 address: 999 Main St.

[output] | print('Hello World!') [instruction] | Edit the following snippet of code to make the program print 'Hello World!' [input] | print('Hello world)

[output] | def count_number(arr, number): count = 0 for num in arr: if num == number: count += 1 return count [instruction] | Write an algorithm to find the number of times a given number appears in an array [input] | [5, 2, 4, 2, 5, 2, 5], number: 5

[output] | def reverse_string(string): rev_string = '' for i in range(len(string) - 1, -1, -1): rev_string += string[i] return rev_string [instruction] | Reverse a given string without using built-in library functions [input] |

[output] | print("my_list is a collection of:", my_list) [instruction] | Use the input provided to print out the name of the collection of items provided. [input] | my_list = ["apple", "banana", "orange"]

[output] | for item in sample_stack: print(item) [instruction] | Write a for loop in Python which prints out the contents of the given stack. [input] | sample_stack = ["first", "second", "third"]

[output] | x = y = 0 [instruction] | Edit the statement to make it a valid expression in Python. [input] | x = y =

[output] | second_dict = data.get('second') for key, value in second_dict.items(): print(key, value) [instruction] | Write a script in Python for printing the given second level sub-dictionary. [input] | data = {'first': {'A': 1, 'B': 2}, 'second': {'C': 3, 'D': 4}}

[output] | let largestNumber = my_array[0]; for (let i = 1; i < my_array.length; i++) { if (largestNumber < my_array[i]) { largestNumber = my_array[i]; } } console.log(largestNumber); [instruction] | Using the input provided, write a program in JavaScript that finds the largest number in an array. [input] | my_array = [2, 3, 6, 1, 9]

[output] | for (int i = 0; i < my_list.length; i++) { for (int j = i + 1; j < my_list.length; j++) { if (my_list[i] > my_list[j]) { int temp = my_list[i]; my_list[i] = my_list[j]; my_list[j] = temp; } } } [instruction] | Write a code in Java to sort given list items in ascending order. [input] | my_list = [9, 4, 7, 2, 6]

[output] | for key, value in my_dict.items(): print(key + ':', value) [instruction] | Using the input provided, write a code in Python to print the elements of a given dictionary along with the corresponding keys. [input] | my_dict = {'one':1, 'two':2, 'three':3}

[output] | int max(int a, int b, int c) { int big = a; if(b > big) big = b; if(c > big) big = c; return big; } [instruction] | Create a program in C to find the biggest of three numbers. [input] |

[output] | model = tf.keras.Sequential() model.add(tf.keras.layers.Input(shape=(1000,))) model.add(tf.keras.layers.Dense(units=128, activation='relu')) model.add(tf.keras.layers.Dense(units=2, activation='softmax')) model.compile(optimizer='Adam', loss = 'categorical_crossentropy',metrics=['accuracy']) mo [instruction] | Using TensorFlow, define a neural network for classifying a set of language data as either English or Spanish. [input] | Training data of 1000 samples with 500 English sentences and 500 Spanish sentences.

[output] | const dateOne = new Date("2021/07/26"); const dateTwo = new Date("2022/06/01"); const timeDifference = dateTwo.getTime() - dateOne.getTime(); const daysDifference = timeDifference / (1000 * 3600 * 24); console.log(daysDifference); [instruction] | Write a JavaScript program to compute the difference between two dates in days. [input] | Two dates- "2021/07/26" and "2022/06/01"

[output] | import React from 'react'; const Navbar = () => { return ( <nav> <div className="logo"> Logo </div> <ul> <li>Home</li> <li>About</li> </ul> </nav> ) } export default Navbar; [instruction] | Create a React component for a navigation bar with a logo and two menu items named "Home" and "About". [input] |

[output] | public class Point { double x,y; public Point(double x, double y) { this.x = x; this.y = y; } public double getX() { return x; } public double getY() { return y; } public void setX(double x) { this.x = x; } public void setY(double y) { this.y = y; } public double d [instruction] | Design a class in Java for creating a 2D point. [input] |

← → 방향키로 페이지 이동 · 숫자 입력 후 Enter로 점프