← 목록

Synth · CodeAlpaca일부

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

[output] | sum = 0 nums = [1, 2, 3, 4, 5] for num in nums: sum += num print(sum) # Output 15 [instruction] | Suppose you have a list of numbers and you want to add all the numbers together. Write a loop to do so. [input] | [1, 2, 3, 4, 5]

[output] | total = 0 nums = [1, 2, 3, 4, 5] for num in nums: total += num print(total) # Output 15 [instruction] | We have a list of numbers, what is the correct syntax for finding the sum of all the numbers? [input] | [1, 2, 3, 4, 5]

[output] | .card { border-radius: 10px; } [instruction] | Create a CSS class named "card" to create a card with border-radius = 10 px.. [input] |

[output] | p { font-size: 14px; } [instruction] | Create a CSS selector for all paragraph tags, which will set the font size to 14px. [input] |

[output] | <button>Submit</button> [instruction] | How can a developer create a button with the text "Submit" in HTML? [input] |

[output] | function assignOddOrEven(num){ let result; if(num % 2 === 0) { result = false; } else { result = true; } return result; } [instruction] | Write a JavaScript function to do the following: assign a value of "true" to a variable if the number is odd, and assign the value of "false" if the number is even. [input] | Number: 6

[output] | using System.Net; using System.IO; public static string GetPageTitle(string url) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { using (StreamReader reader = new StreamReader(response.GetRespons [instruction] | Gather data from the web page and write a C# program to extract the page title. [input] |

[output] | Je prends mon dîner à 20h. [instruction] | Translate the sentence "I'm having dinner at 8pm" into French. [input] |

[output] | let upperCaseString = 'hello'.toUpperCase(); [instruction] | Convert a string of characters to uppercase in JavaScript. [input] | String: hello

[output] | def insert_string(string1, string2, pos): return string1[:pos] + string2 + string1[pos:] [instruction] | Write a Python program to insert a given string at a specific position within another given string. [input] | string1 = 'Python is fun' string2 = 'awesome ' position = 7

[output] | def common_elements(list1, list2): common = [] for elem in list1: if elem in list2: common.append(elem) return common [instruction] | Given two lists, write a Python program to print all common elements in them. [input] | list1 = [10, 20, 30, 40] list2 = [30, 40, 50, 60]

[output] | def get_words(string1): words = string1.split() return words [instruction] | Design a program in Python which takes a string as input and returns a list of words from the string. [input] | string1 = 'Python Programming is Fun!'

[output] | def remove_even(lst): evens = [] for num in lst: if num % 2 != 0: evens.append(num) return evens [instruction] | Design a program in Python to remove all even elements from a given list. [input] | lst = [2, 4, 5, 6, 8, 10]

[output] | def is_increasing(lst): for i in range(len(lst)-1): if lst[i] >= lst[i+1]: return False return True [instruction] | Design a code to check if a given list is ordered in an increasing order. [input] | lst = [1, 2, 3, 5, 4]

[output] | def replace_last(lst, element): lst[-1] = element return lst [instruction] | Write a Python program to replace the last element in a list with another given element. [input] | lst = [1, 2, 3, 4] element = 5

[output] | def check_prime(n): if n == 1: return False for i in range(2, n): if n % i == 0: return False return True def print_prime_numbers(n): for num in range(1, n + 1): if check_prime(num): print(num) [instruction] | Modify the following given program to print all prime number between 1 and n [input] |

[output] | def calculate_std_dev(nums): mean = sum(nums)/len(nums) sum_deviation = 0 for num in nums: diff = num - mean squared_deviation = diff ** 2 sum_deviation += squared_deviation std_dev = (sum_deviation/(len(nums)-1)) ** 0.5 return std_dev [instruction] | Edit the following code to calculate the standard deviation of a given list [input] |

[output] | def fibonacci(n): a = 0 b = 1 if n < 0: print("Incorrect input") elif n == 0: return a elif n == 1: return b else: for i in range(2,n+1): c = a + b a = b b = c return b [instruction] | Modify the following code to generate the Fibonacci sequence up to the nth term [input] |

[output] | """ Retrieve tweets from a specific Twitter account """ import tweepy #Enter the respective information consumer_key = 'XXXXXXXXXX' consumer_secret = 'XXXXXXXXXX' access_token = 'XXXXXXXXXX' access_token_secret = 'XXXXXXXXXX' #Authentication using the given keys auth = tweepy.OAuthHandler(consu [instruction] | Write a code to retrieve tweets from a specific Twitter account by using their API. [input] | Twitter account: "@twitter"

[output] | """ Establish a connection between your server and a remote database """ import pymysql db = pymysql.connect(host='127.0.0.1', user='root', password='pw123', db='my_db') [instruction] | Write a code to establish a connection between your server and a remote database. [input] | Server host: 127.0.0.1 Database Name: my_db Username: root Password: pw123

[output] | import socket hostname = socket.gethostname() IPAddr = socket.gethostbyname(hostname) print("The IP address of the system is:" + IPAddr) [instruction] | Write a code to get the IP address of a system. [input] |

[output] | def unique_elements(arr): new_arr = [] for i in arr: if i not in new_arr: new_arr.append(i) return new_arr arr = [5, 10, 5, 7, 10] print(unique_elements(arr)) # [5, 10, 7] [instruction] | Create a code that removes all duplicate elements in a given array. [input] | Array: [5, 10, 5, 7, 10]

[output] | def insertionSort(arr): for i in range(1, len(arr)): key = arr[i] j = i-1 while j >= 0 and key < arr[j] : arr[j + 1] = arr[j] j -= 1 arr[j + 1] = key arr = [4, 3, 6, 1, 5] insertionSort(arr) print ("Sorted array is: ") for [instruction] | Write a code to implement insertion sort on a given list. [input] | List: [4, 3, 6, 1, 5]

[output] | def bubble_sort(arr): n = len(arr) for i in range(n): for j in range(0, n-i-1): for k in range(0, 3): if arr[j][k] > arr[j+1][k] : arr[j][k], arr[j+1][k] = arr[j+1][k], arr[j][k] arr = [[1, 5, 2], [8, 4, 6], [3, [instruction] | Modify a given code to sort a two-dimensional array (matrix) using bubble sort. [input] | Matrix: [[1, 5, 2], [8, 4, 6], [3, 7, 9]]

[output] | class Student: def __init__(self, name, age, course): self.name = name self.age = age self.course = course def get_info(self): return f"Name: {self.name}, Age: {self.age}, Course: {self.course}" student = Student("John Smith", 17, "Computer Science") pr [instruction] | Construct a Python class to represent a student with attributes such as name, age, and course. The class should have a method that returns the student information in a formatted output [input] | Student Name: John Smith Age: 17 Course: Computer Science

[output] | """ Create a text classifier using a Random Forest algorithm """ import pandas as pd from sklearn.ensemble import RandomForestClassifier # create the dataframe from the given input df = pd.DataFrame(columns=['text', 'category'], data=input) # define the features and labels X = df['text'] y = df[ [instruction] | Create a text classifier using a Random Forest algorithm. [input] | [['Ready Player One', 'Adventure'], ['IT', 'Drama'], ['Halloween', 'Horror'], ['Pirates of the Caribbean', 'Adventure']]

[output] | #import numpy library import numpy as np #create a 3x3 matrix with all elements 1 x = np.ones((3,3)) print(x) [instruction] | Write a code to create a 3x3 matrix with all elements 1. [input] |

[output] | """ Write a code to fetch the last 4 commits of a git repository """ import requests user = 'rnyagah' repo = 'GPT-Evaluation' url = f'https://api.github.com/repos/{user}/{repo}/commits' response = requests.get(url) data = response.json() # get the last 4 commits commits = data[:4] for commit i [instruction] | Write a code to fetch the last 4 commits of a git repository. [input] | user: 'rnyagah', repo: 'GPT-Evaluation'

[output] | """ Design a linked list data structure """ class ListNode: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def append(self, data): new_node = ListNode(data) if self.head is Non [instruction] | Design a linked list data structure. [input] |

[output] | """ Create a script to remove HTML tags from a web page """ import re html_string = input # remove all html tags using regex v = re.compile(r'<.*?>') cleaned_string = re.sub(v, '', html_string) print(cleaned_string) [instruction] | Create a script to remove HTML tags from a web page. [input] | <html> <head> <title>Example</title> </head> <body> <p>Welcome to example.com</p> </body> </html>

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