text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
[DE Wikipedia] Gotthardleitung
Die Gotthardleitung ist eine 1958 von Motor-Columbus errichtete Drehstrom-Hochspannungsleitung über den Gotthardpass von Mettlen bei Inwil nach Airolo. Eigentümer der Gotthardleitung ist die schweizerische Netzgesellschaft Swissgrid. Linienführung Auf dem 52 Kilometer langen Abschnitt vo... | null | null | null |
[HI Wikipedia] बास्किन-रॉबिन्स
बास्किन-रॉबिन्स एक श्रृंखला है आइसक्रीम प्रतिष्ठानों है कि प्रकृति में वैश्विक है, बर्ट Baskin और Irv रॉबिन्स 1953 में स्थापना की। उत्पादित आइसक्रीम में शामिल किया गया है Glendale, कैलिफोर्निया. कंपनी भी आइसक्रीम 5.800 से अधिक स्थानों, जिसमें से 2.800 शाखाओं संयुक्त राज्य अमेरिका में उपल... | null | null | null |
null | Write an HTML page to display a form for user registration. | <!DOCTYPE html> <html> <head> <title>User Registration Form</title> </head> <body> <h1>User Registration Form</h1> <form> <input type="text" name="name" placeholder="Enter your name"> <input type="email" name="email" placeholder="Enter your email"> <input type="password" name="password" placeholder="Enter your password... | |
null | Create a SQL statement that changes the value of a column in the "students" table. | student_id = 123 new_score = 90 | UPDATE students SET score = 90 WHERE student_id = 123; |
null | Using Python, write a piece of code to convert Celsius temperatures to Fahrenheit. | Celsius: 20 | Fahrenheit = 68 |
null | Write a Python class for storing student ID and name | class Student:
def __init__(self, student_id, name):
self.student_id = student_id
self.name = name
def get_details(self):
return self.student_id, self.name | |
null | Write a Python code to sort the names into ascending order. | names = ["Vladimir Putin","Joe Biden","Xi Jinping"] | names.sort() |
null | Find the largest value in an array of numbers. | [5, 9, 40, 0.5, 3] | 40 |
null | Create a CSS style for a div element to have a width of 200px and a height of 50px. | div { width: 200px; height: 50px; } | |
null | Compute the hamming distance between two strings and print the result. | String1: 'hello' String2: 'world' | """ Compute the hamming distance between two strings and print the result """ def calc_hamming_distance(str1, str2): # Calculate the hamming distance dist = 0 for i, j in zip(str1, str2): if i != j: dist+=1 # Print the Hamming Distance print('Hamming Distance: ', dist) calc_hamming_distance('hello','world') |
null | Convert the HTML code below to its corresponding DOM elements. | <div> <p>Hello, World!</p> </div> | // Create a `div` element let divElement = document.createElement('div'); // Create a `p` element let pElement = document.createElement('p'); // Add the content to the `p` element pElement.textContent = 'Hello, World!'; // Append the `p` element to the `div` element divElement.appendChild(pElement); |
null | Create a Python Exception to handle Nonetype Error. | try: my_list = [1, 2, 3] my_list[3] except TypeError: print("Error: Nonetype Found") | |
null | Create an artificial neural network in Python to predict the stock price for a given company. | Historical stock price data for the company. | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import MinMaxScaler
from keras.models import Sequential
from keras.layers import LSTM, Dense
df = pd.read_csv(input_data)
# feature scaling
sc = MinMaxScaler(feature_range= (0,1))
df_scaled = sc.fit_transform(df... |
[DE Wikipedia] Willi Ulfig
Willi Ulfig (* 26. November 1910 in Breslau; † 5. Februar 1983 in Regensburg) war ein deutscher Maler und Graphiker. Leben Nach dem Studium an der Breslauer Kunstgewerbeschule (bei Peter Kowalski) und Kunstakademie 1928 bis 1932 verbrachte er ein halbes Jahr als Stipendiat der Kunstakademie ... | null | null | null |
null | Develop a Python generator to generate all prime numbers in range of 0 - 100. | def generate_prime_numbers(n):
for num in range(2, n):
prime = True
for i in range(2, num):
if num % i == 0:
prime = False
break
if prime:
yield num
for prime_number in generate_prime_numbers(100):
print(prime_number) | |
null | Design a function to clean binary data (strings) by keeping only printable characters. | binary_data = b'h\x9Fl\x04o' | def clean_binary_data(binary_data): return ''.join(map(lambda x:chr(x) if 32 <= x <= 126 else '', binary_data)) |
null | Describe what is a linked list data structure in 10 words or less. | A linear data structure of linked nodes. | |
null | Generate a random 6 character string in Python | import string
import random
characters = string.ascii_lowercase + string.digits + string.ascii_uppercase
password = "".join(random.choice(characters) for x in range(6))
print(password) | |
null | Compose a function that takes in two strings and produces an array of characters that are only in the first string. | stringA = "abcdefg" stringB = "hijklmn" | def to_array(strA, strB): output = [] for char in strA: if char not in strB: output.append(char) return output result = to_array(stringA, stringB) print(result) |
null | Develop a Python program to optimize the given linear equation using the simplex method. | Maximise: 2x + 4y
Subject to:
x + 2y ≤ 14
3x – 4y ≤ 18
x ≥ 0, y ≥ 0 | def simplex(resultMatrix):
n = len(resultMatrix[0]) - 1
c = []
for i in range(n):
c.append(resultMatrix[0][i])
a = []
for i in range(1, len(resultMatrix)):
a.append(resultMatrix[i][:n])
b = []
for i in range(1, len(resultMatrix)):
b.append(resultMatrix[i][n])
# Initialize the basic an... |
null | Write a function to classify a text as positive or negative. | text = "This is an amazing product." | def classify_text(text): score = 0 words = text.split(" ") for word in words: if word in positive_words: score += 1 elif word in negative_words: score -= 1 if score > 0: return "positive" elif score == 0: return "neutral" else: return "negative" |
null | Generate Python Plotly chart that shows the trend of stock prices over the past 3 years. | Apple (AAPL) Stock Prices | import plotly.offline as py
import plotly.graph_objs as go
import pandas as pd
# Read in the data
data = pd.read_csv('AAPL_data.csv')
# Create traces
apple_trace = go.Scatter(
x = data['date'],
y = data['close'],
name = 'Apple'
)
# Create the layout
layout = go.Layout(
title = 'Apple Stock Price Tren... |
[HI Wikipedia] राष्ट्रीय खनन शोध संस्थान
राष्ट्रीय खनन शोध संस्थान या इंडियन स्कूल ऑफ माइंस भारत के खनन संबंधी शोध संस्थानों में सबसे प्रमुख है। यह संस्थान नवनिर्मित झारखंड प्रान्त के धनबाद नामक शहर में स्थित है। बहिर्गामी कडीयाँ राष्ट्रीय खनन शोध संस्थान वेबसाइट (अंग्रेज़ी) | null | null | null |
null | Write a code to convert a given spredsheet in csv format to json format. | import csv import json def csv_to_json(): # Path of csv file file_csv = 'mycsvfile.csv' # Path of json file file_json = 'myjsonfile.json' with open(file_csv, 'r') as input_file: reader = csv.DictReader(input_file) data = list(reader) with open(file_json, 'w') as output_file: json.dump(data, output_file) csv_to_json() | |
null | Create a class in Python that checks if a given integer is prime. | class PrimeChecker:
def __init__(self, number):
self.number = number
def is_prime(self):
for i in range(2, self.number // 2):
if self.number % i == 0:
return False
return True
# Create an instance of PrimeChecker
prime_checker = PrimeChecker(7)
# Check if ... | |
[CS Wikipedia] Civilizační konflikt v Súdánu
Střet civilizací podle Samuela Huntingtona V roce 1993 vyšel vědecký článek Střet civilizací? od amerického profesora politologie Harvardovy univerzity Samuela Huntingtona, který vyvolal rozporuplné reakce. Zatímco většina autorů doby mluvila o usmíření, Huntington hovoří o... | null | null | null |
null | Edit the given code to delete a node from a linked list | void deleteNode(struct node *node) { struct node *temp = node->next; node->data = temp->data; node->next = temp->next; free(temp); } | void deleteNode(struct node *node) { struct node *temp = node->next; node->data = temp->data; // Store pointer to the next of node struct node *next_next = temp->next; // Unlink node from linked list free(temp); node->next = next_next; } |
null | Develop a program in Python to extract the substring between two given strings | input_string = "This is an example string"
start_string = "an"
end_string = "string" | import re
input_string = "This is an example string"
start_string = "an"
end_string = "string"
regex = re.compile(start_string + '(.*?)' + end_string)
result = re.search(regex, input_string)
if result:
print(result.group(1)) |
null | Write a python program to sort a given list of tuples based on its first element in increasing order. | [(3, 'ape'), (1, 'cat'), (4, 'dog'), (2, 'bee')] | def sortTuplesByFirstElement(lst):
lst.sort(key = lambda x: x[0])
return lst
sortedList = sortTuplesByFirstElement([(3, 'ape'), (1, 'cat'), (4, 'dog'), (2, 'bee')])
print(sortedList) |
[HI Wikipedia] जम्मू और कश्मीर
जम्मू और कश्मीर (Jammu and Kashmir,J&K) ५ अगस्त २०१९ तक भारत का एक राज्य था जिसे अगस्त २०१९ में द्विभाजित कर जम्मू और कश्मीर एवं लद्दाख नामक दो केंद्र शासित प्रदेश के रूप में स्थापित कर दिया गया। यह राज्य पूर्वतः ब्रिटिश भारत में जम्मू और कश्मीर रियासत नामक शाही रियासत हुआ करता था। इस रा... | null | null | null |
null | Find the frequency of each letter in the given string. | string = "banana" | freq = {} for i in string: if i in freq: freq[i] += 1 else: freq[i] = 1 # freq is {'b': 1, 'a': 3, 'n': 2} |
null | What is the ASCII character for the code “97”? | The ASCII character for the code “97” is 'a'. | |
[EN Wikipedia] Mbwasa language
The Mbwasa language is a Southern Bantoid language of Cameroon. It is very similar to Ki, and is sometimes considered a dialect of it. References Blench, Roger, 2011. The membership and internal structure of Bantoid and the border with Bantu. Bantu IV, Humboldt University, Berlin. Mbam l... | null | null | null |
null | You are given some HTML code, write a function to strip the tags from it. | def strip_tags(string): stripped_str = '' skip = False for i in range(len(string)): if string[i] == '<' and skip == False: skip = True elif string[i] == '>': skip = False elif skip == False: stripped_str += string[i] return stripped_str | |
null | Construct an XML document using Python which contains the following data. | Item1, Item2, Item3 | import xml.etree.ElementTree as ET
# creating the root element
data = ET.Element('data')
items = ['Item1', 'Item2', 'Item3']
# loop over items
for item in items:
# creating sub elements
item_element = ET.SubElement(data, 'item')
# assign the value for the sub elements
item_element.text = item
# wri... |
null | Write a python program to parse and print out the name, email, and phone number from a given string. | John Doe, foobar@example.com, 123-456-7890 | def parse_contact_info(string):
name = string.split(", ")[0]
email = string.split(", ")[1]
phone_number = string.split(", ")[2]
print(f"Name: {name} \nEmail: {email} \nPhone Number: {phone_number}") |
null | Write a SQL query to select all entries in a given table with a value larger than 100. | SELECT * FROM table WHERE col > 100; | |
null | Create a Python function that takes in a list of numbers and returns the first occurrence of a prime number. | [2, 4, 6, 8] | def findPrime(nums):
for num in nums:
if isPrime(num):
return num
def isPrime(num):
if num <= 1:
return False
for i in range(2, num):
if (num % i == 0):
return False
return True |
[DE Wikipedia] Elbe Holding
Die Elbe Holding GmbH & Co. KG mit Sitz in Bietigheim-Bissingen, Baden-Württemberg, ist ein Familienunternehmen, das Antriebslösungen für den Fahrzeug- und Maschinenbau herstellt. Sie ist die Holding-Gesellschaft der Unternehmen der Elbe Group, welche weltweit über 1100 Mitarbeiter an siebe... | null | null | null |
[DE Wikipedia] Henrik Freischlader
Henrik Freischlader (* 3. November 1982 in Köln) ist ein deutscher Bluesgitarrist und -sänger. Leben Bereits in früher Kindheit begann Henrik Freischlader, Gitarre und Schlagzeug zu spielen. Darüber hinaus spielt er auch Bass und diverse andere Instrumente, deren Beherrschung er sich... | null | null | null |
[EN Wikipedia] Electric Power Systems Research
Electric Power Systems Research is a peer-reviewed scientific journal covering research on new applications of transmission, generation, distribution and uses of electric power. Its current editor-in-chief is Maria Teresa Correia de Barros. According to the Journal Citati... | null | null | null |
null | Can you suggest a pure python alternative to declaring a Float32 array with numbers from 0 to 10? | myArray = [float(i) for i in range(0,11)] | |
null | Write SQL code to insert a row into this table called "tbl_users". | Table Structure: tbl_users user_id (int, primary key) user_name (varchar) user_email (varchar) | INSERT INTO tbl_users (user_name, user_email) VALUES ('John Doe', 'john@example.com'); |
null | Describe the steps of creating an application using the Flask framework. | Steps to creating a Flask application include importing the Flask module, creating an instance of Flask, creating an HTML template file, and creating a route for the app that renders the HTML template. The next step is to create a file containing the code to execute on each route; this could include performing a databa... | |
null | Create a webhook in Python to listen to webhook requests. | import time from flask import Flask, request app = Flask(__name__) @app.route('/webhook', methods=['POST']) def webhook(): data = request.get_json() print(data) if __name__ == '__main__': app.run(host='0.0.0.0', port=5000) | |
null | Design a basic ticket reservation system using Python dictionaries. | # Create a dictionary to store ticket information
tickets = {}
# Function to book ticket
def book_ticket(name, ticket_type, ticket_price):
# Check if the ticket exists
if ticket_type in tickets:
tickets[ticket_type]['availability'] -= 1
tickets[ticket_type]['ticket_holders'].append(name)
else:... | |
null | Implement k-means clustering algorithm in python. | Not applicable | #import necessary libraries
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
#get data
url = 'https://raw.githubusercontent.com/krishnaik06/KNN-K-means/master/Dataset/dataset.csv'
data = pd.read_csv(url,header=None).values
#apply K-means algorithm
k=3
x = data[:,0]
y = data[:,1]
#genera... |
null | Design a genetic algorithm in Python to maximize the value of a given function. | f(x) = x^2 - 4x + 3 | import random
# function to calculate the value of a function
def func(x):
return x**2 - 4*x + 3
# population size
pop_size = 50
# range of initial values of x
x_range = [-20, 20]
# mutation rate
mutation_rate = 0.02
# maximum generation allowed
max_generation = 100
# function to generate a random population
d... |
null | Create an object in JavaScript named 'user' with the following attributes: name, age, and gender. | let user = { name: "", age: 0, gender: "" }; | |
[CS Wikipedia] Salar de Olaroz (lithiový důl)
Salar de Olaroz je povrchový důl na lithium, který se nachází ve stejnojmenné solné laguně v departamentu Susques provincie Jujuy na severozápadě Argentiny. Solné jezero Olaroz je zároveň - podobně, jako některé další solné laguny v Argentině, Bolívii a Chile - zdrojem lit... | null | null | null |
null | Construct a Python code to find the maximum in a given list. | [10, 3, 16, 17, 8] | def find_max(list):
max = list[0]
for i in list:
if i > max:
max = i
return max
list = [10, 3, 16, 17, 8]
print("Maximum number in the list:", find_max(list)) |
null | This code defines a Python class for controlling an Andor3 camera. To use it, import the necessary modules and create an instance of the Andor3 class. Then, call the appropriate methods to control the camera's settings and acquire images. | ############################################################################
# This file is part of LImA, a Library for Image Acquisition
#
# Copyright (C) : 2009-2014
# European Synchrotron Radiation Facility
# BP 220, Grenoble 38043
# FRANCE
#
# This is free software; you can redistribute it and/or modify
# it under ... | |
null | Given the below data, find the sum of all the numbers in the array. | data = [5, 15, 7, 20] | Sum = 47 |
null | Describe the effects when sorting a list using bubble sort | Bubble sort works by comparing adjacent elements of the list and swapping them if they are out of order. It passes through the list multiple times, with each pass through the list moving the highest value elements to their correct position. This process continues until the list is fully sorted. | |
null | Write a function in Python to generate a random alphanumeric string with a length of 5 characters. | import random import string def generate_random_str(): letters = string.ascii_letters + string.digits return ''.join(random.choice(letters) for i in range(5)) | |
null | Create a function in Python that calculates the sum of all even numbers in a given list | [1, 2, 3, 4, 5, 6, 7, 8, 9] | def sum_evens(nums):
total = 0
for num in nums:
if num % 2 == 0:
total += num
return total
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
print(sum_evens(a)) # 20 |
null | Develop a Python program to find the sum of first n even numbers. | 7 | def find_sum(n):
sum = 0
for i in range(1, n+1):
if i % 2 == 0:
sum += i
return sum
n = 7
print("The sum of first n even numbers is:", find_sum(n)) |
null | Create a Python dictionary that includes the keys "name", "age", and "location", and set the values to your name, age, and location. | my_dict = { "name": "John Smith", "age": 28, "location": "New York" } | |
[EN Wikipedia] 1965–66 Norwegian 1. Divisjon season
The 1965–66 Norwegian 1. Divisjon season was the 27th season of ice hockey in Norway. Six teams participated in the league, and Valerenga Ishockey won the championship. Regular season External links Season on eliteprospects.com Nor Eliteserien (ice hockey) seasons 19... | null | null | null |
null | Design and write a Python program to extract all public email addresses from a given string | "My email is john@example.com and yours is john@gmail.com." | import re
def extract_emails(text):
emails = re.findall(r"[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+", text)
return emails
extracted_emails = extract_emails("My email is john@example.com and yours is john@gmail.com")
print(extracted_emails) |
null | Describe the role of the constructors in a Java class. | The role of the constructors in a Java class is to initialize the fields of an object. A constructor is a special method that is called when an object is instantiated. Constructors typically have the same name as the class and take in parameters. The parameters are used to initialize the fields of the object. Construct... | |
null | Create a function called `convert_csv_to_json` to convert the following csv to the corresponding JSON formatt. | city,country,latitude,longitude Frankfurt,Germany,50.1117,8.6785 London,UK,51.4667,-0.25 | import json def convert_csv_to_json(csv_string): lines = csv_string.split("\n") keys = lines[0].split(",") out_list = [] for line_num in range(1, len(lines)): line = lines[line_num] values = line.split(",") item = {} for key_num in range(0, len(keys)): key = keys[key_num] val = values[key_num] item[key] = val out_list.... |
null | Query all values from the table "users" in a MySQL database and sort them by descending order of the column "age". | SELECT * FROM users ORDER BY age DESC; | |
[EN Wikipedia] 1956 World Professional Match-play Championship
The 1956 World Professional Match-play Championship was a snooker tournament that took place from 9 January to 10 March 1956 with the final being held at the Tower Circus in Blackpool, England from 5 to 10 March. Fred Davis won his eighth and last world sn... | null | null | null |
[HI Wikipedia] मुक्त शिक्षा
मुक्त शिक्षा (Open education) से मतलब उन शैक्षिक संस्थानों से है जो प्रवेश से सम्बन्धित अवरोधों को समाप्त करने के पक्ष में है। उदाहरण के लिए, हो सकता है कि ऐसे संस्थानों में प्रवेश के लिए कोई भी शैक्षिक योग्यता आवश्यक न हो। इन्हें भी देखें राष्ट्रीय मुक्त विद्यालयी शिक्षा संस्थान मुक्त विश्... | null | null | null |
null | Design a function in Python that takes a positive integer and finds its prime factors. | def prime_factors(num):
factors = []
n = 2
while n * n <= num:
if num % n == 0:
factors.append(n)
num //= n
else:
n += 1
if num > 1:
factors.append(num)
return factors | |
null | Generate a JavaScript code that prints all the numbers from 1 to 30. | for(let i=1; i<=30; i++){ console.log(i); } | |
null | Extract the strings that match the following regex pattern from a text block | text block = “hotel #9888, school #9876, airport #987” regex pattern = #[0-9]{4} | ['#9888', '#9876', '#987'] |
[HI Wikipedia] पुरी
पुरी (Puri) भारत के ओड़िशा राज्य के पुरी ज़िले में बंगाल की खाड़ी से तटस्थ एक नगर है। यह ज़िले का मुख्यालय भी है। पुरी भारत के चार धाम में से एक है और यहाँ 12वीं शताब्दी के जगन्नाथ मंदिर स्थित होने के कारण इसे श्री जगन्नाथ धाम भी कहा जाता है। विवरण भारत के चार पवित्रतम स्थानों में से एक है पुरी, जह... | null | null | null |
null | Generate a valid regular expression to catch URLs in strings. | r"(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})" | |
null | Develop a function in Python that takes in a list and sorts the elements alphabetically. | my_list = ["word", "translate", "language", "computer"] | def sort_list(my_list):
my_list.sort()
return my_list
print(sort_list(my_list)) |
null | Given two lists, write a Python program to return a list that contains the elements from both the lists, except for the elements that are duplicated. | List1: [1,2,3,4,5]
List2: [4,5,6,7,8] | new_list = [1,2,3,6,7,8] |
null | Write a CSS code to make all h2 headings bold and red. | h2 { font-weight: bold; color: red; } | |
null | Write a snippet of code for looping over a list of numbers. | myList = [1, 2, 3, 4] | for x in myList: print(x) |
[HI Wikipedia] अवधी
अवधी हिंदी क्षेत्र की एक उपभाषा है। यह उत्तर प्रदेश के "अवध क्षेत्र" (लखनऊ, रायबरेली, सुल्तानपुर, बाराबंकी, उन्नाव, हरदोई, सीतापुर, लखीमपुर, अयोध्या, जौनपुर, प्रतापगढ़, प्रयागराज, कौशाम्बी, अम्बेडकर नगर, गोंडा,बस्ती, बहराइच,बलरामपुर, सिद्धार्थनगर, श्रावस्ती तथा फतेहपुर) में बोली जाती है। इसके अतिरि... | null | null | null |
null | Write a function to create a retail price tag given a cost, taxes and discounts. | cost = 5 tax = 0.08 discount = 0.2 | def price_tag(cost, tax, discount): tax_amount = cost * tax discounted_price = cost + tax_amount - (discount * cost) return "Retail Price: $" + str(round(discounted_price, 2)) price_tag(cost, tax, discount) # returns "Retail Price: $7.20" |
null | Create a Swift code that show the number of days in the given month. | int month = 5 | let month = 5 let daysEndingInth = [3, 0, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3] let daysInMonth = daysEndingInth[month - 1] print("The number of days in the month of \(month) is \(daysInMonth).") |
null | Generate a regular expression that matches strings containing any number of digits, but does not contain any non-digit character. | ^[0-9]+$ | |
[EN Wikipedia] 1863 in Denmark
Events from the year 1863 in Denmark. Incumbents Monarch – Frederick VII (until 15 November), Christian IX Prime minister – Carl Christian Hall (until 31 December), Ditlev Gothard Monrad Events 6 June Frederick VII receives a Greek deputation at Christiansborg. 22 October – The first tra... | null | null | null |
null | Write a Python program to find the first non-repeated character of a given string. | string = "teststring" | def first_non_repeated_char(string):
for ch in string:
if string.count(ch) == 1:
return ch |
null | Generate an array of random integers between 1 and 50 inclusive. | let randomIntegersArray = []; for (let i = 0; i < 50; i++) { randomIntegersArray.push(Math.floor(Math.random() * (50 - 1 + 1)) + 1); } | |
null | Suggest a completion for the following python code to randomly select an element from a given list. | import random
def random_element(lst): | import random
def random_element(lst):
return random.choice(lst) |
null | Suggest an API endpoint in Ruby on Rails for creating a new blog post. | post "/posts" do post = Post.new(params[:post]) if post.save status 202 json post.to_json else status 400 json post.errors end end | |
null | Write a Python program to randomly generate a 5x5 matrix of integers between 1 and 10, and then find the sum of each row of the matrix. | Not applicable | import random
# Create a 5x5 matrix of random integers between 1-10
matrix = [[ random.randint(1,10) for _ in range(5)] for _ in range(5)]
# Print the matrix
for row in matrix:
print(row)
# Find the sum of each row
row_sums = [sum(row) for row in matrix]
# Print the row sums
print(row_sums) |
null | Create a Python module that utilizes machine learning to predict the selling price of an item from its description. | {
“description”: “Gently used Apple iPhone 8 Plus, 64GB, unlocked. Great condition!”
} | import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
# Create data frame from input
df = pd.DataFrame([{
“description”: “Gently used Apple iPhone 8 Plus, 64GB, unlocked. Great condition!”
}])
# Create feature columns
df['Length'] = df['description'].apply(len)
# Create target col... |
null | Write a SQL query to get the count of records in a table. | SELECT COUNT(*) FROM myTable; | |
null | Create a Python dictionary with the student's name as the key and marks as the value. | data = { "Ann": 78, "John": 92, "Bob": 67 } | student_marks = { "Ann": 78, "John": 92, "Bob": 67 } |
null | Create a query in SQL that will display the first name, last name and department of all employees in the table. | Employee Table: |first_name | last_name | department | -------------------------------------- | John | Doe | Marketing | | SELECT first_name, last_name, department FROM Employee; |
null | Develop a code in R that returns the maximum from a list. | #function to return maximum max <- function(x) { max_num <- 0 #Initialize maximum number for (i in x) { if (i > max_num) { max_num <- i } } return (max_num) } #Test list <- c(10, 30, 20, 5, 100) maximum <- max(list) print(maximum) | |
null | Write a Python code to generate a random password string of length 8, consisting of upper and lower case characters, special characters and digits. | import random
import string
def generate_password_string(length):
# Generate a random password string of length 8, consisting of upper and lower case characters, special characters and digits
password_characters = string.ascii_letters + string.digits + string.punctuation
return ''.join(random.choice(passwo... | |
null | Write a Python code snippet that takes a list of numbers as argument and prints the average. | [2, 3, 4, 5, 6] | def average(numbers: list):
if numbers:
return sum(numbers) / len(numbers)
else:
return 0
numbers = [2, 3, 4, 5, 6]
print(f"Average of {numbers} is {average(numbers)}") |
null | How can you utilize SQL in machine learning? | SQL is useful in machine learning projects because it allows the data scientist to organize and store large datasets. SQL can also be used to join different datasets and merge unstructured datasets efficiently. Further, with SQL, data scientists can filter and prepare the dataset for further machine learning modeling. ... | |
[CS Wikipedia] Elevační úhel
Elevační úhel při šikmém vrhu je úhel mezi vektorem počáteční rychlosti a vodorovnou rovinou. Na elevačním úhlu závisí délka a výška šikmého vrhu. Největší délky se při hodu ve vakuu dosáhne při úhlu 45°, pro hod ve vzduchu (tzn. s nezanedbatelným odporem vzduchu) je tento úhel o něco nižš... | null | null | null |
[CS Wikipedia] Lavrov
Existuje více nositelů příjmení Lavrov, Lavrovová: Alexandr Vasiljevič Lavrov (* 1949) – ruský literární vědec Andrej Lavrov (* 1962) – ruský házenkář Pjotr Lavrov (1823–1900) – ruský filozof a politik Sergej Lavrov (* 1950) – ruský diplomat a politik Natalja Lavrovová (1984–2010) – ruská moderní... | null | null | null |
null | Create a function that takes two strings and removes all the white spaces from them. | string_1 = "Hello World !" string_2 = " Goodbye! " | def remove_whitespace(string_1, string_2): return string_1.replace(" ", "") + string_2.replace(" ", "") |
null | Iterate over a list and count the number of occurrences of each item. | list1 = [10, 20, 30, 10, 10, 40, 10] | def count_instances(list1): count_dict = dict() for item in list1: if (item in count_dict): count_dict[item] += 1 else: count_dict[item] = 1 for key, value in count_dict.items(): print(f"{key} : {value}") count_instances(list1) Output: 10 : 4, 20 : 1, 30 : 1, 40 : 1 |
[HI Wikipedia] मेसेंजर
मेसेंजर (MESSENGER → MErcury Surface, Space ENvironment, GEochemistry, and Ranging), बुध ग्रह की परिक्रमा कर रहा नासा का एक रोबोटिक अंतरिक्ष यान है | ऐसा करने वाला यह कभी का पहला अंतरिक्ष यान भी है। सन्दर्भ अंतरिक्ष यान | null | null | null |
null | Write a PHP script that prints out "Hello, World!" on the web page. | <?php echo "Hello, World!"; ?> | |
null | Create a function to retrieve a random element from a given list in Java. | public static Object getRandomElement(List<?> list) { Random rand = new Random(); int randIndex = rand.nextInt(list.size()); return list.get(randIndex); } | |
null | Write a Python program to find the largest common substring between two strings. | 'killerbees','python' | def largest_common_substring(string1, string2):
substring = ""
len1, len2 = len(string1), len(string2)
for i in range(len1):
match = ""
for j in range(len2):
if (i + j < len1 and string1[i + j] == string2[j]):
match += string2[j]
else:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.