text
stringlengths
141
2.89k
⌀
instruction
stringlengths
19
1.5k
⌀
input
stringlengths
0
800
⌀
output
stringlengths
1
2.5k
⌀
null
Build a Python program that takes in two lists as an input and returns a third list with the common elements across the two inputs.
list1 = [2, 3, 4, 5, 6] list2 = [3, 5, 7, 8, 9]
def common_elements(list1, list2): common_elements = [] for element in list1: if element in list2: common_elements.append(element) return common_elements list1 = [2, 3, 4, 5, 6] list2 = [3, 5, 7, 8, 9] print(common_elements(list1, list2))
null
Create an algorithm to convert temperatures from Celsius to Fahrenheit in Python.
def celcius_to_fahrenheit(temp): return ((temp*9/5) + 32) print(celcius_to_fahrenheit(20))
null
Create a function in Java to remove all the values equal to the given number from an array.
public static int[] removeFromArray(int[] arr, int num){ int[] newArr = new int[arr.length]; int newIndex = 0; for(int i = 0; i < arr.length; i++){ if(arr[i] != num){ newArr[newIndex] = arr[i]; newIndex++; } } return Arrays.copyOfRange(newArr, 0, newIndex); }
[DE Wikipedia] Lauerzersee Der Lauerzersee befindet sich im Kanton Schwyz zwischen Vierwaldstättersee und Zugersee. Mit seiner maximalen Wassertiefe von 14 m gehört er zu den flachsten Seen der Schweiz. Geographie Eingebettet ist der Lauerzersee zwischen Steinerberg, Rigi und dem Kleinen und Grossen Mythen. Nahe dem S...
null
null
null
null
Write a python program to print a frequency table of the data in a two-dimensional array
data = [[6, 2, 8], [9, 5, 6], [4, 5, 2]]
def print_freq_table(data): row_count = len(data) col_count = len(data[0]) freq_table = [[0] * col_count for i in range(row_count)] for i in range(row_count): for j in range(col_count): freq_table[i][j] = data[i][j] * 100 / sum([data[k][j] for k in range(row_count)]) for i in...
[HI Wikipedia] करीमनगर करीमनगर (Karimnagar) भारत के तेलंगाना राज्य के करीमनगर ज़िले में स्थित एक नगर है। यह ज़िले का मुख्यालय भी है। विवरण करीमनगर आंध्र प्रदेश राज्य में स्थित एक ऐतिहासिक स्थान और नगर भी है। यहाँ सातवाहन काल के लुहार की उपस्थिति के प्रमाण मिले है। सातवाहनो ने करीमनगर में लौह अयस्कों का उपयोग किया होगा...
null
null
null
null
What is the output of the following code? def check_even(num): if num % 2 == 0: return "Even" else: return "Odd" print(check_even(3))
Odd
[HI Wikipedia] जमशेदपुर महिला महाविद्यालय जमशेदपुर महिला महाविद्यालय () जमशेदपुर का एक कालेज है। यह शहर के बिष्टुपुर क्षेत्र में गोपाल मैदान (जिसे पहले रीगल ग्राउंड के नाम से जाना जाता था), के पास स्थित है। यह महाविद्यालय रांची विश्वविद्यालय से संबद्ध है। प्रमुख विभाग विज्ञान नामांकन प्रक्रिया महाविधालय प्रशासन प्राचा...
null
null
null
[HI Wikipedia] आईडीई की सूची नीचे प्रमुख आईडीई पैकेजों की सूची दी गई है। ऐक्शनस्क्रिप्ट (ActionScript) अडा (Ada) बेसिक (Basic) सी/सी++ कॉमन लिस्प (Common Lisp) कम्पोनेन्ट पास्कल (Component Pascal) सी शार्प (C#) एफेल (Eiffel) फोर्ट्रान (Fortran) जावा जावास्क्रिप्ट Lua पास्कल, आब्जेक्ट पास्कल (Pascal, Object Pascal) पर्...
null
null
null
null
Using the input, create a new list of strings where all strings in the new list have an uppercase first letter.
my_list = ["hello", "world", "how", "are", "you?"]
new_list = [] for string in my_list: new_list.append(string.capitalize()) print(new_list) # prints ['Hello', 'World', 'How', 'Are', 'You?']
null
Create an object-oriented structure to solve a maze by using python.
import collections class Maze: def __init__(self, n, m): self._n, self._m = n, m self._grid = [[None] * m for _ in range(n)] def solve_maze(self): result, found = [], False start, end = (0, 0), (self._n-1, self._m-1) for i in range(self._n): for j in range(...
null
Generate a code to calculate the mean absolute difference of items in a list in Python.
my_list = [1, 2, 3, 4, 5]
def mean_absolute_difference(my_list): diff = 0 for i in range(len(my_list) - 1): diff += abs(my_list[i] - my_list[i + 1]) return diff / (len(my_list) - 1) if __name__ == "__main__": print(mean_absolute_difference(my_list))
null
Create an AI agent in Python to play the game of Tic Tac Toe.
Not applicable
import random # Define the board board = ['_', '_', '_', '_', '_', '_', '_', '_', '_'] # Define the players player = 'X' ai = 'O' # Define the rules of the game def play_game(): # Draw initial board draw_board(board) # Choose the player to start (randomly) choose_player() # Start playing ...
null
Create a list of 10 strings in Python and print each string in a separate line.
mylist = ['string1', 'string2', 'string3', 'string4', 'string5', 'string6', 'string7', 'string8', 'string9', 'string10'] for item in mylist: print(item)
null
Write a Python script to print out the max and min values from the given list.
[2,10,18,24,36,95]
list = [2,10,18,24,36,95] max_value = max(list) min_value = min(list) print("Max value: ", max_value) print("Min value: ", min_value)
null
Create a Python web interface to facilitate text analysis of a given set of documents.
library used: NLTK
import nltk import math # Load the given set of documents docs = [...] # Tokenize documents tokens = [nltk.word_tokenize(doc) for doc in docs] # Create list of all tokens all_tokens = [token for doc in tokens for token in doc] # Calculate IDF (Inverse Document Frequency) for each token idf_scores = {token: math.log...
null
Write a Python program to create a join of two given strings being separated by a given separator.
First string: Apples Second string: Oranges Separator: and
a = "Apples" b = "Oranges" #joining the strings, using the separator joinedString = a +" "+ "and" +" "+ b # print the joined string print(joinedString)
null
Write an HTML code to display a table of 3 columns and 5 rows.
<table> <tr> <th>Column1</th> <th>Column2</th> <th>Column3</th> </tr> <tr> <td>Row1_data1</td> <td>Row1_data2</td> <td>Row1_data3</td> </tr> <tr> <td>Row2_data1</td> <td>Row2_data2</td> <td>Row2_data3</td> </tr> <tr> <td>Row3_data1</td> <td>Row3_data2</td> <td>Row3_data3</td> </tr> <tr> <td>Row4_data1</td> <td>Row4_dat...
null
Find the area of a triangle using the Heron's formula
lengths = [3, 4, 5]
def herons_formula(lengths): a, b, c = lengths[0], lengths[1], lengths[2] s = (a + b + c) / 2 area = (s*(s-a)*(s-b)*(s-c))** 0.5 return area
null
Design a Fibonacci sequence calculator in Python.
Not applicable
def fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: return fibonacci(n-1) + fibonacci(n-2) # Main Program n = int(input("Enter number of terms: ")) for i in range(n): print(fibonacci(i), end=" ")
null
Classify this code error as a runtime error or a compile error
def foo(x): if x > 0 print("x is positive")
Compile error
null
Generate code to create a REST API in Python that parses JSON and returns the values of a nested object.
{ "data": { "name": "John Doe", "age": 25 } }
@app.route('/parseJSON', methods=['POST']) def parse_json(): data = request.get_json() name = data['data']['name'] age = data['data']['age'] response = { "name": name, "age": age } return jsonify(response)
null
Edit a program to show the area of the rectangle
#include <stdio.h> int main() { int length, width; printf("Enter the length : "); scanf("%d", &length); printf("Enter the width : "); scanf("%d", &width); printf("The Perimeter of rectangle is : %d \n", 2*(length + width)); return 0; }
#include <stdio.h> int main() { int length, width; printf("Enter the length : "); scanf("%d", &length); printf("Enter the width : "); scanf("%d", &width); printf("The Perimeter of rectangle is : %d \n", 2*(length + width)); printf("The Area of rectangle is : %d \n", length * width); return 0; }
null
Classify the given text as "positive" or "negative" using Natural Language Processing.
This movie is terrible.
negative
[HI Wikipedia] अकात्सुकी (अंतरिक्ष यान) अकात्सुकी (), एक जापानी मानवरहित अंतरिक्ष यान है, जिसका उद्देश्य शुक्र ग्रह का अन्वेषण था | इसे 20 मई 2010 को एक H-IIA 202 रॉकेट पर लादकर प्रमोचित किया गया था | सन्दर्भ अंतरिक्ष यान
null
null
null
null
Generate a random 8 digit string composed of numbers and letters in Python 3.
import string import random #Generate 8 character random string def generate_random_string(stringLength=8): lettersAndDigits = string.ascii_letters + string.digits return ''.join(random.choice(lettersAndDigits) for i in range(stringLength)) #Driver code random_string = generate_random_string() print(f"Random String Gen...
[HI Wikipedia] हैफ़ीस्टस हैफ़ीस्टस (अंग्रेज़ी : :en:Hephaestus, यूनानी : हैफाइस्तोस ) प्राचीन यूनानी धर्म के प्रमुख देवताओं में से एक थे। वो अग्नि, लोहारो, धातुकी और कारख़ानों के देवता थे। प्राचीन रोमन धर्म में उनके समतुल्य देवता थे वुल्कन। यूनान के देवी-देवता यूनानी धर्म
null
null
null
null
Write an SQL query to find all the employees based in France.
SELECT * FROM employees WHERE country = 'France';
[EN Wikipedia] Senior (album) Senior is the fourth studio album by Norwegian electronic music duo Röyksopp. It was released on 8 September 2010 by Wall of Sound. Consisting of instrumental tracks only, the album is described as more introspective and withdrawn than its predecessor, Junior (2009). The final track on th...
null
null
null
null
Create a function in Python that takes a string as an argument and replace all vowels with underscores.
teststring
def replace_vowels(input_string): vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"] output_string = '' for s in input_string: if s in vowels: output_string += '_' else: output_string += s return output_string result = replace_vowels('teststring') print(...
null
Optimize the following application in Python to reduce startup time.
import time def func(): start=time.time() i=0 while(i<100000000): i+=1 end=time.time() print(end-start) func()
import time def func(): start=time.time() # Optimized code using range instead of while loop lst = range(100000000) end=time.time() print(end-start) func()
null
Write a JavaScript function to determine if an array is sorted or not.
function isSorted(arr) { for (let i=1; i<arr.length; i++) { if (arr[i] < arr[i-1]) return false; } return true; }
null
Create a Python class that merges two sorted lists.
class MergeTwoLists(): def merge(self, left_list, right_list): """Merge two sorted lists""" i = 0 j = 0 merged_list = [] while i < len(left_list) and j < len(right_list): if left_list[i] < right_list[j]: merged_list.append(left_list[i]) ...
[DE Wikipedia] Villa Matschatsch Die Villa Matschatsch (auch Schloss Matschatsch) befindet sich in Südtirol im Gebiet der Gemeinde Eppan, südwestlich von Bozen. Die Villa liegt auf Höhe an der Mendelpassstraße (SS 42), nach Kehre Nr. 5 oberhalb des Gandbergs. Geschichte Im 16. Jahrhundert gehörte das Gebäude einem gew...
null
null
null
[HI Wikipedia] कानपुर कानपुर ( ) भारत के उत्तर प्रदेश राज्य के कानपुर नगर ज़िले में स्थित एक औद्योगिक महानगर है। यह नगर गंगा नदी के दक्षिण तट पर बसा हुआ है। प्रदेश की राजधानी लखनऊ से 80 किलोमीटर पश्चिम स्थित यहाँ नगर प्रदेश की औद्योगिक राजधानी के नाम से भी जाना जाता है। ऐतिहासिक और पौराणिक मान्यताओं के लिए चर्चित ब्रह...
null
null
null
null
Create an SQL query to get the average of all the prices in the products table.
SELECT AVG(price) FROM products;
null
Create a Python class "Book" with name and price properties.
class Book: def __init__(self, name, price): self.name = name self.price = price
null
How can you use recurrent neural networks for sequence prediction?
Recurrent neural networks (RNNs) can be used for sequence prediction tasks. RNNs are powerful models that are able to capture patterns from sequences of data and can remember information from previous inputs. The network is comprised of layers and nodes, and each layer contains nodes that are connected to the previous ...
null
Write a machine learning program in Python to classify products as bad, good, or great based on their price and reviews.
A training dataset that contains the price and reviews of products.
import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.linear_model import LogisticRegression from sklearn.pipeline import make_pipeline from sklearn.metrics import confusion_matrix # Load...
null
Create a JavaScript object to contain employee data.
let employee = { name: "John", age: 25, job: "developer", address: { city: "Berlin", street: "Main Street" } }
null
Generate a random string with 8 characters in Python.
import string import random def generate_random_string(stringLength=8): """Generate a random string of fixed length """ letters = string.ascii_lowercase return ''.join(random.choice(letters) for i in range(stringLength)) print(generate_random_string())
null
Modify the given Python loop to also multiply the numbers by 2 at the same time.
numbers = [1, 2, 3 , 4] for num in numbers: print(num)
numbers = [1, 2, 3 , 4] for num in numbers: print(num*2)
null
Design a machine learning algorithm to classify the given dataset.
Dataset of images of cats and dogs
""" Design a machine learning algorithm to classify the given dataset """ import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt #Prepare data data = pd.read_csv('path/to/dataset') #Preprocess data X = data.drop('label', axis=1) y = data['label'] #Split into training and test set f...
null
Remove the boilerplate code from the program for printing 10 random numbers.
import random # Generate 10 random numbers for i in range(10): # TODO
import random # Generate 10 random numbers for i in range(10): print(random.randrange(1, 101))
null
Complete the following Python program for converting the given list into a dictionary.
list1 = ['a', 'b', 'c'] list2 = [1, 2, 3] def to_dict(list1, list2): ???
list1 = ['a', 'b', 'c'] list2 = [1, 2, 3] def to_dict(list1, list2): return dict(zip(list1, list2))
null
Output the even numbers between 0 and 10.
2, 4, 6, 8, 10
null
Transform the following array into a string of comma-separated values in Python.
[1, 2, 3, 4]
','.join([str(i) for i in [1, 2, 3, 4]]) # returns "1,2,3,4"
null
Create a CSS class which defines a black border with a red background color.
.blackBorder { border: 1px solid black; background-color: red; }
[DE Wikipedia] Burg Grimburg Die Burg Grimburg, auch einfach Grimburg genannt, ist eine Spornburg im Gebiet der Ortsgemeinde Grimburg in der Verbandsgemeinde Hermeskeil im rheinland-pfälzischen Landkreis Trier-Saarburg. Geographische Lage Die Burg Grimburg steht im Naturpark Saar-Hunsrück 1,8 km südsüdwestlich der Ort...
null
null
null
null
Given two strings s1 and s2, write a Python program to find whether s1 is an anagram of s2.
s1 = 'listen' s2 = 'silent'
def isAnagram(s1, s2): if (sorted(s1) == sorted(s2)): print("The strings are anagrams.") else: print("The strings aren't anagrams.") isAnagram(s1, s2)
null
Write a code to delete all the items whose value is lower than 5
{ "item1": 10, "item2": 7, "item3": 3, "item4": 4, "food1": 2 }
let data = { "item1": 10, "item2": 7, "item3": 3, "item4": 4, "food1": 2 }; // check each value for (let key in data) { if (data[key] < 5) { // if value is lower than 5, delete that item from the object delete data[key]; } } // output object console.log(data);
[DE Wikipedia] Champions League 2007 Champions League 2007 steht für: AFC Champions League 2007, asiatischer Fußballwettbewerb für Vereinsmannschaften der Männer CAF Champions League 2007, afrikanischer Fußballwettbewerb für Vereinsmannschaften der Männer CONCACAF Champions’ Cup 2007, nord- und mittelamerikanischer Fu...
null
null
null
null
Generate a Python function that takes a list and a number as input and assigns the number to each item in the list.
[2, 3, 4, 5], 7
def assign_value(lst, num): for i in range(len(lst)): lst[i] = num return lst print(assign_value([2, 3, 4, 5], 7)) # Output: [7, 7, 7, 7]
[CS Wikipedia] Seznam škol v Třebíči v roce 1906 Tento seznam je seznamem škol ve městě Třebíči v roce 1906. Obecné a měšťanské školy Pětitřídná česká obecná škola chlapecká s 9 učiteli a 426 žáky, pětitřídná česká obecná škola dívčí s 6 učiteli a 393 žákyněmi, petitřídná česká obecná škola chlapecká na Nových Dvorech...
null
null
null
null
Write a recursive function in Python to compute the n-th Fibonacci number
def Fibonacci(n): if n <= 1: return n else: return (Fibonacci(n-1) + Fibonacci(n-2))
[CS Wikipedia] Šneková turbína Archimédova turbína, nazývaná také jako šneková nebo šroubová turbína, je vodní turbína, která je obměnou vodního kola na horní vodu a jako taková využívá potenciální energii vody. Nicméně, ve srovnání s účinností vodního kola, je účinnost šnekové turbíny větší. Turbína se skládá z rotor...
null
null
null
null
Write a code to reverse the order of a data structure such as array, list, or stack.
list1 = [1, 3, 5, 7, 9]
list1.reverse() # [9, 7, 5, 3, 1]
null
Create a React component to render a table with 10 rows and 3 columns.
import React, { Component } from 'react'; class Table extends Component { render() { return ( <table> <thead> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> </tr> </thead> <tbody> {Array.from(Array(10).keys()).map((x) => { return ( <tr> <td>Data 1</td> <td>Data 2</td> <td>Data 3</td> </tr> ); })} </tbody> <...
[EN Wikipedia] Danguolė Brogienė Danguolė Brogienė (born 1959) is a Lithuanian textile designer, and Associate Professor of the Costume Design Department of Vilnius Academy of Arts, Lithuania. In 1982, she graduated from the Lithuanian Institute of Art (since 1990 Vilnius Academy of Fine Arts). She is on the jury of H...
null
null
null
null
Generate a Python program that creates a GUI window with two buttons: one to change the window background to red and the other to change the window background to green.
#Import the necessary modules import tkinter as tk from tkinter import * #Create the main window window = tk.Tk() #Create a window content def change_background_to_red(): window.configure(background='red') def change_background_to_green(): window.configure(background='green') #Creating the button red_btn...
null
Write a Python program to translate a string into pig latin.
Hello
def toPigLatin(word): vowels = ["a","e","i","o","u"] first_letter = word[0] if first_letter in vowels: modified_word = word + "way" else: modified_word = word[1:] + first_letter + "ay" return modified_word result = toPigLatin("Hello") print(result)
[EN Wikipedia] Brazilian coral snake The Brazilian coral snake (Micrurus decoratus) is a species of coral snake in the family Elapidae. References Micrurus Snakes of South America Reptiles of Brazil Endemic fauna of Brazil Reptiles described in 1858 Taxa named by Giorgio Jan it is a very venomous snake
null
null
null
null
Read the following pseudocode and generate a Python program to complete the given task.
Given a list of numbers, print the numbers in reverse order
numbers = [1, 2, 3, 4, 5] numbers.reverse() for num in numbers: print(num)
null
Create an SQL query to find the id of the customer whose name is "John Doe".
SELECT id FROM customers WHERE name = 'John Doe';
[HI Wikipedia] क्रूनुबैर्य लैन क्रूनुबैर्य लैन (स्वीडी: Kronobergs län, अंग्रेज़ी: Kronoberg) स्वीडन का एक लैन है। 'लैन' स्वीडन का उच्च-स्तरीय प्रशासनिक विभाग होता है, जिसे कभी-कभी 'काउंटी' भी कहते हैं। इन्हें भी देखें स्वीडन की काउंटियाँ सन्दर्भ क्रूनुबैर्य लैन स्वीडन की काउंटियाँ स्वीडन
null
null
null
null
Create a boolean expression in JavaScript, which returns false if a variable named "result" is an empty string.
var result = '';
if (result === '') { var result = false; }
null
Write a JavaScript code to add the numbers 8 and 4.
var num1 = 8; var num2 = 4; var sum = num1 + num2; console.log(sum);
null
Change the HTML element to have a font size of 10px
<p>Hello World!</p>
<p style="font-size:10px;">Hello World!</p>
null
Write a function to construct a new string by appending the provided string to itself.
my_string = 'Hello'
def append_string(my_string): return my_string + my_string final_string = append_string(my_string) print("Final string:", final_string)
null
Identify the variables and operators in the following Java code.
int a = 3 + 4; int b = a * 2;
Variables: a, b Operators: +, *
null
Process the following array of numbers to get the max, min, and average scores.
scores = [90, 75, 70, 85, 80]
const scores = [90, 75, 70, 85, 80]; let maxScore = Math.max(...scores); let minScore = Math.min(...scores); let avgScore = scores.reduce((a, b) => a + b, 0) / scores.length; console.log(`Max Score = ${maxScore}`); console.log(`Min Score = ${minScore}`); console.log(`Average Score = ${avgScore}`);
null
Implement a decision-making algorithm for a rock-paper-scissors game using Python.
# Rock, paper, scissors game! def play_game(player1, player2): # Define the winning rules rules = {'rock': 'scissors', 'scissors': 'paper', 'paper': 'rock'} if player1 == player2: return 'It is a draw!' elif rules[player1] == player2: return 'Player 1 wins!' elif rules[player2] == ...
[HI Wikipedia] इस्माइल सामानी पर्वत इस्माइल सामानी (ताजिक भाषा: Қуллаи Исмоили Сомонӣ, क़ुल्लई इस्मोइलि सोमोनी; अंग्रेज़ी: Ismoil Somoni Peak) ताजिकिस्तान का सबसे ऊँचा पर्वत है। जब ताजिकिस्तान रूसी साम्राज्य और फिर सोवियत संघ का हिस्सा था, जब यह पर्वत उन देशों का भी सबसे ऊँचा पहाड़ हुआ करता था। यह पूरे मध्य एशिया और प...
null
null
null
null
Create a function in Python that prints the sentence "Hello, World!" n times.
def print_hello_world(n): for i in range(n): print("Hello, World!") print_hello_world(3) # Output: Hello, World! Hello, World! Hello, World!
[CS Wikipedia] Šíření tepla Šíření tepla (někdy též sdílení tepla) je jedním ze způsobů přenosu energie. Spočívá v tepelné výměně, což je termodynamický děj, při kterém dochází k výměně tepla mezi dvěma tělesy s různou teplotou. Tepelná výměna vždy probíhá tak, že teplejší těleso předává část své vnitřní energie chlad...
null
null
null
[HI Wikipedia] ग़ज़ल यह अरबी साहित्य की प्रसिद्ध काव्य विधा है जो बाद में फ़ारसी, उर्दू, नेपाली और हिंदी साहित्य में भी बेहद लोकप्रिय हुइ। संगीत के क्षेत्र में इस विधा को गाने के लिए इरानी और भारतीय संगीत के मिश्रण से अलग शैली निर्मित हुई। शब्दार्थ अरबी भाषा के इस शब्द का अर्थ है औरतों से या औरतों के बारे में बातें कर...
null
null
null
null
Using the given data point, train a linear regression model.
[4, 7], [2, 5], [3, 6]
import numpy as np X = np.array([[4,7], [2,5], [3,6]]) y = np.array([7, 5, 6]) from sklearn.linear_model import LinearRegression model = LinearRegression() model.fit(X, y)
null
Write a JavaScript program to find the maximum number from the given three numbers.
5, 10, 3
let num1 = 5; let num2 = 10; let num3 = 3; let maxNum = Math.max(num1, num2, num3); console.log("The maximum number of the three numbers given is " + maxNum);
null
Design a Python function that generates a password string from random alphabets, numbers and special characters.
import random import string def generate_password(length): ''' Generate a password string of specified length containing random alphabets, numbers and special characters. ''' password = ''.join(random.choice(string.ascii_letters + string.digits + string.punctuation) for i in range(length)) r...
[DE Wikipedia] Tetraeder-Puzzle Ein Tetraeder-Puzzle ist ein Geduldsspiel und gehört zu den 3D-Puzzles. Abhängig von der Anzahl der zusammenzusetzenden Teile und deren räumlicher Struktur erfordert es ein hohes Maß an Geduld, bis die einzelnen Teile zum Ausgangstetraeder zusammengefügt sind. Spielregel und Lösungsstra...
null
null
null
null
Format this list such that each element is in a new line.
list_of_numbers = [1,2, 3, 4, 5]
""" Format this list such that each element is in a new line """ list_of_numbers = [1,2, 3, 4, 5] # Format the list such that each element is in a new line for num in list_of_numbers: print(num)
null
Modify a given JavaScript code snippet to add a random background color to all elements with the class name 'box'.
document.querySelectorAll('.box').forEach(function(el) { el.style.backgroundColor = "red"; });
document.querySelectorAll('.box').forEach(function(el) { const randomHex = Math.floor(Math.random()*16777215).toString(16); el.style.backgroundColor = `#${randomHex}`; });
[HI Wikipedia] विश्वनाथ प्रताप सिंह विश्वनाथ प्रताप सिंह भारत गणराज्य के 10 ‌‌दसवे क्रम के (७वें व्यक्ति) प्रधानमंत्री थे और उत्तर प्रदेश के मुख्यमंत्री रह चुके है। उनका शासन एक साल से कम चला, २ दिसम्बर १९८९ से १० नवम्बर १९९० तक। विश्वनाथ प्रताप सिंह (जन्म- 25 जून 1931, डईया राजघराना, राजा माण्डा (कोरांव के निकट , माण...
null
null
null
[EN Wikipedia] WGLY-FM WGLY-FM (91.5 FM, "The Light") is a Christian radio station licensed to Bolton, Vermont, serving the Burlington, Vermont area. The station is owned by Christian Ministries, Inc. Programming The Light Radio Network's programming includes Christian Talk and Teaching and Christian music. Christian ...
null
null
null
null
FOr a given list, create a program that prints out the standard deviation of the elements in the list.
list = [1, 4, 9, 16]
def std_dev(list): """Print the standard deviation of elements in a given list.""" numerator = 0 mean = sum(list) / len(list) for num in list: numerator += (num - mean) ** 2 sd = (numerator / (len(list) - 1)) ** 0.5 return sd
null
Add a 3x3 identity matrix to the following matrix.
[[1, 2, -3] [0, 1, 3] [-2, 0, 4]]
[[4, 2, -3], [0, 4, 3], [-2, 0, 7]]
[CS Wikipedia] Bartholomeus Breenbergh Bartholomeus Breenbergh (před 13. listopadem 1598 - po 3. říjnu 1657) byl nizozemský malíř krajinář. V letech 1619 až 1630 působil v Římě, od roku 1630 do 1657 v Amsterdamu. Životopis O jeho počátcích toho není mnoho známo. Nizozemský malíř a životopisec Arnold Houbraken v prvním...
null
null
null
null
Write a JavaScript program to replace a specific word in a string.
The given string is: "Welcome to my website!" To replace the word “website” with “blog”
var str = "Welcome to my website!"; var newStr = str.replace("website", "blog"); console.log(newStr);
null
Write an SQL query to select the names of employees and their salaries from a table named 'employees', in ascending order of the salaries.
SELECT name, salary FROM employees ORDER BY salary ASC;
null
Construct a program to print the Pyramid pattern using asterisks.
""" Construct a program to print the Pyramid pattern using asterisks """ for i in range(0, 5): for j in range(0, i+1): print("*", end="") print()
null
Convert a given array of strings to an array of numbers.
Array: ['1', '2', '3']
nums = list(map(int, ['1', '2', '3']))
null
Create a new string that is the reverse of the original string.
my_string = "Hello World!"
new_string = "!dlroW olleH"
null
Generate a regular expression to match words that contain only lowercase letters.
^[a-z]+$
null
Edit the following code to check if the resulting output of the division is an integer.
a = 15 b = 4 output = a/b
if b != 0: output = a/b assert output.is_integer(), "Result of division is not an integer"
null
Build a machine learning model in Python to predict whether a customer should be contacted or not.
The data given consists of the columns; age, salary, bank balance, purchased product and response.
import pandas as pd import numpy as np from sklearn.linear_model import LinearRegression # Read the dataset data = pd.read_csv('data.csv') # Separate the features and targets X = data.iloc[:, 0:4] # independent variables y = data.iloc[:, 4] # target variable # Create an instance of a linear regression model model = ...
null
Write an R program to print out the numbers from 0-50, in steps of 4.
x <- seq(from = 0, to = 50, by = 4) print(x)
null
Write a function that prints Fibonacci numbers up to N (N>1).
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
null
Can you write a Python code that can sort dictionaries based on the values
def sort_dict_by_values(dict): return sorted(dict.items(), key=lambda kv: kv[1])
null
Design a code for clustering data using Python and the K-means algorithm.
import numpy as np from sklearn.cluster import KMeans # Load the data data = np.loadtxt('data.txt') #Train Clustering Model kmeans = KMeans(n_clusters=3, random_state=0) kmeans.fit(data) #Make Predictions labels = kmeans.predict(data) #Print the labels print(labels)
[DE Wikipedia] Reimer von Essen Reimer von Essen (* 31. Oktober 1940 in Hamburg) ist als Jazz-Klarinettist und -Bandleader bekannt durch die Frankfurter Barrelhouse Jazzband. Leben und Wirken Von Essen (Klarinette, Altsaxophon, Klavier, Arrangements, Komposition) verbrachte seine Schulzeit zunächst in Shanghai, später...
null
null
null