text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
null | Create a program which takes an array of integers and an integer as input, and returns the index of the integer in the array. | array = [1, 2, 3, 4]; number = 3; | def indexof(nums, target): for i in range(len(nums)): if nums[i] == target: return i return -1 |
[DE Wikipedia] Hepstedt
Hepstedt () ist eine Gemeinde in der Samtgemeinde Tarmstedt im niedersächsischen Landkreis Rotenburg (Wümme). Geschichte Hepstedt wird 1004 erstmals erwähnt, als König Heinrich II. dem Kloster Kemnade bei Bodenwerder an der Weser Hepstidi als Besitz bestätigt. Im Staatsforst Ummel liegt ein von... | null | null | null |
null | Create a function in Python that takes a string as an input and returns TRUE if it is a palindrome or FALSE if it is not. | def is_palindrome(string): left_pos = 0 right_pos = len(string) - 1 while right_pos >= left_pos: if not string[left_pos] == string[right_pos]: return False left_pos += 1 right_pos -= 1 return True | |
null | Create a function for splitting a string into an array of characters. | def split_string_to_chars(string): '''This function takes a string and splits it into an array of characters.''' return list(string) | |
null | Generate a Python script to create a random password of length 8 characters consisting of alphabets(lower and upper), numbers, and symbols. | Not applicable | import random
import string
# generate a random password
def randomPassword():
password = ''
all_characters = string.ascii_letters + string.digits + string.punctuation
# loop over the length
for _ in range(8):
# select a random character
password += random.choice(all_characters)
return password
# print the g... |
null | Represent the given content into a well-formatted JSON structure. | Name: John Doe Age: 33 Gender: Male | { "name": "John Doe", "age": 33, "gender": "Male" } |
null | Create a program that can identify the next number in a sequence. | Find the next number in 3, 7, 11, 15. | def get_next_number(arr): return arr[-1] + (arr[-1] - arr[-2]) if __name__ == "__main__": arr = [3, 7, 11, 15] print(get_next_number(arr)) |
null | Arrange in order of increasing magnitude the elements in an integer array. | arr = [4, 23, 1, 7, 10] | arr.sort(); // arr is now [1, 4, 7, 10, 23] |
null | Create a function to calculate the following expression and output the result. | 2^2 + 4 - 3*6 | def expression_result(expression): result = eval(expression) return result print(expression_result("2**2 + 4 - 3*6")) # Output: -6 |
null | Design a natural language processing algorithm in Python to extract names from a text. | import nltk
#tokenize the text
text = "John and Mary went to the park. They had a great time."
tokenized_text = nltk.word_tokenize(text)
# tag the tokens with their part-of-speech
tagged_words = nltk.pos_tag(tokenized_text)
# filter for proper nouns
names = [word for word,pos in tagged_words if (pos == 'NNP' or pos ... | |
[CS Wikipedia] Vrh vodorovný
Vrh vodorovný je pohyb tělesa v tíhovém poli, při kterém počáteční rychlost tělesa má směr kolmý ke směru tíhového zrychlení. Vodorovný vrh je složený – pohyb vrženého tělesa vodorovným směrem a volný pád tělesa. Vodorovný vrh je speciálním případem šikmého vrhu. Pokud vrh probíhá ve vakuu... | null | null | null |
[CS Wikipedia] Jan mladší Popel z Lobkovic
Jan mladší Popel z Lobkovic (8. listopadu 1510 – 12. dubna 1570 Praha-Hradčany), od roku 1569 starší, také Jan IV. Popel z Lobkowicz byl český šlechtic, představitel mladší – popelovské linie rodu Lobkoviců, zakladatel jeho tachovské pošlosti, nejvyšší komorník a nejvyšší pur... | null | null | null |
null | Create a function to sort the given array of numbers in descending order. | [7, 2, 5, 1, 4] | def sort_number(arr): arr.sort(reverse=True) return arr arr = [7, 2, 5, 1, 4] print(sort_number(arr)) # Output: [7, 5, 4, 2, 1] |
[EN Wikipedia] Will Ord
Will Ord is a UK-based educational trainer and speaker, who is specialised in Thinking Skills, Religious Education, and Citizenship Education. He is also the Chair of the Society for Advancing Philosophical Enquiry and Reflection in Education (SAPERE). Ord advocates for education that promotes ... | null | null | null |
null | Given a sequence of numbers, write a program to find the length of the longest subsequence in which all numbers are in increasing order. | arr = [1, 7, 4, 3, 2, 8] | def findLongestSubsequence(arr): n = len(arr) dp = [1]*n for i in range(1, n): for j in range(i): if arr[i] > arr[j] and dp[i] < dp[j] + 1 : dp[i] = dp[j]+1 return max(dp) |
null | Given an array of numbers, generate a Python program to find the maximum value. | [1, 4, 6, 8, 3, 9, 5] | def find_max(arr):
max_val = arr[0]
for el in arr:
if el > max_val:
max_val = el
return max_val
arr = [1, 4, 6, 8, 3, 9, 5]
print(find_max(arr)) |
null | Please fix the following broken HTML code. | <html> <head> <title>Test HTML Page </head> <body> /body> </html> | <html> <head> <title>Test HTML Page</title> </head> <body> </body> </html> |
[HI Wikipedia] इटारसी
इटारसी (Itarsi) मध्य प्रदेश प्रान्त का एक शहर है जो कि नर्मदापुरम जिले के अन्तर्गत आता हैं। इटारसी के नाम के उत्पत्ति ईंट और रस्सी शब्द के संयोग से हुई है इसका कारण प्राचीन काल में इन उद्योगों की बहुतायत होना। व्यावसायिक दृष्टि से, एक बड़ी कृषि मंडी, आयुध निर्माणी, एवम् रेलवे के कारखानो से। यह नर... | null | null | null |
null | Create an object-oriented programming model using python to represent a student in a classroom. | class Student:
def __init__(self, name, age):
self.name = name
self.age = age
def get_info(self):
return "Name: {}, Age: {}".format(self.name, self.age) | |
null | Create a function that filters an array of elements based on a given criteria and returns an array of the resulting elements. | lst = [2, 3, 4, 5, 6, 7, 8, 9] # elements to filter criteria = lambda x: x > 5 # criterion to filter by | def filter_by(lst, criteria): """This function takes an array of elements and a criteria and returns an array of elements filtered by the criteria.""" return [x for x in lst if criteria(x)] |
null | Write a code to get the user input for two numbers and print the sum of the two numbers. | # Get user input for two numbers num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: ")) # Print the sum of the two numbers print("The sum of the two numbers is:", num1 + num2) | |
[EN Wikipedia] Alistipes
Alistipes is a Gram-negative genus of rod-shaped anaerobic bacteria in the phylum Bacteroidota. When members of this genus colonize the human gastrointestinal (GI) tract, they provide protective effects against colitis (intestinal inflammation), autism, and cirrhosis (liver fibrosis). However,... | null | null | null |
null | Construct a Python class named Person which contains the instance variables name, age, and gender. | Class Person:
def __init__(self,name,age,gender):
self.name = name
self.age = age
self.gender = gender | |
null | Design a program in Python to find the frequency of a specific word in a given sentence. | 'Python is an interpreted, high-level and general-purpose programming language.' | def word_frequency(sentence, word):
# remove special characters
sentence = sentence.replace('.', '')
# split the sentence into words
words = sentence.split(' ')
# count frequency
count = 0
for w in words:
if w.lower() == word:
count += 1
return count
words_frequency ... |
null | How can we create a class in C++ to represent a point on a 2D plane? | class Point { int x; int y; public: Point(int _x, int _y) : x(_x), y(_y) {} }; | |
[DE Wikipedia] Digya-Nationalpark
Der Digya-Nationalpark ist mit einer Fläche von 3124 km² der zweitgrößte Nationalpark in Ghana. Er liegt auf einer Halbinsel, die von Westen in den Volta-See hineinragt. Sein Gebiet befindet sich zum Teil in der Bono East Region Ghanas und zum Teil in der Ashanti Region. Der Jahresnie... | null | null | null |
[HI Wikipedia] कुवैत
कुवैत (अरबी: دولة الكويت, दवालात अल-कुवैती) पश्चिम एशिया में स्थित एक संप्रभु अरब अमीरात है, जिसकी सीमा उत्तर में सउदी अरब और उत्तर और पश्चिम में इराक से मिलती है। उत्तर से लेकर दक्षिण तक की अधिकतम दूरी 200 कि॰मी॰ (120 मील) और पूर्व से लेकर पश्चिम तक की दूरी 170 किमी (110 मील) है। कुवैत एक अरबी श... | null | null | null |
null | Create a SQL query to select customers who have spent more than $1000 in the last month. | SELECT customerId FROM orders WHERE orderDate > DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND total > 1000 | |
null | Generate a Python script that filters a list of strings, keeping only those that have a length greater than 5 characters. | words = ["hello", "world", "example", "test"] | def filter_words(words):
filtered_words = []
for word in words:
if len(word) > 5:
filtered_words.append(word)
return filtered_words
words = ["hello", "world", "example", "test"]
filtered_words = filter_words(words)
print(filtered_words) # Output: ['example', 'test'] |
[DE Wikipedia] Boo Nieves
Cristoval „Boo“ Nieves (* 23. Januar 1994 in Baldwinsville, New York) ist ein US-amerikanischer Eishockeyspieler, der zuletzt bis Juli 2021 bei den Tampa Bay Lightning aus der National Hockey League unter Vertrag stand. Karriere Nieves spielte zunächst zwischen 2010 und 2012 an der Kent Schoo... | null | null | null |
null | Construct an algorithm that finds the minimum element in an array of values. | [5, 4, 11, 7, 12, 55, 3] | Create a variable called min and set its value to be the first element of the array. Loop through elements of the array and compare the value at each index to the value of min. If the value at the current index is less than min, update min with the current index's value. When the loop has finished, min will contain the... |
null | Write an if-else statement in Java to check if a given number is greater than or equal to 15. | Number: 9 | int number = 9; if (number >= 15) { System.out.println("Number is greater than or equal to 15"); } else { System.out.println("Number is less than 15"); } |
null | Write a code which reverses the order of items in an array | my_list = [1,2,3,4,5] | # Reversing the order of items in an array def reverse_order(input_list): return input_list[::-1] my_list = [1,2,3,4,5] print(reverse_order(my_list)) # Output: [5, 4, 3, 2, 1] |
null | Create a Python program to find the longest consecutive sequence of integers in an unsorted array. | [9, 6, 1, 3, 7, 5, 4, 8] | def find_longest_consecutive_sequence(arr):
longest_val = 0
current_val = 0
for i in range(0, len(arr)-1):
current_val = 0
j = i
while arr[j] + 1 == arr[j+1]:
j += 1
current_val += 1
if current_val > longest_val:
longest_val = current_val
... |
null | Write a Python script to swap two variables. | x = 10
y = 20
#Swap the values
x, y = y, x
print("After swapping: x =", x, "and y =", y) | |
null | Construct a function in C++ to check if two numbers are co-prime or not. | bool isCoprime(int a, int b) { // Everything divides 0 if (a == 0 || b == 0) return false; // base case if (a == 1 || b == 1) return true; // a is divisible by b if (a % b == 0 || b % a == 0) return false; // a is even if (a % 2 == 0) return (b % 2 == 1) ? isCoprime(a/2, b) : isCoprime(a/2, b/2); // b is even if (b % 2... | |
null | Create a function to return all possible sums of two numbers. | def two_num_sums(nums): """Returns a list of all possible sums of two numbers from nums.""" combinations = [] for i in range(len(nums)-1): for j in range(i+1, len(nums)): combination = nums[i]+nums[j] combinations.append(combination) return combinations | |
null | Write a code to edit a given column in an SQL table. | ALTER TABLE my_table MODIFY my_column TYPE INT; | |
null | Create a Python program to detect outliers in a given dataset and replace them with the mean of the remaining non-outlier values. | [1.2, 3.4, 4.5, 3.1, 2.2, 4.9, 4.2, 2.1, 1.1, 5.1, 5.2] | import pandas as pd
def detect_outliers(data):
# Calculate the mean
mean = data.mean()
# Calculate the standard deviation
std_dev = data.std()
# Set outliers limit
outliers_limit = mean + 3*std_dev
# For every data point compute the z-score and check if it's an outlier
for data_point... |
null | Create a PHP form to register a user. | <!doctype html> <html> <head> <title>User Registration Form</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style type="text/css"> #form-div { background-color: #ffffff; padding: 10px 20px; border: #e0dfdf 1px solid; } #form-div h2 { padding-bottom: 10px; } #form-div input, #form-div sel... | |
null | Write a Python function to compare two strings and check if they are equal. | Compare 'Hello' and 'World' | def str_compare(str1, str2):
return str1 == str2
str_compare('Hello', 'World') |
[HI Wikipedia] जवाहरलाल नेहरू
जवाहरलाल नेहरू (नवम्बर १४,१८८९ - मई २७, १९६४) भारत के प्रथम प्रधानमन्त्री थे और स्वतन्त्रता के पूर्व और पश्चात् की भारतीय राजनीति में केन्द्रीय व्यक्तित्व थे। महात्मा गांधी के संरक्षण में, वे भारतीय स्वतन्त्रता आन्दोलन के सर्वोच्च नेता के रूप में उभरे और उन्होंने १९४७ में भारत के एक स्वतन... | null | null | null |
null | Construct a SQL query to get all the rows of a table ordered by the largest value in each row first. | SELECT ... | SELECT * FROM Table ORDER BY MAX(column1, column2, ...) DESC; |
[EN Wikipedia] Badminton at the 2019 SEA Games – Men's team
The badminton men's team tournament at the 2019 SEA Games in Manila will be held from 1 to 4 December at the Muntinlupa Sports Complex, Metro Manila, Philippines. Schedule All times are Philippines Standard Time (UTC+08:00) Results Quarter-finals Semi-finals ... | null | null | null |
null | Find the maximum value of an array without using any built-in functions | [7, 9, -2, 15, 3] | def find_max(arr): max = arr[0] for i in range(1, len(arr)): if arr[i] > max: max = arr[i] return max arr = [7, 9, -2, 15, 3] print(find_max(arr)) |
null | Create a program in Python that evaluates a given expression and displays the result in decimal. | "3 + 4 * 5 + 9" | def evaluate_expression(expression):
"""
Function to evaluate an arithmetic expression and return the result
"""
# define an operator precedence dictionary
op_precedence = {'+': 1, '-': 1, '*': 2, '/': 2}
# break the expression into tokens
expression_tokens = expression.split(' ')
... |
null | How would you convert a binary number to decimal in JavaScript? | const binaryToDecimal = binaryString => parseInt(binaryString, 2); | |
[DE Wikipedia] Rena (Norwegen)
Rena ist eine Ortschaft in der norwegischen Kommune Åmot in der Provinz (Fylke) Innlandet. Der Ort stellt das Verwaltungszentrum von Åmot dar und hat Einwohner (Stand: ). Geografie Rena ist ein sogenannter Tettsted, also eine Ansiedlung, die für statistische Zwecke als eine Ortschaft gez... | null | null | null |
null | Suggest a way to convert a JSON object to a string in JavaScript. | The JSON.stringify() method can be used to convert a JSON object to a string in JavaScript. It takes two parameters: the object to be stringified and an optional replacer to modify the values before they are stringified. The result is a JSON-formatted string. Example: const object = {'name': 'John', 'age': 25}; const s... | |
null | Develop a bot in Python to simulate a conversation between two people. | # Importing the necessary libraries
import random
# Defining the responses for the bot
questions = ["What is your favorite movie?", "What is your favorite color?"]
responses = ["My favorite movie is 'The Godfather'. I love the classic vibe of the movie.",
"My favorite color is blue. It's soothing and cal... | |
[CS Wikipedia] Bochnatka
Bochnatka (Pectinatella) je rod mechovky žijící ve sladké vodě - žije jako volně plovoucí, či usedlá rosolovitá hmota o hmotnosti až několik kilogramů. Od roku 2003 se v České republice šíří bochnatka americká (Pectinatella magnifica Leidy, 1851), i když její výskyt se na území Česka objevil j... | null | null | null |
null | Build a code program to index a set of strings of variable lengths. | Strings: "I am learning python", "I love coding", "Coding is awesome" | from collections import defaultdict
def index_strings(strings):
index = defaultdict(list)
for string in strings:
for i, char in enumerate(string):
index[char].append((i, string))
return index
strings = ["I am learning python", "I love coding", "Coding is awesome"]
print(index_strings(s... |
null | Write a function to give the intersection of two unsorted linked lists. | def intersection(head1, head2): s = set() current1 = head1 current2 = head2 while current1 is not None: s.add(current1.data) current1 = current1.next result = [] while current2 is not None: if current2.data in s: result.append(current2.data) current2 = current2.next return result | |
[EN Wikipedia] Afghanistan
Afghanistan, officially the Islamic Emirate of Afghanistan, is a landlocked country located at the crossroads of Central Asia and South Asia. Referred to as the Heart of Asia, it is bordered by Pakistan to the east and south, Iran to the west, Turkmenistan to the northwest, Uzbekistan to the... | null | null | null |
null | Read a code and find all the function calls that are made. | print('Hello world!') my_function() my_function2(2, 3) | The two function calls made are "my_function()" and "my_function2(2, 3)". |
[EN Wikipedia] Pearse River
The Pearse River is a river of the Tasman Region of New Zealand's South Island. It flows east from sources in the Wharepapa / Arthur Range, reaching the Motueka River 20 kilometres southwest of Motueka. The source is a resurgence near the Nettlebed Cave. The resurgence has been dived to a d... | null | null | null |
[DE Wikipedia] Vendelinus
Vendelinus steht für: Govaert Wendelen (1580–1667, Gelehrtenname Vendelinus), flämischer Astronom Vendelinus (Mondkrater), benannt nach Govaert Wendelen | null | null | null |
null | Create a Python program that, given a person's Birthdate and current date, returns the age of the person. | Birthdate: 6 Dec 1996
Current Date: 18 March 2021 | def calculate_age(birthdate, current_date):
age = current_date.year - birthdate.year
if current_date.month < birthdate.month:
age -= 1
elif (current_date.month == birthdate.month and
current_date.day < birthdate.day):
age -= 1
return age
import datetime
birthdate = datetime.da... |
null | Create a web application using Python and Django that enables users to register and log in. | Not applicable | from django.contrib.auth.forms import UserCreationForm
class SignUpForm(UserCreationForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['username'].label = 'Display Name'
self.fields['email'].label = 'Email Address'
form = SignUpForm(data=request.POST or None)
if form... |
null | Train a machine learning model in Python using a given dataset and generate a confusion matrix. | // Dataset of 1000 samples and 30 features | from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)
model.fit(X_train, y_train)
predictions = model.predict(X_test)
confusion_matrix(y_test, predictions) |
null | Develop a function in Java that takes two integers as its arguments and prints out the maximum of the two. | A = 25 B = 27 | /** * Develop a function in Java that takes two integers as its arguments and prints out the maximum of the two. */ public class maximum { public static int maximum(int a, int b){ if(a > b){ return a; } else { return b; } } public static void main(String[] args) { int a = 25; int b = 27; int max = maximum(a, b); System... |
null | Solve this regular expression problem. | A string should start with a letter, contain only letters and numbers, and should be at least 8 characters in length. | /^[A-Za-z][A-Za-z0-9]{7,}$/ |
null | Create a list containing a given number of random numbers. | import random def random_list(length): rand_list = [] for i in range(length): rand_list.append(random.randint(0,100)) return rand_list | |
null | Create a Python function to evaluate a given polynomial equation | P(x) = x^2 - 4x + 6 | def poly_evaluation(x):
return x**2 - 4*x + 6
x = 2
result = poly_evaluation(x)
print(result) # prints 0 |
null | Convert the following if-else scenerio into switch statements. | if (x == 1) { y = 10; } else if (x == 2) { y = 20; } else if (x == 3) { y = 30; } | switch (x) { case 1: y = 10; break; case 2: y = 20; break; case 3: y = 30; break; default: // no default required } |
null | Create an SQL query to return the customer name and total amount spent on all orders in the past week. | SELECT customer_name, SUM(amount) AS total_spent FROM orders WHERE order_date > DATE_SUB(NOW(), INTERVAL 1 WEEK) GROUP BY customer_name; | |
[HI Wikipedia] यौन हिंसा
यौन हिंसा शारीरिक और मानसिक स्वास्थ्य पर गहरा प्रभाव डालती है। साथ ही साथ यह शारीरिक चोट का भी कारण बन रही है, इसमें यौन और प्रजनन स्वास्थ्य की समस्याओं के तात्कालिक और दीर्घकालिक दोनों तरह के परिणामों के जोखिम भी जुड़े हुए हैं। यौन हिंसा, दुनिया भर में होता है, हालांकि अधिकांश देशों में इस सम... | null | null | null |
null | Write a Python code to create a dictionary which records the frequency of words in a given string. | " this is a test string " | # Create a dictionary to record the frequency of words in a given string
# Split the string into words
words = "this is a test string".strip().split()
# We use a dictionary to store the frequency of the words
freq = {}
# Iterate through the words and count their frequency
for word in words:
if word in freq:
... |
null | Create a string parameter with a default value in golang. | myString := flag.String("name", "Default Value", "description") | |
[CS Wikipedia] Bielovodské Žabie plesá
Bielovodské Žabie plesá () je soubor dvou ledovcových jezer nacházejících se v horní části Žabí Bielovodské doliny ve Vysokých Tatrách na Slovensku. Plesa leží v nadmořské výšce 1675 m a 1699 m. Plesa Odkazy Poznámky Literatura Související články Žabia Bielovodská dolina Externí ... | null | null | null |
null | Write a JavaScript code snippet that will add two numbers. | let num1 = 5; let num2 = 8; let sum = num1 + num2; console.log(sum); | |
null | Write a Python program to print out the ASCII table. | def print_ascii_table():
for i in range(32, 127):
print(f"Character:{chr(i)}, ASCII Number:{i}") | |
null | Write a Bash command that outputs the system's date as "DD-MM-YYYY". | date +"%d-%m-%Y" | |
null | Write a Python code to convert a given list of strings to all lowercase. | ['CoDE', 'OF', 'LinK'] | def to_lowercase(strings):
return [string.lower() for string in strings]
result = to_lowercase(['CoDE', 'OF', 'LinK'])
print(result) |
null | Implement Object-Oriented Programming in this blog post. | Blog post content:
This post is about the basics of Python programming. You'll learn about data types, loops, and functions | # Object-Oriented Programming Implementation
class Python:
# Basic data types
INTEGER = "integer"
FLOAT = "float"
STRING = "string"
BOOLEAN = "boolean"
def __init__(self):
self.__data_types = [self.INTEGER, self.FLOAT, self.STRING, self.BOOLEAN]
# Function to get the data types
... |
null | Design a python program that calculates a person's BMI (body mass index). | def calculate_bmi(weight, height):
bmi = weight/(height**2)
return bmi | |
null | Implement a method to check if a given string has all unique characters. | def has_unique_chars(string): chars = set() for char in string: if char in chars: return False else: chars.add(char) return True | |
null | Generate a Python program to remove all elements of given list present in other list. | list1 = [1, 2, 3, 4, 5, 6], list2 = [2, 4, 6] | def remove_from_list(list1, list2):
for i in list2:
list1.remove(i)
return list1
list1 = [1, 2, 3, 4, 5, 6]
list2 = [2, 4, 6]
print(remove_from_list(list1, list2)) |
null | Prepare a training dataset for a Machine Learning model using Python. | Not applicable | import pandas as pd
# Read in the data
df = pd.read_csv('data.csv')
# Preprocess the data
df = preprocessData(df)
# Split the data into training and test
train_X, test_X, train_y, test_y = train_test_split(df.drop('X',axis=1),
df['X'], test_size=0.2)
# Save the training and test data to files
train... |
null | Edit the following code so that it will print out all the integer numbers between 0 and 10. | for x in range(10): print(x) | for x in range(11): print(x) |
null | Create a Python function to strip a given string of its whitespace. | def strip_whitespace(string):
return string.replace(" ", "")
print(strip_whitespace('Hello World')) # HelloWorld | |
null | Create a python code to generate a dictionary of char counts for a given string. | input_string = "Hello World!" | def char_count_dict(input_string):
char_dict = {}
for char in input_string:
if char in char_dict:
char_dict[char] += 1
else:
char_dict[char] = 1
return char_dict
print(char_count_dict(input_string)) |
null | What is a text editor? | A text editor is a computer program used for entering, editing, formatting and displaying text. Some text editors support syntax coloring, code completion and autopairing for programming languages. Text editors are used for programming, writing, composition, web design and many other forms of text-related work. | |
null | Write a function in Python to implement a linear search algorithm. The algorithm should return the index of the number in the array if found, otherwise -1. | data = [7, 13, 11, 9, 12] search_num = 9 | def linear_search(data, search_num): for index, num in enumerate(data): if num == search_num: return index return -1 |
[DE Wikipedia] Liste der Naturdenkmale in Aichelberg (Landkreis Göppingen)
Die Liste der Naturdenkmale in Aichelberg nennt die verordneten Naturdenkmale (ND) der im baden-württembergischen Landkreis Göppingen liegenden Gemeinde Aichelberg. In Aichelberg gibt es insgesamt vier als Naturdenkmal geschützte Objekte, davon... | null | null | null |
null | Create a Python program to classify the digits in a dataset | Features: [0.25, 0.33, 0.46, 0.83, 0.14]
Labels: [0, 0, 1, 1, 0] | import numpy as np
from sklearn.svm import SVC
features = np.array([[0.25, 0.33, 0.46, 0.83, 0.14]])
labels = np.array([0, 0, 1, 1, 0])
clf = SVC()
clf.fit(features, labels)
# predicting the class of the following data
test_data = np.array([[0.36, 0.22, 0.91, 0.81, 0.12]])
result = clf.predict(test_data)
pri... |
null | Create a class in Python that takes two arguments a 'name' and 'age' and returns a greeting. | - | class Greeting:
def __init__(self, name, age):
self.name = name
self.age = age
def get_greeting(self):
return f"Hello, my name is {self.name} and I am {self.age} years old." |
null | Generate a list containing the squares of numbers from 0 to 10. | [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100] | |
[HI Wikipedia] समाजशास्त्र
समाजशास्त्र मानव समाज का अध्ययन है। यह सामाजिक विज्ञान की एक शाखा है, जो मानवीय सामाजिक संरचना और गतिविधियों से सम्बन्धित जानकारी को परिष्कृत करने और उनका विकास करने के लिए, अनुभवजन्य विवेचन और समालोचनात्मक विश्लेषण की विभिन्न पद्धतियों का उपयोग करता है, अक्सर जिसका ध्येय सामाजिक कल्याण के अ... | null | null | null |
null | Write a code for a Javascript program to return the nth Fibonacci number. | 8 | // returns the nth Fibonacci number function nthFibonacciNumber(n) { let fib = [0, 1]; for (i=2; i<=n; i++) { fib[i] = fib[i-2] + fib[i-1]; } return fib[n]; } console.log(nthFibonacciNumber(8)); |
null | Create a Python program to predict the type of fruit based on its color. | Red | import numpy as np
from sklearn import datasets
from sklearn.tree import DecisionTreeClassifier
# Load the dataset
fruits = datasets.load_iris()
# Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(fruits.data, fruits.target, test_size=0.3, random_state=1)
# Train the m... |
null | Write a Bash shell script to print the unique elements in the given array. | list=(1 2 3 1 4 2 5) | #!/bin/bash list=(1 2 3 1 4 2 5) unique_list=() for num in ${list[@]}; do if [[ ! ${unique_list[*]} =~ $num ]]; then unique_list+=($num) fi done echo ${unique_list[@]} |
null | Create a boolean condition to check if the value is a real number. | typeof value == 'number' && isFinite(value) | |
null | Write a Python program to print all the numbers from 1 to n (inclusive), where n is a given number. | n = 20 | for i in range(1, n+1):
print(i) |
null | Create a Python program to find the square root of the sum of two numbers without using the sqrt() function. | Num1 = 4
Num2 = 9 | # Python program
import math
def square_root(a, b):
return math.sqrt(a*a + b*b)
Num1 = 4
Num2 = 9
print("Square root of the sum of two numbers:", square_root(Num1, Num2)) |
null | Write a class definition for a Box class. | class Box: def __init__(self, width, length, height): self.width = width self.length = length self.height = height def calculate_volume(self): return self.width * self.length * self.height | |
null | Write Clojure code to solve the following problem. | Problem: Given a list of words and a target word, find the index of the target word in the list. Example: ("apple", "banana", "citrus") "banana" | (defn solve-problem [lst target] (-> lst (map #(first %) (map-indexed vector)) (filter #(= (second %) target)) (first) (first))) |
null | Create a program that finds the sum of all numbers divisible by 4 between 150 and 300 | sum = 3750 | |
null | Write a Python program to determine and-or operations | x = False and False | x = False and False
# Output
print(x)
# False |
[CS Wikipedia] The Originals (seriál)
The Originals je americký dramatický fantasy televizní seriál, jehož autorkou je Julie Plecová. Premiérově byl vysílán v letech 2013–2018 na stanici The CW. Celkově bylo natočeno 92 dílů v pěti řadách. Vznikl jako spin-off seriálu Upíří deníky, naopak z The Originals byl dále odvo... | null | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.