← 목록

Synth · CodeAlpaca일부

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

[output] | def word_frequency(words): freq = {} for word in words: if word not in freq: freq[word] = 0 freq[word] += 1 for word, count in freq.items(): print('{}: {}'.format(word, count)) word_frequency(['foo', 'bar', 'foo', 'baz', 'bar']) [instruction] | Given a list of words, write a Python function to print the frequency of occurrence of each word in the list. [input] | ['foo', 'bar', 'foo', 'baz', 'bar']

[output] | # Set up the project using a web framework such as Flask # Import necessary libraries such as Pandas, Numpy and SQLite # Create database and import recipe dataset # Create the user interface # Set up routes # Create a search form # Execute a SQL query to access the recipes that match the search quer [instruction] | Build a web application that allows users to search for recipes based on ingredients. [input] |

[output] | // Code in JavaScript const numbers = [2, 3, 6, 9, 5]; let max = numbers[0]; let min = numbers[0]; for(let i=0; i<numbers.length; i++){ if(numbers[i] > max){ max = numbers[i]; } if(numbers[i] < min){ min = numbers[i]; } } console.log('Max value is', max); console. [instruction] | Write a JavaScript program that given an array of integers, prints the maximum and minimum value of the array. [input] | numbers = [2, 3, 6, 9, 5]

[output] | SELECT * FROM Users; [instruction] | Write a query in SQL to display all records from the 'Users' table. [input] |

[output] | <html> <head> <title>Hello World</title> </head> </html> [instruction] | Format the following HTML tags correctly. [input] | <html><head> <title>hello world</title></head></html>

[output] | SELECT * FROM <table_name> ORDER BY <column_name> DESC; [instruction] | Write a query in MySQL to find all records in a table, sorted by a column in descending order. [input] |

[output] | SELECT * FROM <table_name> WHERE <column_name> > 50; [instruction] | Write a query in SQL to find all records where the value of a field is greater than 50. [input] |

[output] | package com.example.welcome; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends AppCompatActivity { @override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setConte [instruction] | Create an Android application with an activity that displays a string "Welcome to Android". [input] |

[output] | def calculateMedian(arr): n = len(arr) arr.sort() if n % 2 == 0: median1 = arr[n//2] median2 = arr[n//2 - 1] median = (median1 + median2) / 2 else: median = arr[n // 2] return median print("Median is: " + str(calculateMedian([5, 2, 6, 8, 10]) [instruction] | Implement a function in Python that calculates the median of a given input array. [input] | [5, 2, 6, 8, 10]

[output] | import Foundation let word = "Hello" let characters = word.prefix(3) print(characters) [instruction] | Make a Swift program to print out the first three characters of a given string. [input] | String word = "Hello";

[output] | string = "Hello World!" #Extract first 3 characters first_3_characters = string[0:3] print(first_3_characters) [instruction] | Extract the first 3 characters of an input string using Python. [input] | String = "Hello World!"

[output] | public class ReverseString { public void printReverseString(String s) { for(int i= s.length()-1; i>=0; i--) { char c = s.charAt(i); System.out.print(c); } System.out.println(); } } [instruction] | Create a method in Java that takes in a string and prints its contents in reverse. [input] | String s= "Hello World!"

[output] | import tensorflow as tf #get the dataset dataset = load_dataset() # create the input pipeline iterator = dataset.make_initializable_iterator() next_element = iterator.get_next() #build the model model=Sequential() #input layer model.add(Conv2D(32,(3,3), activation='relu',input_shape=(input_width, [instruction] | Use Tensorflow to classify a given input dataset of animals as cats or dogs. [input] | Input dataset contains images of cats and dogs.

[output] | class CollegeStudent: def __init__(self, name, year, major): self.name=name self.year=year self.major=major def get_name(self): return self.name def get_year(self): return self.year def get_major(self): return sel [instruction] | How would you define a class in Python to represent a college student? [input] |

[output] | for i in range(10): print(i) [instruction] | Update the following code so that it prints the numbers from 0-9 instead of 0-8. [input] | for i in range(8): print(i)

[output] | def Fibonacci(n): if n<0: print("Incorrect input") elif n==1: return 0 elif n==2: return 1 else: return Fibonacci(n-1)+Fibonacci(n-2) [instruction] | Develop a Python function to calculate a Fibonacci number based on a given index. [input] |

[output] | class Square { constructor(length) { this.length = length; } calcArea() { return this.length * this.length; } } [instruction] | In the given JavaScript class, add a method to calculate the area of a square. [input] | class Square { constructor(length) { this.length = length; } }

[output] | def averageMarks(student_mark_dict): total = 0 total_marks = 0 for key, value in student_mark_dict.items(): total += sum(value) total_marks += len(value) return total/total_marks [instruction] | Suppose you have a dictionary containing the records of some student marks. Write a Python program to calculate the average marks of all the students. [input] | student_mark_dict = { 'John': [50, 70, 60], 'Harry': [20, 60, 80], 'Tom': [90, 70, 80] }

[output] | class MyObject { constructor(elements) { this.elements = elements; } sumElements() { let sum = 0; this.elements.forEach(element => { sum += element; }); return sum; } } [instruction] | Add a method in JavaScript for an object to find the sum of all its elements. [input] | class MyObject { constructor(elements) { this.elements = elements; } }

[output] | def deleteDuplicates(string): unique_string = '' for i in string: if i not in unique_string: unique_string += i return unique_string [instruction] | Develop a function in Python to delete the duplicates of a given string. [input] | string = 'Hello World!'

[output] | integer [instruction] | What data type does the following variable belong to: 500? [input] |

[output] | def findNumber(array): return 15 in array [instruction] | A given array contains the numbers 1, 5, 9 and 13. Write a function to find out if 15 is present in the array or not. [input] | array = [1, 5, 9, 13]

[output] | div { display: block; } [instruction] | Develop a CSS selector to display all divs. [input] |

[output] | def countWords(string): return len(string.split()) [instruction] | Given a string, develop a function to find out how many words are present in it. [input] | string = 'Hello world!'

[output] | fahrenheit = lambda T : ( ( float(9) / 5 )*T + 32 ) [instruction] | Rewrite the following function as a lambda function. [input] | def fahrenheit(T): return ((float(9)/5)*T + 32)

[output] | A for loop is a type of loop used in programming to execute a set of code multiple times. For loops use an iterable object to iterate over a sequence of statements, such as a list or a string. For loops are typically used to traverse through a sequence of elements, perform a set of calculations or o [instruction] | Explain the use of a for loop in programming and when you would use it. [input] |

[output] | list = [1,2,3,4,5] evens = list(filter(lambda x: x % 2 == 0, list)) print(evens) [instruction] | Convert the following code from imperative style to functional style. [input] | list = [1,2,3,4,5] for x in list: if x % 2 == 0: print(x)

[output] | for x in range(0, 5): print(x) [instruction] | Add the missing parentheses and brackets for the for loop. [input] | for x range(0, 5): print(x)

[output] | for name in names: first_name, last_name = name.split(' ') print('First name: {} ; Last name: {}'.format(first_name, last_name)) # Output First name: John ; Last name: Smith First name: Alice ; Last name: Bryant First name: Bob ; Last name: Johnson First name: Harry ; Last name: Evans [instruction] | Parse the following list of names into separate strings. [input] | names = ["John Smith", "Alice Bryant", "Bob Johnson", "Harry Evans"]

[output] | C or C++ [instruction] | What language is the following code written in? [input] | for (i=0; i<n; i++)

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