← 목록

Synth · CodeAlpaca일부

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

[output] | import xml.etree.ElementTree as ET tree = ET.parse("file.xml") root = tree.getroot() for child in root: print(f"{child.tag}: {child.text}") [instruction] | Parse an XML document using Python. [input] |

[output] | <!DOCTYPE html> <html> <head> <title>Table</title> </head> <body> <table> <tr> <th>Name</th> <th>Address</th> <th>Phone</th> </tr> <tr> <td>John</td> <td>12 [instruction] | Create a HTML page to display a table in the following format. [input] |

[output] | SELECT COUNT(*) FROM students WHERE zipcode = 90001; [instruction] | Write a SQL query to find the number of students living in zipcode 90001. [input] |

[output] | import java.util.Scanner; public class SumIntegers { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Enter two integers: "); int first = scanner.nextInt(); int second = scanner.nextInt(); [instruction] | Write a Java program to accept two integers and find the sum of the two numbers. [input] |

[output] | var books = ["Learn Ruby", "Learn JavaScript"]; books.forEach(function(book) { console.log(book); }); [instruction] | Transform the following Ruby code into its JavaScript equivalent. [input] | books = ["Learn Ruby", "Learn JavaScript"] books.each do |book| puts book end

[output] | for num in range(16): if num not in [6, 7, 12]: print(num) [instruction] | Create a loop that prints out numbers from 0 to 15, except skip numbers 6, 7, and 12. [input] |

[output] | import random import string def generate_random_str(): letters = string.ascii_letters + string.digits return ''.join(random.choice(letters) for i in range(5)) [instruction] | Write a function in Python to generate a random alphanumeric string with a length of 5 characters. [input] |

[output] | SELECT name, population FROM us_cities ORDER BY population DESC LIMIT 10; [instruction] | Write a query that returns the first 10 cities in the US table sorted by population in descending order. [input] |

[output] | <html> <head> <title>A Sample HTML Page</title> </head> <body> <form> <input type="text" id="input-field" /> <input type="submit" value="Submit" /> </form> <table> <tr> <th>Results</th> </tr> <tbody id="results-table"> </tbo [instruction] | Create a HTML page containing an input field, a submit button and a table for displaying the results. [input] |

[output] | def infer_type(expression): return type(eval(expression)) [instruction] | Write a code to infer the data type of an lambda expression. [input] |

[output] | ls -lt [instruction] | Create a bash program to list the contents of a directory in reverse alphabetical order. [input] |

[output] | The longest common substring of the list [1, 2, 3, 4, 5, 3, 2, 6] is "3, 2". The length of the common substring is 3. [instruction] | Given a list of integers, find the lengthiest common substring of the list. [input] | [1, 2, 3, 4, 5, 3, 2, 6]

[output] | import requests import json url = 'https://imdb-api.com/documentation/top-rated/all}' response = requests.get(url) data = json.loads(response.text) movies = data['results'][:10] for movie in movies: title = movie['title'] rating = movie['rating'] print(f"{title}: {rating}") [instruction] | Write code in Python to retrieve the top 10 Rated Movies in IMDB. [input] |

[output] | The complexity of an iterative mergesort algorithm is generally O(nlog(n)). It is a divide-and-conquer type of algorithm which splits a list of elements into its two halves, sorts each half recursively, and then merges the sorted halves. This means that the algorithm has a time complexity of O(log(n [instruction] | What is the complexity of an iterative mergesort algorithm? [input] |

[output] | def highest_odd_number(numbers): highest = 0 for number in numbers: if number % 2 != 0 and number > highest: highest = number return highest [instruction] | Edit the code in Python so that the function returns the highest odd number in the list. [input] | def highest_odd_number(numbers): highest = 0 for number in numbers: if number % 2 != 0 and number > highest: highest = number return number

[output] | import random def generate_random_string(characters): random_string = "" for i in range(10): random_string += random.choice(characters) return random_string characters = 'abcdefghijklmnopqrstuvwxyz' print(generate_random_string(characters)) [instruction] | Create a program in Python to generate a random string using the given characters. [input] | characters = 'abcdefghijklmnopqrstuvwxyz'

[output] | names = ["Alice", "Bob", "Peter", "John"] phone_numbers = ["1234567", "7654321", "246810", "13579"] name_and_phone = dict(zip(names, phone_numbers)) print(name_and_phone) [instruction] | Write code in Python to create a dictionary with names as keys and phone numbers as values. [input] | names = ["Alice", "Bob", "Peter", "John"] phone_numbers = ["1234567", "7654321", "246810", "13579"]

[output] | def check_name(name): """Check whether the name is a string""" assert isinstance(name, str), "name must be a string" def greet_to(name): """Print a greeting to the name provided.""" check_name(name) print("Hello, " + name + "!") [instruction] | Reorganize the given Python code such that two functions are created. [input] | def greet_to(name): """Print a greeting to the name provided.""" # assert name is a string assert isinstance(name, str), "name must be a string" print("Hello, " + name + "!")

[output] | <a href="https://www.example.com">Click Here</a> [instruction] | Create a HTML code to make a hyperlink of "https://www.example.com" that shows the text "Click Here". [input] |

[output] | SELECT * FROM Products WHERE price > 50; [instruction] | Using the data provided, write a SQL query that returns all products with a price higher than $50. [input] | Table: Products | productId | productName | price | |-----------|-------------|-------| | 101 |T-shirt | 25 | | 102 | Table | 90 | | 103 | Phone | 30 | | 104 | Shoes | 65 | | 105 |Laptop | 120 |

[output] | var popupWindow = window.open("", "", "width=600,height=400"); [instruction] | Write a JavaScript code snippet to open a pop-up window with a width of 600px and a height of 400px. [input] |

[output] | 1. Start with an initial guess for the square root, ‘x’. 2. Calculate the value of ‘x2’. 3. If the square of ‘x’ is close enough to the given number, then ‘x’ is the square root of the given number. 4. If the calculated value of ‘x2’ is not close enough to the given number, then reduce the differenc [instruction] | Write an algorithm for finding the square root of a number. [input] |

[output] | def reverseString(testString): reversedString = "" for char in testString: reversedString = char + reversedString return reversedString print(reverseString(testString)) [instruction] | Write an efficient Python program to reverse a string. [input] | testString = "Hello World"

[output] | for element in input_list: print(element) [instruction] | Replace the “TODO” comment in the code with the proper code to print each element of the list on a new line using Python. [input] | input_list = [10, 15, 20, 25, 30]

[output] | my_object = { 'element1': 1, 'element2': 2, 'element3': 3 } [instruction] | Construct an object in Python containing three elements. [input] |

[output] | my_dictionary = { 'Name': 'John', 'Age': 35 } [instruction] | Convert this JSON string into a dictionary in Python: {"Name": "John", "Age": 35}. [input] | {"Name": "John", "Age": 35}

[output] | .center { width: 100px; margin: 0 auto; } [instruction] | Create a CSS class to center an element with a width of 100px. [input] |

[output] | my_text = "Hello World!" [instruction] | Store the text "Hello World!" in a variable in Ruby. [input] |

[output] | my_array = [1,2,3,4,5] [instruction] | Construct an array in JavaScript containing five elements. [input] |

[output] | import requests url = "http://openlibrary.org/api/books" querystring = {"bibkeys":"ISBN:0201558025","format":"json","jscmd":"data"} headers = { 'cache-control': "no-cache", } response = requests.request("GET", url, headers=headers, params=querystring) print(response.text) [instruction] | Construct an API call in Python that returns information about a given book. [input] |

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