text
stringlengths
141
2.89k
⌀
instruction
stringlengths
19
1.5k
⌀
input
stringlengths
0
800
⌀
output
stringlengths
1
2.5k
⌀
[HI Wikipedia] हकलाना हकलाना (अंग्रेज़ी: stammering या stuttering, स्टैमरिन्ग या स्टटरिन्ग) मानव वाक-शक्ति में एक प्रकार की वाक बाधा होती है जिसमें बोलने वाले न चाह कर भी शब्दों की ध्वनियाँ दोहराता है, उन्हें खींचता है और कभी-कभी अटककर आवाज़ निकालने में असमर्थ हो जाता है। अक्सर देखा गया है कि हकलाने वाले बहुत बुद्धिमा...
null
null
null
[CS Wikipedia] Mluv, mluv, zajímáš mě Mluv, mluv, zajímáš mě (originální francouzský název Cause toujours... tu m'intéresses !) je francouzská filmová komedie z roku 1979, kterou režíroval Edouard Molinaro podle scénáře Francise Vebera. Hlavní role ve filmu ztvárnili Jean-Pierre Marielle společně s Annie Girardotovou....
null
null
null
null
Given a list of words, write a Python program to generate all valid anagrams.
Python
def generate_anagrams(words): anagrams = [] for word in words: anagrams_list = [] if len(word) == 1: return [word] for anagram in generate_anagrams(words.difference({word})): for i in range(len(word)): anagrams_list.append(anagram[:i]+ word[0] + anagram[i:]) anagrams += anagrams_list return anagram...
[EN Wikipedia] Tautuku River The Tautuku River originates in the Maclennan Range of The Catlins in New Zealand. It continues through native bush for almost its entire length, including McLean Falls. Near its mouth at Tautuku Bay, just north of Tautuku Peninsula, the river flows through the Tautuku Estuary, a breeding ...
null
null
null
null
Write SQL code to select records from a table whose ID is greater than 200.
SELECT * FROM table WHERE ID > 200;
[EN Wikipedia] Rangitane River The Rangitane River is a short river of the Northland Region of New Zealand's North Island. It flows east to reach the Tahoranui River north of Kerikeri. See also List of rivers of New Zealand References Far North District Rivers of the Northland Region Rivers of New Zealand
null
null
null
null
Read the string ‘Hello World’ and identify the lengths of the words using Python
def word_lengths(string): words = string.split(' ') lengths = [] for word in words: lengths.append(len(word)) return lengths word_lengths('Hello World') // [5, 5]
null
Edit the following array in JavaScript so that all the strings are in uppercase.
let array = ['cat', 'dog', 'fish'];
let array = ['CAT', 'DOG', 'FISH'];
null
Write a C program to find the root of a quadratic equation
#include <stdio.h> #include <math.h> // A utility function to calculate the discriminant float discriminant(float a, float b, float c) { return (b*b - 4*a*c); } // Function to calculate the roots of Quadratic Equations void findRoots(float a, float b, float c) { float discriminant = discriminant(a, b, c); if (discrimin...
[HI Wikipedia] साउण्डेक्स साउण्डेक्स (Soundex) एक ध्वन्यात्मक कलन विधि है जिसका उपयोग नामों को उनकी अंग्रेजी ध्वनि के अनुसार व्यवस्थित किए जाने में किया जाता है। इसका उद्देश्य यह है कि समान रूप से उच्चारित (homophones) नामों को समान प्रकार से कोडित किया जाय यद्यपि उनके वर्तनियों में मामूली अन्तर क्यों न हो। यह अल्गोरि...
null
null
null
null
Explain the result of the following one-liner command.
echo Apple Banana Cat | cut -d" " -f2
This command prints the second word of the list of words, i.e., "Banana". The echo command prints out the words 'Apple', 'Banana', and 'Cat', and the cut command is used to extract the parts of each word delimited by spaces. The -d flag specifies the delimiter, which in this case is a space, and the -f flag specifies t...
null
Generate a Monte-Carlo simulation program in Python to estimate the value of Pi.
import random # Function to generate random points def generate_random_point(): x = random.uniform(-1, 1) y = random.uniform(-1, 1) return (x, y) # Function to calculate Pi def calculate_pi(num_samples): # Number of points inside the circle num_inside = 0 for i in range(num_samples): ...
null
Create a Java program to determine whether a given string is a palindrome. A palindrome is a string which reads the same forwards and backwards.
public class Palindrome { public static boolean isPalindrome(String s) { int i = 0, j = s.length()-1; while (i < j) { if (s.charAt(i) != s.charAt(j)) return false; i++; j--; } return true; } public static void main(String[] args) { String s = "madam"; if (isPalindrome(s)) System.out.println("The string is a palindrome....
null
Develop a python script that takes in 2 strings and outputs the longest common subsequence.
string1 = 'GeeksforGeeks' string2 = 'GeeksQuiz'
def longest_common_subsequence(string1, string2): """ Find the longest common subsequence of two strings. Args: string1 (str): first string string2 (str): second string Returns: str: longest common subsequence """ m = len(string1) n = len(string2) dp = [[None]*(...
null
Using regular expressions, extract all telephone numbers from a given string in JavaScript.
let string = "My telephone numbers are 123-456-7890 and 012-345-6789"; let regex = /\d{3}-\d{3}-\d{4}/g; let numbers = string.match(regex); console.log(numbers);
null
Translate the following sentiment analysis model written in Python to JavaScript
model = tf.keras.models.Sequential([ tf.keras.layers.Dense(128, activation='relu', input_shape=(tem_train_data.shape[1],)), tf.keras.layers.Dense(2, activation='softmax') ])
const model = tf.sequential(); model.add(tf.layers.dense({units: 128, activation: 'relu', inputShape: tem_train_data.shape[1]})); model.add(tf.layers.dense({units: 2, activation: 'softmax'}));
null
Design a data structure to keep track of a student's marks for a given course.
class StudentMark{ //stores student ID int student_id; //stores course name string course_name; //stores marks int marks; //constructor StudentMark(int student_id, string course_name, int marks) { this->student_id = student_id; this->course_name = course_name; this->marks = marks; } }
[CS Wikipedia] Lionel Richie Lionel Richie, rodným jménem Lionel Brockman Richie, Jr. (* 20. června 1949, Tuskegee, Alabama, USA) je americký zpěvák, skladatel i herec. Byl frontmanem kapely Commodores. Má adoptovanou dceru Nicole Richie. Životopis V roce 1984 získal dvě Grammy Award ocenění v kategorii The Album of t...
null
null
null
null
Using the input provided, write a Python program to find the longest pattern in the given string.
string = "abccbaabcabccba"
def find_longest_pattern(string): """Function to find the longest pattern in the given string""" longest_pattern = "" for i in range(len(string)): for j in range(i+1, len(string)+1): pattern = string[i:j] if pattern == pattern[::-1]: longest_pattern = max(patt...
null
Create an algorithm to produce a Fibonacci number.
def fibonacci(n): if n <= 1: return n else: return fibonacci(n-1) + fibonacci(n-2)
null
Create a regex that matches any five-digit zip code.
[noinput]
^[0-9]{5}$
null
Write a code to get the median of four numbers
x = 11, y = 12, z = 13, w = 14
def median(x,y,z,w): nums = [x,y,z,w] nums.sort() mid =len(nums)//2 if len(nums)%2 == 0: median = (nums[mid] + nums[mid-1])/2 else: median = nums[mid] return median if __name__ == '__main__': print(median(11,12,13,14))
null
Suggest an algorithm and write Python code to solve the following problem: classify a list of colours into warm and cool colours.
Colours list = ["Red", "Yellow", "Orange", "Green", "Blue", "Purple", "Pink"]
def classify_colours(colours_list): warm_colours = ["Red", "Yellow", "Orange"] cool_colours = ["Green", "Blue", "Purple", "Pink"] warm_values = [] cool_values = [] for colour in colours_list: if colour in warm_colours: warm_values.append(colour) elif colour in cool_c...
null
Update the following Node.js function so that it can handle an array of objects.
function someFunction(obj1, obj2){ console.log('someFunction called'); return `object 1 is ${obj1.key1} object 2 is ${obj2.key2}`; }
function someFunction(arr){ console.log('someFunction called'); let str = "" for (const obj of arr){ str += `object is ${obj.key1} ` } return str; }
null
Write a function in Python to find the sum of all even numbers between 0 and a given number.
def sum_of_even_numbers(n): result = 0 for i in range(0, n + 1): if i % 2 == 0: result += i return result
[HI Wikipedia] सम्मोहन सम्मोहन से कोई कुछ भी करवा सकता है कहना या सोचना गलत होगा। यह एक सरल और सामान्य प्रक्रिया है जिसके समझने में जटिलता है, ये कोई दैवीय शक्ति या काला जादू नहीं है। यह Sycology से सम्मंधित (related) है। सम्मोहन (Hypnosis) वह कला है जिसके द्वारा मनुष्य उस अर्धचेतनावस्था में लाया जा सकता है जो समाधि, ...
null
null
null
null
Create a procedure in C# to print a string.
my_string
void PrintString(string my_string) { Console.WriteLine(my_string); } PrintString("my_string");
null
Implement an algorithm to find all the sets of three numbers in an array which adds up to a given number.
Array: [2, 5, 8], Number: 10
def three_sum(array, number): result_sets = [] for i in range(len(array) - 2): for j in range(i+1, len(array) - 1): for k in range(j+1, len(array)): if array[i] + array[j] + array[k] == number: result_sets.append([array[i], array[j], array[k]]) return result_sets print(three_sum([2, 5, 8], 10)) # Result: [[2, 5, 8]]
null
Create a python script to generate a random password consisting of a combination of 10 alphabetic characters, 9 digits and the symbols @, # and $.
import random import string def randomPasswordGenerator(length): # Generate a random password consisting of 10 alphabet characters, 9 digits and the symbols @, # and $ generated_password = ''.join(random.choice( string.ascii_letters + string.digits + "@#$") for i in range(length)) return generated_...
null
Develop an algorithm in Python to remove duplicates from a list.
# remove_duplicates function takes a list as a parameter # and returns a list with all the duplicates removed def remove_duplicates(input_list): # Create an empty list to store the result result = [] # Iterate through the given list for element in input_list: # Check if the element is already in the re...
null
Create a function to find the total area of a triangle, given its base and height.
def findAreaOfTriangle(base, height): return 0.5 * base * height
null
Create an HTML form for inputting user details.
name, age, email
<form action=""> Name:<br> <input type="text" name="name"> <br> Age:<br> <input type="number" name="age"> <br> Email:<br> <input type="email" name="email"> <br><br> <input type="submit" value="Submit"> </form>
null
Generate a Python script that iterates over a list and prints each item.
list = [1, 2, 3, 4]
for item in list: print(item)
null
Create an object in Ruby that stores a student's name, age, and GPA.
student = { name: "John Smith", age: 22, gpa: 3.5 }
null
Write a code snippet to check if all characters in a given string are letters or numbers.
string = "Welcome123"
function checkString(string) { var lettersOnly = /^[0-9a-zA-Z]+$/; if (string.match(lettersOnly)) console.log("The string contains only letters and numbers."); else console.log("The string contains other characters too."); }
null
Develop a web scraper in Python that collects data from a web page. The scraper should capture the product title, description, and price for each item on the page.
Not applicable
import requests from bs4 import BeautifulSoup url = 'https://www.example.com/products' html = requests.get(url).text soup = BeautifulSoup(html, 'html.parser') products = soup.find_all('div', class_='product') for product in products: title = product.find('h3', class_='title').text description = product.find('p', c...
null
Using a regular expression, extract all prices of items from a given HTML string.
<div> Price of tea is £1.45, price of burger is £2.50, price of coffee is £2.00. </div>
let prices = []; let pricesRegex = /£\d+(?:\.\d+)?/g; let matches = str.match(pricesRegex); for (let i= 0; i < matches.length; i++) { prices.push(matches[i]); } console.log(prices); // ["£1.45","£2.50","£2.00"]
null
Convert the following Python loop into a list comprehension.
for x in range(0, 5): if (x%2 == 0): print(x)
# Solution [x for x in range(0,5) if (x%2 == 0)]
null
Construct a Python script to create a dictionary containing the numbers from 1 to 10 and their squares.
numbers = dict((num, num*num) for num in range(1,11)) print(numbers)
[DE Wikipedia] Easy Love Easy Love ist ein deutscher dokumentarischer Spielfilm von Tamer Jandali aus dem Jahr 2019, der verschiedene junge Paare in ihrem Sex- und Liebesleben inszeniert. Handlung Sören hat Erfolg bei Frauen, bei denen er dann jeweils gleich einzieht. Und unverbindlich bleibt, bis er sich in Maria ver...
null
null
null
[DE Wikipedia] Dmitrij Prokopcov Dmitrij Prokopcov (; * 5. Januar 1980 in Simferopol, Oblast Krim, Ukrainische SSR, Sowjetunion) ist ein ukrainisch, später tschechischer Tischtennisspieler. Von 1996 bis 2017 nahm er an 11 Weltmeisterschaften, 13 Europameisterschaften und einmal an Olympischen Spielen teil. Werdegang D...
null
null
null
null
Create a Python program to solve the following equation.
2x + 3y = 5
#!/usr/bin/env python def solve_equation(eqn): eqn_parts = eqn.split(' ') # co-efficients of x and y a = int(eqn_parts[0].replace('x', '')) b = int(eqn_parts[2].replace('y', '')) # RHS value c = int(eqn_parts[4]) # solving the equation x = (c - (b * 3)) / (2 * a) y = (5 - (2 * x)...
null
Write a SQL statement to join table1 and table 2 on the "name" column.
SELECT table1.name, table1.city, table2.email FROM table1 INNER JOIN table2 ON table1.name=table2.name;
null
Given the following HTML, change the text to "Hello World".
<p>Hi there</p>
<p>Hello World</p>
null
Generate a list of numbers starting from 10 to 50.
myList = list(range(10,51))
[DE Wikipedia] James Ulmer James „Blood“ Ulmer (* 2. Februar 1942 in St. Matthews, South Carolina) ist ein US-amerikanischer Jazz- und Bluesgitarrist. Er stand seit Ende der 1970er Jahre wie auch Ornette Coleman und Ronald Shannon Jackson im Mittelpunkt eines den Free Jazz mit dem Jazzrock neu verschmelzenden Free Fun...
null
null
null
null
This code defines a Python class called "Plugin" that can be used to send push notifications using the Pushover service. To use this class, you need to provide a user key and an API key, as well as a list of devices to send notifications to (if desired), a message title, and a Mako template file (if desired). To send a...
""" Emonoda -- A set of tools to organize and manage your torrents Copyright (C) 2015 Devaev Maxim <mdevaev@gmail.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either vers...
null
Print the positions of all vowels in the given string.
String: mississippi
The positions of all vowels in the string "mississippi" are: [1, 4, 7, 10].
null
Calculate the sum of these two numbers in assembly language.
x = 27, y = 11
mov ax, 27 ; put x = 27 in ax mov bx, 11 ; put y = 11 in bx add ax, bx ; add ax and bx, sum is stored in ax ; ax = 38
null
Create a Python script that fetches a web page and scrapes the HTML to extract the top 5 headlines from the page.
URL to scrape: https://www.nytimes.com/
import requests from bs4 import BeautifulSoup url = 'https://www.nytimes.com/' response = requests.get(url) if response.status_code == 200: html_data = response.text soup = BeautifulSoup(html_data, 'html.parser') headlines = soup.find_all('h2', {'class': 'e1voiwgp0'}) for headline in headlines[:5]: print(head...
null
Examine a given Python program and modify it to only print out characters which are palindromes.
my_string = "I like mangoes"
my_string = "I like mangoes" for char in my_string: if char == char[::-1]: print(char)
null
Edit the following code to remove the bugs.
def reverse_string(user_string): if len(user_string) == 0: return "" else: return reverse_string(user_string[1:]) + user_string[0] print(reverse_string(“test”))
def reverse_string(user_string): reversed_string = '' if len(user_string) == 0: return "" else: reversed_string = reverse_string(user_string[1:]) + user_string[0] return reversed_string user_string = 'test' print(reverse_string(user_string))
null
Create a method to find all valid IP addresses that can be formed using a given string.
string = "25525511135"
def find_all_valid_ip_addresses(string): valid_ips = [] for i in range(1,4): for j in range(1,4): for k in range(1,4): if i+j+k == len(string): ip_string = string[:i]+"."+string[i:i+j]+"."+string[i+j:i+j+k]+"."+string[i+j+k:] if is_valid_ip_address(ip_string): valid_ips.append(ip_string) return valid_ips def is_valid_i...
null
Implement a function that takes a list and reverses its order
lst = [1,2,3,4]
def reverse(lst): return lst[::-1] reverse(lst)
null
Create a Python script to remove all punctuation from a string.
String: A text containing punctuation marks.
import string # Define the input string inp_str = "A text containing punctuation marks." # Remove all punctuation out_str = inp_str.translate(str.maketrans('', '', string.punctuation)) print(out_str) # Output: A text containing punctuation marks
[DE Wikipedia] Idrizi Idrizi ist der Familienname folgender Personen: Ammar Idrizi (* 2001), Schweizer Handballspieler Blendi Idrizi (* 1998), kosovarisch-deutscher Fußballspieler Meris Idrizi (* 2003), Schweizer Kickboxer Shpëtim Idrizi (* 1967), albanischer Politiker Valdete Idrizi (* 1973), kosovarische Friedensakt...
null
null
null
null
Update the below Python code to run in multiprocess mode.
import time def add(a, b): return a + b if __name__ == '__main__': start = time.time() result = add(2, 3) end = time.time() print(end-start)
import multiprocessing import time def add(a, b): return a + b if __name__ == '__main__': pool = multiprocessing.Pool() start = time.time() result = pool.apply_async(add, (2, 3)) pool.close() pool.join() end = time.time() print(result.get()) print(end-start)
null
Create a Python algorithm to solve the classic game "Connect 4".
Not applicable
ROW_COUNT = 6 COLUMN_COUNT = 7 def create_board(): board = [[0 for i in range(COLUMN_COUNT)] for j in range(ROW_COUNT)] return board def drop_piece(board, row, col, piece): board[row][col] = piece def is_valid_location(board, col): return board[ROW_COUNT - 1][col] == 0 ## Check for a win def check_win(board)...
null
Compare two strings and return "bigger", "smaller" or "equal" depending on the lexicographical order.
string1 = "zebra" string2 = "zeal"
def compare_strings(string1, string2): i = 0 length = min(len(string1), len(string2)) while i < length: if string1[i] < string2[i]: return 'smaller' elif string1[i] > string2[i]: return 'bigger' i += 1 if len(string1) > len(string2): return 'bigger' else: return 'equal'
null
Create an algorithm to find the median of a given list of numbers.
[2, 5, 7, 4, 3]
def find_median(list_of_numbers): sorted_list = sorted(list_of_numbers) length = len(sorted_list) if length % 2 == 0: median1 = sorted_list[length // 2] median2 = sorted_list[(length // 2) - 1] median = (median1 + median2) / 2 else: median = sorted_list[length // 2] return median
null
Create a class in Java named 'Person' that has the following fields: name, age, and gender.
public class Person { private String name; private int age; private String gender; public Person(String name, int age, String gender) { this.name = name; this.age = age; this.gender = gender; } }
null
Create a basic Python program to list all the odd numbers from 0 to a user-specified number
user_number = 10
def odd_numbers(num): for n in range(num+1): if n % 2 != 0: print(n) odd_numbers(user_number) # Output: 1, 3, 5, 7, 9
null
Find the index of a given item in an array
arr = [1, 4, 6, 8, 9] item = 8
def find_index(arr, item): """ Finds the index of a given item in an array """ for i, num in enumerate(arr): if num == item: return i return -1
null
Write an SQL query to pick distinct elements from a table named 'students'.
SELECT DISTINCT * FROM students;
null
Create a code that take an input of the list of integers, and outputs even numbers from the list.
numbers = [2, 3, 4, 5, 6, 7, 8]
def get_even_numbers(numbers): even_numbers = [] for number in numbers: if number % 2 == 0: even_numbers.append(number) return even_numbers get_even_numbers(numbers)
null
Write code to delete all elements in a given Python list which are NOT integer type.
lst = [1, "a", 2.3, False, 4, "abc"]
for item in lst[:]: if not isinstance(item, int): lst.remove(item)
null
Write a code that computes the sum and difference of two numbers in JavaScript.
var x = 10; var y = 5;
var x = 10; var y = 5; var sum = x + y; var diff = x - y; console.log("The sum of " + x + " and " + y + " is: " + sum); console.log("The difference of " + x + " and " + y + " is: " + diff);
null
Suggest a way to automate a process that extracts the data from a web page.
The process of extracting data from a web page can be automated by using web scraping techniques. Web scraping is a process of extracting data from websites using programming languages such as Python or JavaScript. It involves making web requests to the respective web pages using tools like BeautifulSoup and then parsi...
null
Using the given information, write a function to calculate a 5-digit ISBN number.
Author name: Bob Smith Title of Book: Learn Programming Publisher: Aztec Publishing Year Published: 2020
def calculate_isbn(authorname, title, publisher, yearpublished): authorname_string = authorname.replace(' ', '') title_string = title.replace(' ', '') publisher_string = publisher.replace(' ', '') isbn_total = 0 for letter in authorname_string: isbn_total += ord(letter) for letter in title_string: isbn_total += ord(let...
null
Split a sentence into an array of words using C++.
Sentence: Today is a sunny day.
#include<string> #include<vector> #include<sstream> std::string sentence = "Today is a sunny day."; std::istringstream iss(sentence); std::vector<std::string> words; for(std::string word; iss >> word; ) words.push_back(word); //words[] now contains the sentence split into words
null
Construct a for-loop in Python to repeat a code snipet 10 times.
for i in range(10): print("This code is being repeated 10 times")
null
Create a function to create a simple calculator for addition, subtraction, multiplication and division.
def simple_calculator(action, a, b): if action == "add": return a + b elif action == "subtract": return a - b elif action == "multiply": return a * b elif action == "divide": return a / b else: return 0
null
Write a CSS rule to set the text size of all elements with the class “big-header” to 24px.
.big-header { font-size: 24px; }
null
Recognize the type of error in the given code and provide which line of code is causing the error.
def divide(numerator, denominator): return numerator / denominator number = int(input("Enter a number: ")) result = divide(100, number)
Line 4 is causing a syntax error due to improper indentation.
null
Write a Python program to find the list of words that are longer than given length
word_list = ["Red", "Green", "Blue", "Yellow", "Orange"] length = 5
# Create a list to store the result long_words_list = [] # Iterate the list to find words longer than the given length for word in word_list: if len(word) > length: long_words_list.append(word) # Print the result print(long_words_list)
[CS Wikipedia] Seznam obcí v departementu Horní Savojsko Toto je seznam obcí v departementu Horní Savojsko ve Francii, jichž je celkem 294: Reference Externí odkazy Horní Savojsko
null
null
null
null
Generate a Python program to classify text documents by topic.
text = ["The quick brown fox jumps over the lazy dog.", "This is a sample text used to determine how well the classification model works.", "This text belongs to the Animal topic."]
import sklearn from sklearn.feature_extraction.text import CountVectorizer from sklearn.preprocessing import LabelEncoder from sklearn.naive_bayes import MultinomialNB # Sentences sentences = [] sentences.append("The quick brown fox jumps over the lazy dog.") sentences.append("This is a sample text used to determine ...
null
Count the number of integers in the given 2D array.
[ [1, 2, 3], [4, 5, 6], [7, 8] ]
8
[DE Wikipedia] Kami-kama Kami-kama () ist eine halbkreisförmige Depression an der Prinz-Harald-Küste des ostantarktischen Königin-Maud-Lands. Sie liegt im oberen Abschnitt des Simo-kama im südlichen Teil der Langhovde. Japanische Wissenschaftler kartierten sie anhand von Vermessungen und Luftaufnahmen aus den Jahren z...
null
null
null
null
Create a list in Python that contains the first 10 multiples of 3.
multiples_list = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]
[CS Wikipedia] Robert Bresson Robert Bresson (* 25. září 1901, Bromont-Lamothe, Puy-de-Dôme, Auvergne, Francie - 18. prosince 1999, Paříž, Francie) byl francouzský režisér. Původně byl malíř, který se posléze prosadil ve čtyřicátých letech jako filmový režisér a dalších čtyřicet let zůstal jednou z nejvlivnějších post...
null
null
null
null
How can you convert a number from one base to another?
def convert_base(num, from_base, to_base): if isinstance(num, str): n = int(num, from_base) else: n = int(num) alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" if n < to_base: return alphabet[(n)] else: return convert_base(n // to_base, from_base, to_base) + alphabet[n % to_base]
[DE Wikipedia] NetApp NetApp, Inc., zuvor bekannt als Network Appliance, Inc., ist ein Unternehmen, das im Bereich der Datenspeicherung, des Cloud Computing und des Datenmanagements arbeitet. Es hat seinen Sitz seit 2021 in San José im US-Bundesstaat Kalifornien. Geschichte NetApp wurde 1992 unter dem Namen Network Ap...
null
null
null
null
Given a list of numbers, determine whether they are a perfect square or not.
[1, 2, 3, 4]
[True, False, False, True]
null
Name the Java keyword used to define a class
The Java keyword used to define a class is "class".
null
Create a program in Java that calculates the average of two test scores.
test1 = 85 test2 = 90
public static double average(int test1, int test2){ double avg = (test1+test2)/2; return avg; }
null
Write a Python code to normalize a list of numbers.
list_numbers = [1, 4, 4, 5, 7]
""" Normalize a list of numbers using Python """ def normalize_list(list_numbers): max_val = max(list_numbers) normalized = [n/max_val for n in list_numbers] return normalized if __name__ == '__main__': list_numbers = [1, 4, 4, 5, 7] print(normalize_list(list_numbers))
null
Develop a Python code to replace all occurrences of a specified phrase in a string.
string = "This is a sample string. This has to be replaced." phrase = "This" newString = "That"
string = string.replace(phrase, newString) print(string) # Output: That is a sample string. That has to be replaced.
[CS Wikipedia] Danė Akmena-Danė , nebo také Dangė, je řeka na západě Litvy (Klaipėdský kraj), v Žemaitsku, v okresech Kretinga a Klaipėda. Je dlouhá 62,5 km. Povodí má rozlohu 580,2 km². Pramení u vsi Mažieji Žalimai, protéká okresem Kretinga, městem Kretinga, okresem Klaipėda a v Klaipėdě se vlévá do Kurského zálivu,...
null
null
null
null
Design a stack in Python to hold strings.
class Stack: def __init__(self): self.stack = [] def isEmpty(self): return len(self.stack) == 0 def push(self, item): self.stack.append(item) def pop(self): if (self.isEmpty()): return "Stack is empty" return sel...
null
Modify the above program to sort the array in descending order.
[3,8,5,1,2,6,4]
public class SortDescending { public static void main(String[] args) { int[] numbers = {3,8,5,1,2,6,4}; int temp = 0; for (int i = 0; i < numbers.length; i++) { for (int j = i+1; j < numbers.length; j++) { if (numbers[i] < numbers[j]) { //swap elements temp = numbers[i]; // assign value of i to temp numbers[i] = number...
null
Using the given NumPy array, print out all the elements that are greater than 5.
import numpy as np arr = np.array([4, 6, 2, 8, 0, 7, 5])
import numpy as np arr = np.array([4, 6, 2, 8, 0, 7, 5]) print("Elements greater than 5:") for element in arr: if element > 5: print(element)
null
Create a python program to find the largest prime factor of a number.
Number: 331
import math def largest_prime_factor(n): # Separate the list of larger factors of the number into prime and composite numbers factors = [] for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: factors.append(i) factors.append(int(n/i)) # Find the largest prime factor in the...
null
Generate the for loop in Java for iterating from 0 to the given number.
4
for (int i = 0; i < 4; i++) { //code to be executed }
null
Create an algorithm in Python to reverse an array in place.
def reverse_in_place(arr): # Initializing start and end start = 0 end = len(arr) - 1 while start < end: # swapping the elements arr[start], arr[end] = arr[end], arr[start] start += 1 end -= 1 return arr arr = [1, 2, 3, 4, 5, 6] print(reverse_in_place(a...
[EN Wikipedia] 1839 in Denmark Events from the year 1839 in Denmark. Incumbents Monarch – Frederick VI (until 3 December), then Christian VIII Prime minister – Otto Joachim Events Undated Births JanuaryMarch 25 January – Frederikke Federspiel, photographer (died 1913) 6 February – Caroline Testman, women's rights acti...
null
null
null
null
Create a Python program to detect whether a given number is even or odd.
def detect_even_or_odd(num): if num % 2 == 0: print(num, "is Even") else: print(num, "is Odd") if __name__ == "__main__": num = int(input("Enter a number: ")) detect_even_or_odd(num)
null
Can you write a Python program to take a list and create a new list with unique elements of the first list?
list=[1,2,2,3,3,3]
def unique_list(list): unique_list = [] for element in list: if element not in unique_list: unique_list.append(element) return unique_list unique_elements = unique_list([1,2,2,3,3,3]) print(unique_elements)
null
Create a Python function to calculate the Fibonacci sequence with a given number as the input.
6
def fibonacci_sequence(num): a = 0 b = 1 if num < 0: print("Incorrect input") elif num == 0: return a elif num == 1: return b else: for i in range(2,num): c = a + b a = b b = c return b print(fibonacci...
null
Implement a linear search algorithm in C language that takes an array and a value as input and returns the index of the value’s first occurrence in the given array.
Array: [3, 4, 6, 9, 10] value: 9
int linearSearch(int array[], int size, int key) { for (int i = 0; i < size; i++) { if (array[i] == key) return i; } return -1; }