← 목록

Synth · CodeAlpaca일부

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

[output] | def calculate_expression(expression): return eval(expression) [instruction] | Write a function to obtain the result of a given mathematical expression. [input] | 2 + 3 - 5

[output] | def base_conversion(num, base_from, base_to): if base_from == 10: num = int(num, base_to) elif base_to == 10: num = int(str(num), base_from) else: num = int(str(int(str(num), base_from)), base_to) return num [instruction] | Suggest a solution to convert a given number from one base to another. [input] |

[output] | import java.awt.BorderLayout; import java.awt.event.*; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; class Reverse extends JFrame { JTextField inputTF; JTextField outputTF; JButton reverseBtn; Reverse() { inputTF = [instruction] | Develop a GUI application in Java to reverse a string. [input] | User should be able to enter a string in the text field.

[output] | SELECT E.Name FROM EMPLOYEES E INNER JOIN (SELECT DEPARTMENT, AVG(SALARY) AVG_SALARY FROM EMPLOYEES GROUP BY DEPARTMENT ) T ON E.DEPARTMENT = T.DEPARTMENT WHERE E.SALARY > T.AVG_SALARY [instruction] | Create a SQL query to find all employees whose salary is greater than the average salary of their department. [input] | Table of Employees: ID | Name | Department | Salary

[output] | const moment = require('moment-timezone'); const timezone = 'America/New_York'; const currentTime = moment().tz(timezone).format('h:mm a z'); console.log(`The current time in ${timezone} is ${currentTime}`); [instruction] | Develop a Node.js program that prints out the current time in a specified timezone. [input] |

[output] | import React, { useState } from "react"; function SumInput() { const [number1, setNumber1] = useState(""); const [number2, setNumber2] = useState(""); const [sum, setSum] = useState(0); const handleNumber1Change = e => setNumber1(e.target.value); const handleNumber2Change = e => setNumbe [instruction] | Develop a ReactJS program that displays the sum of two number inputs. [input] | The two numbers that the user will input should be positive integers.

[output] | fit <- lm(y ~ x,data) summary(fit) [instruction] | Develop a code to perform linear regression in R [input] |

[output] | func searchIndex(arr: [Int], target: Int) -> Int? { for index in 0..<arr.count { if arr[index] == target { return index } } return nil } [instruction] | Develop a Swift program that returns the index of a given element in an array. [input] | Given an array of integers and a target element.

[output] | class PrimeNumber{ public static void main(String args[]){ int i,m=0,flag=0; int n=100;//it is the number to be checked m=n/2; for(i=2;i<=m;i++){ if(n%i==0){ System.out.println("Number is not prime"); flag=1; break; } } if(flag==0 [instruction] | Create an algorithm in Java that prints the prime numbers between 1 and 100. [input] |

[output] | function findMax(arr) local maxValue = -math.huge for i = 1, #arr do if arr[i] > maxValue then maxValue = arr[i] end end return maxValue end [instruction] | Generate a code in Lua to find the maximum number in a given array. [input] |

[output] | my_dict = dict(zip(keys, values)) [instruction] | Use the information provided to initialize a dictionary in Python. [input] | keys = ["name", "age", "gender"] values = ["John Doe", 25, "Male"]

[output] | sum = x ^ y + (x & y) << 1 # using bitwise operators [instruction] | Compute the sum of two integers without using the "+" operator. [input] | x = 5 y = 7

[output] | my_dict.update({"key1": 4, "key2": 8}) [instruction] | Update the dictionary values using the same keys. [input] | my_dict = {"key1": 3, "key2": 6}

[output] | total = 0 for num in my_list: total += num print(total) # 20 [instruction] | Calculate the total of all the elements in the list using a loop. [input] | my_list = [2, 5, 9, 4]

[output] | student_list = [[student[0], student[1]] for student in students] [instruction] | Create a list of students which contains a nested list of the student’s name and age. [input] | students = ["Sam", 19], ["Alice", 20], ["Linda", 21]

[output] | c = a if a > b else b [instruction] | Change the following if-else expression to a ternary operator [input] | a = 10 b = 5 if a > b: c = a else: c = b

[output] | def absolute_difference(x, y): return abs(x - y) [instruction] | Define an absolute difference function in Python to find the difference between two numbers. [input] |

[output] | <a href="https://www.example.com" target="_blank">Example</a> [instruction] | Edit the following HTML tag to make the link open in a new tab. [input] | <a href="https://www.example.com">Example</a>

[output] | Instruction [instruction] | Classify the following sentence as a declaration or an instruction [input] | Be careful while crossing the street.

[output] | common_elements = [element for element in list1 if element in list2] print(common_elements) #[14] [instruction] | Given two lists, write a Python code to find the common elements in both the lists [input] | list1 = [3, 7, 14, 19] list2 = [6, 8, 14, 17]

[output] | The continue keyword can be used to skip over certain elements in a loop body. It is often used to skip over certain unwanted elements. It works by returning to the loop condition by stopping the current iteration of the loop and jumping straight to the next iteration. [instruction] | Explain the use of the continue keyword in Python [input] |

[output] | import random random_string = "".join(random.choices(data, k=5)) print(random_string) #helll or olleh or leloh or any other combination [instruction] | Using the following data, generate a random string in Python [input] | data = [“H”, “e”, “l”, “l”, “o”]

[output] | import unittest class TestBubbleSort(unittest.TestCase): def test_sort(self): arr = [5, 2, 3, 7, 1] bubble_sort(arr) self.assertEqual(arr, [1, 2, 3, 5, 7]) if __name__ == '__main__': unittest.main() [instruction] | Generate a unit test for the following bubble sort algorithm [input] | def bubble_sort(arr): n = len(arr) for i in range(n-1): for j in range(0, n-i-1): if arr[j] > arr[j+1] : arr[j], arr[j+1] = arr[j+1], arr[j]

[output] | import nltk from nltk.tokenize import word_tokenize sentence = "It's raining cats and dogs" tokens = word_tokenize(sentence) tagged = nltk.pos_tag(tokens) print(tagged) #[('It', 'PRP'), ("'s", 'VBZ'), ('raining', 'VBG'), ('cats', 'NNS'), ('and', 'CC'), ('dogs', 'NNS')] [instruction] | Write a Python code to classify the following sentence [input] | It's raining cats and dogs

[output] | A = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]] [instruction] | Construct a 2-dimensional array, A, of size M*N, filled with all zeroes. [input] | M=4, N=5

[output] | def display_first_lesson(lessons): print("The first lesson is: " + lessons[0]) Lessons = ["Python Basics", "Javascript Basics", "C++ Basics", "Data Structures", "Object-Oriented Programming"] display_first_lesson(Lessons) [instruction] | Given a course consisting of 5 lessons, write a program to display the first lesson. [input] | Lessons = ["Python Basics", "Javascript Basics", "C++ Basics", "Data Structures", "Object-Oriented Programming"]

[output] | <a style="color: blue; font-weight: bold" href="index.html">Home</a> [instruction] | Add styling to the HTML anchor tag. [input] | <a href="index.html">Home</a>

[output] | dictionary['key'] = 'updated value' [instruction] | Assign a value to a given key in a dictionary. [input] | dictionary = {'key': 'value'}

[output] | "Hola" [instruction] | Translate the text "Hello" to Spanish. [input] |

[output] | import functools array = [2, 7, 3, 8, 5] smallest = functools.reduce(lambda x,y: x if x < y else y, array) print(smallest) [instruction] | Find the smallest number in the array using the reduce method. [input] | array = [2, 7, 3, 8, 5]

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