text
stringlengths
141
2.89k
⌀
instruction
stringlengths
19
1.5k
⌀
input
stringlengths
0
800
⌀
output
stringlengths
1
2.5k
⌀
[CS Wikipedia] Dirceu Dirceu José Guimarães (15. června 1952 – 15. září 1995) byl brazilský fotbalista. Hrával na pozici záložníka. S brazilskou reprezentací získal bronzovou medaili na mistrovství světa v Argentině roku 1978. Na tomto turnaji se dostal i do all-stars a federací FIFA byl vyhlášen třetím nejlepším hráč...
null
null
null
[CS Wikipedia] Kaspar Zehnder Kaspar Zehnder (* 27. srpna 1970, Riggisberg, Švýcarsko) je švýcarský dirigent. Životopis Vystudoval klasické jazyky na lyceu v Bernu a současně absolvoval obsáhlé hudební studium na Bernské akademii umění, kde k jeho hlavním učitelům patřili Heidi Indermühle (flétna), Ewald Körner (dirig...
null
null
null
[CS Wikipedia] Ráz těles Ráz těles je střetnutí dvou těles. Pokud se srazí dvě tělesa při pohybu, vznikají na styčné ploše síly, které způsobí změnu pohybu těles. Ráz těles, častěji srážka těles, je interakce těles, při níž se soustředíme na pozorování počátečního stavu Sinit a koncového stavu Sfin. Typy Ráz (dokonale...
null
null
null
[CS Wikipedia] Objem Objem je fyzikální veličina, která vyjadřuje velikost prostoru, kterou zabírá těleso. Z matematického hlediska představuje objem míru charakterizující danou vymezenou část prostoru. Z Fyzikálně-chemického hlediska je objem odvozená jednotka. Objem látek je závislý na tlaku, teplotě a látkovém množ...
null
null
null
null
Create a natural language processing model in Python to generate a summary of a given article.
Input Article: "The world is in a state of crisis. Social media and technology have taken over our lives, and it has caused serious harm to our mental health and wellbeing. We have become isolated and more disconnected from other people and nature. It’s time to take a break and reconnect with the real world."
import spacy import nltk # load the model nlp = spacy.load('en_core_web_sm') # define the input article text = "The world is in a state of crisis. Social media and technology have taken over our lives, and it has caused serious harm to our mental health and wellbeing. We have become isolated and more disconnected fro...
[CS Wikipedia] Univerzita Konstantina Filozofa v Nitře Univerzita Konstantina Filozofa v Nitře () je slovenská veřejná vysoká škola univerzitního typu se sídlem v Nitře. Jde o vrcholnou vzdělávací, vědeckou a uměleckou univerzitu v historicky nejstarším hlavním městě slovenského národa, Nitrianského knížectví. Univerz...
null
null
null
null
Optimize a program that uses a Web Scraper to fetch data from a website.
Not applicable
# Import Python modules import os import lxml import requests import html5lib # Retrieve the HTML url = 'https://www.example.com/' r = requests.get(url) html_doc = r.text # Parse the HTML tree = lxml.html.fromstring(html_doc) links = tree.xpath('//a/@href') # Fetch the data from each link data = [] for link in links...
null
What is the value of the math expression 100(log_10 10)
100
null
Given an array of numbers, write a program to remove the duplicates from the array.
[1, 2, 2, 3, 4, 4, 5]
def remove_duplicates(arr): return list(set(arr)) # using built-in python set()
null
Create a function to format a given number to two decimal places.
def format_number(num): return '{0:.2f}'.format(num)
null
Construct a maximum priority queue in Python given the list of numbers [25,2,105,62,12].
class MaxPQ: def __init__(self, arr = []): self.heap = [0] for item in arr: self.add(item) def add(self, key): self.heap.append(key) self._swim(len(self.heap)-1) def delMax(self): root = self.heap[1] self.heap[1] = self.heap[-1] s...
null
Create a REST API in Python for a basic todo list. The API should be able to return a list of todos, create a new todo, delete an existing todo, and update an existing todo.
Not applicable
from flask import Flask, request, jsonify app = Flask(__name__) todos = [] @app.route('/todos', methods=['GET','POST']) def list_todos(): if request.method == 'GET': return jsonify({'todos': todos}) if request.method == 'POST': todo = {'task': request.json['task']} todos.append(todo) return jsonify({'todo': tod...
null
Design a function that provides the square root of a number x.
def square_root(x): return x ** 0.5
null
Segregate the negative numbers to the left side and positive numbers to the right side of an array.
def segregate_numbers(array): j = 0 for i in range(len(array)): if (array[i] <= 0): array[i], array[j] = array[j], array[i] j+=1 return array
[EN Wikipedia] Asteroid An asteroid is a minor planet—an object that is neither a true planet nor a comet—that orbits within the inner Solar System. They are rocky, metallic or icy bodies with no atmosphere. Sizes and shapes of asteroids vary significantly, ranging from 1-meter rocks to a dwarf planet almost 1000 km i...
null
null
null
null
How can we sort a given list of integers in ascending order?
def sort_list(lst): return sorted(lst)
null
Create a python program to reverse an integer.
x = 123
def reverse_int(x): """Reverse an integer.""" reversed_int = int(str(x)[::-1]) return reversed_int # Usage Example x = 123 reversed_int = reverse_int(x) print(reversed_int) # 321
null
Optimize your code in Python so that it runs faster.
import time def slow_function(): # some code that takes a long time to run time.sleep(5) start_time = time.time() slow_function() elapsed_time = time.time() - start_time print(f"Function took {elapsed_time} seconds.") # Rewritten with optimisation import time from functools import lru_cache @lru_cache() def...
null
Design an algorithm to find the largest number in a given array.
arr = [2,4,6,9,3,7]
def max_in_array(arr): max = 0 for i in range(len(arr)): if arr[i] > max : max = arr[i] return max maxValue = max_in_array(arr) print(maxValue) # 9
null
Create a function to convert a character to its ASCII code.
character = 'a'
def char_to_ascii(character): """Convert a character to its ASCII code.""" ascii_code = ord(character) return ascii_code
null
Generate the class diagrams for a System class and a Database class.
<nopinput>
System Class Diagram: [![system class diagram](https://i.ibb.co/MfXN7xN/system-class-diagram.png)] Database Class Diagram:[![database class diagram](https://i.ibb.co/6WHWKV8/database-class-diagram.png)]
null
Write a JavaScript program to validate whether a given phone number is valid.
phone number: 412-678-9012
function validPhoneNumber(phoneNumber) { let phoneRegex = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/; let validPhone = phoneRegex.test(phoneNumber); return validPhone; } validPhoneNumber("412-678-9012") # true
null
Sum up all the elements of a given list in Python.
my_list = [10,20,30,40]
my_list = [10,20,30,40] total = 0 for num in my_list: total += num print("The sum of all elements in the list is: " + str(total))
null
Write a Python class to simulate a game of tic-tac-toe.
class TicTacToe: board = [] def __init__(self): self.board = [[' ' for x in range(3)] for y in range(3)] def display_board(self): for row in self.board: print('|'.join(row)) def make_move(self, player, row, col): if self.board[row][col] == ' ': self.board[row][col] = player else: print "This cell is occup...
null
Create an array of 10 randomly generated integers between 0 and 10.
import random def generate_random_array(): return [random.randint(0, 10) for _ in range(10)]
[HI Wikipedia] लखनऊ विश्वविद्यालय लखनऊ विश्वविद्यालय, लखनऊ; उत्तर प्रदेश में स्थित एक सार्वजनिक राज्य विश्वविद्यालय है। १८६७ में स्थापित, लखनऊ विश्वविद्यालय भारत में उच्च शिक्षा के सबसे पुराने सरकारी स्वामित्व वाले संस्थानों में से एक है। विश्वविद्यालय का मुख्य परिसर बादशाहबाग, और दूसरा परिसर जानकीपुरम में स्थित है । ...
null
null
null
null
Write a Python program which takes a string and returns the first non-repeated character.
String: "hello"
def first_non_repeated_char(input): counts = {} chars = [] for char in input: if char in counts: counts[char] += 1 else: counts[char] = 1 chars.append(char) for char in chars: if counts[char] == 1: return char re...
null
Create a Bash function that takes an integer as input and prints out the corresponding ASCII character.
97
function print_ascii(){ echo "$(printf '\x%x' "$1")" } print_ascii "$1"
null
Implement a recursive function to calculate the factorial of a number, given by the user as an argument.
def calculate_factorial(num): if num == 0 or num == 1: return 1 else: return num * calculate_factorial(num-1)
null
Write a function in Python that takes a list and prints out all the elements in the list.
list1 = [1, 2, 3, 4, 5]
def printList(list1): for x in list1: print(x) printList(list1)
null
Create a if statement in JavaScript that checks if number is divisible by 3.
Number: 9
if (number % 3 === 0) { console.log('Number is divisible by 3'); }
null
Using the code below, update the function to find the average of two numbers.
def find_average(num1, num2): total = num1 + num2
def find_average(num1, num2): total = num1 + num2 average = total / 2 return average
null
Define a function that takes a string and prints it in reverse order.
def print_reverse(str): for i in range(len(str)-1, -1, -1): print(str[i], end="") print()
null
Identify the incorrect statement about the following code fragment.
def is_over21(age): if age > 21: return “true” else: return
The function returns a string, "true" which is invalid. The function should return a boolean value instead (True or False).
null
Create a Python script to print all entries of a data set in a table format?
data_set = [['Name', 'Age', 'Location'], ['James', 30, 'London'], ['Mary', 25, 'New York'], ['John', 28, 'Toronto']]
def print_table(data_set): col_width = max(len(word) for row in data_set for word in row) + 2 # padding for row in data_set: print("".join(word.ljust(col_width) for word in row)) print_table(data_set) # Output Name Age Location James 30 London Mary 25 New York John 28 Toronto
null
Design a Python class to hold a given array of objects.
[1, 2, 3, 4, 5]
class ArrayContainer: def __init__(self, arr): self.arr = arr def get_array(self): return self.arr
[CS Wikipedia] Rovnovážná poloha Rovnovážná poloha je poloha tuhého tělesa, při níž je výslednice všech sil působících na těleso nulová a výsledný moment všech sil je také nulový. Rovnovážná poloha je poloha, která je výsledkem rovnováhy sil. Typy rovnovážných poloh Stálá rovnovážná poloha Stálá rovnovážná poloha (též...
null
null
null
null
List the primitive data types of the language Python.
Python data types include integers, floating-point numbers, strings, Booleans, lists, sets, dictionaries, tuples, and None.
null
Name an advantage of using linked list over an array.
One advantage of a linked list over an array is that it does not require the memory for storing all the elements to be allocated at once. Linked lists allow memory to be allocated as needed and can be easily expanded as new records are added. Also, linked list can easily insert and remove elements at any position in th...
null
Create a python program to trace any recursive function on the screen.
def trace_function(F): def wrapper(*args, **kwargs): print(F.__name__ + str(args) + str(kwargs)) value = F(*args, **kwargs) print(F.__name__ + " returns " + str(value)) return value return wrapper
null
Modify the following code to include a try/except statement.
def read_file(filename): with open(filename) as f: return f.read()
def read_file(filename): try: with open(filename) as f: return f.read() except FileNotFoundError: print(f"File {filename} was not found.")
null
Create a list of the top 3 highest valued elements in the following array.
arr = [7, 5, 8, 4, 9, 6, 1, 3, 2]
arr = [7, 5, 8, 4, 9, 6, 1, 3, 2] # Create a list of the top 3 highest valued elements top_three = [max(arr)] # start with the maximum elements arr.remove(max(arr)) # remove the maximum element from the list top_three.append(max(arr)) #Add the second maximum element to top_three arr.remove(max(arr)) # remove the second...
null
Write a SQL query to create a table with three columns called A, B, and C, where the data type for each column is defined as string.
CREATE TABLE table_name ( A VARCHAR(255) NOT NULL, B VARCHAR(255) NOT NULL, C VARCHAR(255) NOT NULL );
null
Create a web form in HTML with two fields - first name and last name
<form> <label for="firstName">First Name</label><br> <input type="text" id="firstName" name="firstName"><br><br> <label for="lastName">Last Name</label><br> <input type="text" id="lastName" name="lastName"><br><br> </form>
null
Develop a Python function to calculate the mean of an array of numbers.
data = [1, 4, 6]
# Python Function to calculate mean def calculateMean(data): sum = 0 # calculating sum for e in data: sum += e # calculating mean mean = sum / len(data) return mean # Driver code data = [1, 4, 6] mean = calculateMean(data) print("Mean of given data is:", mean)
[EN Wikipedia] Satellites (song) "Satellites" is the first single by Petra Marklund (performing as September) from her second album In Orbit, and is the first single released under her contract with Catchy Tunes. The single was a success in Sweden and Finland and was later released in variety of countries worldwide, s...
null
null
null
null
Write a Python program to randomly shuffle a list of elements.
[1,2,3,4,5,6,7]
import random list_elements = [1,2,3,4,5,6,7] random.shuffle(list_elements) print (list_elements)
null
Write a Python program to search for a given element in multiple lists
my_list1 = [2, 3, 4, 5] my_list2 = [7, 9, 5] elem = 5
def search_elem(my_list1, my_list2, elem): for list in [my_list1, my_list2]: found = False for val in list: if val == elem: found = True break if found: return True return False found = search_elem(my_list1, my_list2, elem) print(f...
null
Sort an array of integers in C++.
[4, 2, 9, 5, 1, 3]
int array [] = {4, 2, 9, 5, 1, 3}; int n = sizeof(array)/sizeof(array[0]); //sort the array std::sort(array, array+n); //print the sorted array for (int i=0; i<n; i++) cout << array[i] << " ";
null
Create a python program that counts the words in a list of sentences.
sentences = ['This is a sentence', 'This is another sentence', 'And yet another sentence.']
def count_words(sentences): count = 0 for sentence in sentences: words = sentence.split() count += len(words) return count
[EN Wikipedia] Tobias and the Angel (Savoldo) Tobias and the Angel is an oil on canvas painting by Giovanni Girolamo Savoldo, created c. 1527. It is held in the Galleria Borghese, in Rome, since 1910. The Galleria's director Giulio Cantalamessa saw the work in a private house in Tivoli and corrected its misattribution...
null
null
null
null
Write a script in Python for generating a histogram for a given set of data.
[3, 5, 8, 1, 9, 12]
import matplotlib.pyplot as plt data = [3, 5, 8, 1, 9, 12] plt.hist(data, color='blue', ec='black') plt.title("Histogram") plt.xlabel("Values") plt.ylabel("Frequency") plt.show()
null
Produce a data structure in Python to model a simple grocery store.
class GroceryStore: def __init__(self): self.items = {} def add_item(self, item, price): self.items[item] = price def get_price(self, item): return self.items.get(item)
[DE Wikipedia] Nicolas Durand de Villegagnon Nicolas Durand de Villegagnon (* 1510 in Provins in Brie; † 9. Januar 1571 in Beauvais-en-Gâtinais) war Vizeadmiral der Bretagne im Dienst der französischen Krone und Gründer einer kurzlebigen Kolonie in Brasilien: das antarktische Frankreich (France Antarctique). Leben und...
null
null
null
null
Write a python program to find the sum of squares of all numbers in a set
Set: {1, 2, 3}
def sum_squares(s): total = 0 for x in s: total += x * x return total
[CS Wikipedia] Gletscherhorn Gletscherhorn je hora v Bernských Alpách ve Švýcarsku. Nachází se ve skupině Jungfraugruppe na hranicích mezi kantony Bern a Valais. Leží nad vesnicí Stechelberg asi 20 km jihozápadně od města Interlaken. Na severu sousedí s vrcholem Louwihorn (3777 m), na jihozápadě s vrcholem Äbeni Flue ...
null
null
null
null
Write a python function to format a string according to provided parameters.
Input string: "Hello World" Upper-Case Letters: True Lower-Case Letters: False
def formatString(s, upperCaseLetters, lowerCaseLetters): newStr = "" if upperCaseLetters: newStr = s.upper() elif lowerCaseLetters: newStr = s.lower() return newStr print(formatString("Hello World", True, False)) # Output: "HELLO WORLD"
null
Create a Python program that takes in a list of strings and returns a dictionary with the count of each word.
list_of_strings = ['My', 'name', 'is', 'John', 'Doe', 'My', 'name', 'is', 'John']
def count_words(list_of_strings): count_dict = dict() for word in list_of_strings: if word in count_dict: count_dict[word] += 1 else: count_dict[word] = 1 return count_dict list_of_strings = ['My', 'name', 'is', 'John', 'Doe', 'My', 'name', 'is', 'John'] result = c...
null
Construct a linear regression model in Python to predict the output of a dataset.
import pandas as pd import numpy as np from sklearn.linear_model import LinearRegression # Load the dataset df = pd.read_csv('dataset.csv') # Extract input and output features X = df[df.columns[:-1]].values y = df[df.columns[-1]].values # Create and fit the model model = LinearRegression().fit(X, y) # Output the mo...
null
Implement a basic algorithm in Python for encrypting a string.
Not applicable
def encrypt(message): encrypted_message = "" for character in message: # increment the character number to get its encrypted form encrypted_message += chr(ord(character) + 2) return encrypted_message if __name__ == "__main__": message = "Hello World" encrypted_message = encrypt(message) print(encrypt...
null
Identify which type of triangle the 3 sides of length a, b, and c form.
a = 4, b = 4, c = 6
The triangle is an isosceles triangle as two of its side are of equal length.
null
Create a python program to implement random forest algorithm.
import numpy as np from sklearn.ensemble import RandomForestClassifier #data X = np.array([[1,2,3], [1,2,3], [4,5,6], [4,5,6]]) y = np.array([1,1,2,2]) #Create a Random Forest Classifier clf = RandomForestClassifier(max_depth=2, random_state=0) #Training the model clf.fit(X,y)
null
Develop a function in python to find the index of an element in a list.
a = [2, 3, 4, 5, 2] x = 2
def find_index(a, x): indices = [] if x not in a: return -1 else: for i in range(len(a)): if a[i] == x: indices.append(i) return indices indices = find_index(a, x) print("The index of element 2 in the list is", indices)
[EN Wikipedia] Matthew Wheeler Matthew Benjamin Harold Wheeler (born 14 August 1962) is a former English cricketer. Wheeler was a right-handed batsman who bowled right-arm medium-fast. He was born at Windlesham, Surrey and educated at Winchester College and the University of Exeter. Wheeler made two first-class appear...
null
null
null
[DE Wikipedia] Jochen Sostmann Jochen Sostmann (* 6. März 1938 in Hamburg; † 23. Januar 2019) war ein deutscher Schauspieler bei Bühne und Fernsehen. Leben und Wirken Sostmann erhielt seine Bühnenausbildung im heimatlichen Hamburg bei Eduard Marks. Seinen Einstand an der Bühne gab er Ende der 1950er Jahre am Contra-Kr...
null
null
null
null
Generate a random password with 8 characters long including lowercase letters, uppercase letters, and numbers.
function generatePassword() { let characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; let password = ''; for (let i = 0; i < 8; i++) { let characterIndex = Math.floor(Math.random() * characters.length); let character = characters[characterIndex]; password += character; } return password; } //...
null
Generate a Python program that takes a number as input and calculates its sum of digits.
Number: 123
n = 123 sum_of_digits = 0 while n > 0: digit = n % 10 sum_of_digits += digit n //= 10 print("Sum of digits in 123 is:", sum_of_digits)
null
Suggest a valid JSON dictionary for the following data.
Name: John, Age: 32, Profession: Developer
{"Name": "John", "Age": 32, "Profession": "Developer"}
[CS Wikipedia] Rádio Blaník Rádio Blaník je česká nejposlouchanější komerční celoplošná rozhlasová stanice, která kromě pravidelných krátkých zpráv (regionálních i centrálních) vysílá směs hudby středního proudu jak zahraničních, tak ve velkém českých interpretů. V podílu na trhu má v mnoha krajích 1. místo (Středočes...
null
null
null
null
Suggest a Python code to print the following text in the output: "This is a example sentence".
print("This is an example sentence")
null
Generate a Python program that compares two binary trees to check if they are similar.
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def are_similar(root1, root2): if root1 is None and root2 is None: return True if (root1 and root2) is None or (root1 or root2) is None: return False if root1.val != root2.val:...
null
Use JavaScript to write a program that finds the greatest common divisor of two numbers.
num1 = 45 num2 = 36
function findGCD(num1, num2) { let min = Math.min(num1, num2); while (num1 % min !== 0 || num2 % min !== 0) { min--; } return min; } let result = findGCD(45, 36); console.log(result); // output: 9
null
Generate a python program to determine if two objects are mutually exclusive or not.
Input objects are ([1,2,3], [4,5,6]).
def mutually_exclusive(object1, object2): if len(object1.intersection(object2)) > 0: return False else: return True object1 = set([1, 2, 3]) object2 = set([4, 5, 6]) result = mutually_exclusive(object1, object2) print(result) # Outputs True as objects don't share elements.
[DE Wikipedia] Miloslav Ransdorf Miloslav Ransdorf (* 15. Februar 1953 in Rakovník; † 22. Januar 2016 in Prag) war ein tschechischer kommunistischer Politiker, Philosoph und Abgeordneter des Europaparlaments. Leben Sein Studium schloss er 1977 an der Philosophischen Fakultät der Karls-Universität in Prag ab, an der er...
null
null
null
null
Debug the following code to print the correct output.
num = [2, 5, 12, 8] output = [] for n in num: output.apend(n**2) print(output)
num = [2, 5, 12, 8] output = [] for n in num: output.append(n**2) print(output)
[CS Wikipedia] Slow jam Slow jam je obvykle zpomalená baladická jemná píseň s R&B-orientovanou melodií. Slow jamy jsou buď R&B balady nebo downtempo písně. Slow jam může mít Jazz/Funk/R'n'B/Quiet storm/pop elementy. Název termínu pochází z doby, kdy kapela Midnight Star (SOLAR Records) nahrála píseň "Slow Jam" do svéh...
null
null
null
null
Generate a code this that calculates the gross salary including allowance
Basic salary: 10,000 Allowance: 4,000
let basicSalary = 10000; let allowance = 4000; let grossSalary = basicSalary + allowance; console.log(grossSalary); //14,000
null
Write an HTML page with a form which takes the input of an email address and a password and sends an email to the given address.
<html> <head> <title>Form Email</title> <meta charset="utf-8" /> </head> <body> <form method="post" action="send-email.php"> <label>Email: <input type="text" name="email" /> </label> <label>Password: <input type="password" name="password" /> </label> <input type="submit" value="Send Email" /> </form> </body> </html>
null
Write a SQL query to join two tables ‘employees’ and ‘locations’ on the key ‘city’ and return only the employees of age 25-35
Table A (employees): id | name | city | age Table B (locations): city | region
SELECT e.id, e.name, e.city, e.age FROM employees e INNER JOIN locations l ON e.city = l.city WHERE e.age BETWEEN 25 AND 35;
[HI Wikipedia] बुरज़िल दर्रा बुरज़िल दर्रा (Burzil Pass) कश्मीर क्षेत्र का एक ऐतिहासिक दर्रा है जो श्रीनगर को पाक अधिकृत कश्मीर के गिलगित-बल्तिस्तान क्षेत्र में स्थित गिलगित और स्कर्दू से जोड़ता है। यहाँ से यात्री और व्यापारी घोड़ों और टट्टुओं पर सवार यातायात करा करते थे लेकिन भारत के विभाजन के बाद यह पाकिस्तान द्वारा...
null
null
null
[EN Wikipedia] Constitución Unido Club Deportivo y Social Constitución Unido is a Chilean football club based in Constitución, Chile. The club was founded on February 18, 1998, and played for nine years in Tercera División A and 16 seasons in Segunda División de Chile. See also Chilean football league system Stadium E...
null
null
null
null
Write a Python program to print the following string pattern.
*__*__*
for i in range(3): for j in range(3): if (i == j) or (i + j == 2): print('*', end="") else: print('_', end="") print()
[DE Wikipedia] TV 1890 Rüsselsheim-Haßloch Der TV 1890 e.V. Rüsselsheim-Haßloch (kurz TVH oder TVH Rüsselsheim) wurde 1890 als Turnverein in Haßloch gegründet. Heute hat der Verein über 1800 Mitglieder und gehört zu den größten Sportanbietern in Rüsselsheim am Main. Das Sportangebot umfasst neun Abteilungen, dazu gehö...
null
null
null
null
Write a JavaScript function to check if an array contains a specific element.
var arr = [1,2,3,4];
function contains(arr, element) { return arr.indexOf(element) > -1; } console.log(contains(arr, 2)); //true
null
What is the difference between deep learning and traditional AI?
The primary difference between deep learning and traditional AI is the way they process and interpret data. Deep learning uses a multi-layered artificial neural network in order to learn the patterns and features in data, while traditional AI uses symbolic reasoning and rule-based algorithms to process data. Deep learn...
null
Design a class representing a car using Python.
class Car(): def __init__(self, model, make, color, engine_power, num_wheels): self.model = model self.make = make self.color = color self.engine_power = engine_power self.num_wheels = num_wheels def start_engine(self): print("Engine started.") def stop_eng...
null
Sort the given list according to the last three digits of every number.
[332, 555, 898, 876]
def sort_list(numbers): """Sorts a list of numbers according to the last three digits of each number.""" return sorted(numbers, key=lambda x: x % 1000)
[DE Wikipedia] Esperantomuseum Das Esperantomuseum der Österreichischen Nationalbibliothek mit der Sammlung für Plansprachen wurde 1927 von Hugo Steiner als Verein gegründet und 1928 an der Österreichischen Nationalbibliothek in Wien eingerichtet. Eine über 80-jährige kontinuierliche Sammeltätigkeit ließ die weltweit ...
null
null
null
null
Using SQL, write a query to identify the student ID and the name of the student who scored the highest marks in a given subject.
SELECT students.id AS student_id, students.name AS student_name FROM students INNER JOIN marks ON students.id = marks.student_id WHERE marks.subject = ‘Subject1’ ORDER BY marks.mark DESC LIMIT 1;
null
Write a python program to represent the given data using a tree structure.
[{'name': 'John', 'age': 20}, {'name': 'David', 'age': 26}, {'name': 'Adam', 'age': 16}, {'name': 'Stephen', 'age': 35}]
def create_tree(data): tree = { 'age': None, 'children': [] } for d in data: node = { 'age': d['age'], 'name': d['name'], 'children': [] } tree['children'].append(node) return tree
null
Reformat the following C++ code to reduce the memory it needs to function.
char str1[] = "Hello"; char str2[] = "World!";
const char* str1 = "Hello"; const char* str2 = "World!";
null
Design an algorithm in Python for finding the longest common subsequence between two strings.
"AGGTAB", "GXTXAYB"
def lcs(a, b): lengths = [[0 for j in range(len(b)+1)] for i in range(len(a)+1)] # row 0 and column 0 are initialized to 0 already for i, x in enumerate(a): for j, y in enumerate(b): if x == y: lengths[i+1][j+1] = lengths[i][j] + 1 else: ...
null
Edit the following XML code to add a navigation bar to the top of a web page
<html> <head> <title>My Webpage</title> </head>
<html> <head> <title>My Webpage</title> </head> <body> <nav> <ul> <li><a href="index.html">Home</a></li> <li><a href="about.html">About Us</a></li> <li><a href="contact.html">Contact</a></li> </ul> </nav> </body>
[HI Wikipedia] मद्रिद मद्रिद, स्पेन की राजधानी और सबसे अधिक जनसंख्या वाला शहर है। शहर में लगभग 3.4 मिलियन निवासी हैं और महानगरीय क्षेत्र की आबादी लगभग 6.7 मिलियन है। यह यूरोपीय संघ का दूसरा सबसे बड़ा शहर है, और इसका महानगरीय क्षेत्र यूरोपीय संघ में दूसरा सबसे बड़ा शहर है। नगरपालिका में 604.3 km² भौगोलिक क्षेत्र शामिल ...
null
null
null
[DE Wikipedia] Peter Podlunšek Peter Podlunšek (* 25. Mai 1970, Trbovlje, Slowenien) ist ein slowenischer Kunstflugpilot, der in den Jahren 2014, 2015 in der Challenger Class und in den Jahren 2016, 2017 in der Master Class der Red Bull Air Race Weltmeisterschaft startete. Karriere Anfänge Geboren in Trbovlje war Podl...
null
null
null
null
Write a function to rearrange a given string in alphabetical order
myString = ‘ Hello World’
def rearrange_string(myString): myString = myString.lower().strip() words = myString.split(' ') words.sort() return ' '.join(words) print(rearrange_string(myString))
null
Write a JavaScript code that gets the URL of a web page.
var url = window.location.href;
null
Construct an SQL query to Create a table with name "Order" in the database
CREATE TABLE Order ( order_id INT NOT NULL, customer_name VARCHAR(255) NOT NULL, order_date DATE NOT NULL, order_amount DECIMAL(15, 2) NOT NULL );
null
Create a function in Python to move a list of items from one list to another.
list1 = [2, 4, 6, 8, 10] list2 = [1, 3, 5, 7, 9]
def move_items(list1, list2): for item in list1: list2.append(item) for i in range(len(list1)): list1.pop() list1 = [2, 4, 6, 8, 10] list2 = [1, 3, 5, 7, 9] move_items(list1, list2) print("List 1 = ", list1) print("List 2 = ", list2)
null
Create a Python script to match parts of speech of two given sentences.
Sentence 1: She is the best player. Sentence 2: He is the worst player.
from nltk import word_tokenize, pos_tag def match_pos(sent1, sent2): sent1_tokens, sent2_tokens = word_tokenize(sent1), word_tokenize(sent2) sent1_pos, sent2_pos = pos_tag(sent1_tokens), pos_tag(sent2_tokens) matches = [] for i in range(min(len(sent1_pos),len(sent2_pos))): if sent1_pos[i][1] =...