text
stringlengths
141
2.89k
⌀
instruction
stringlengths
19
1.5k
⌀
input
stringlengths
0
800
⌀
output
stringlengths
1
2.5k
⌀
null
Structure an HTML form taking inputs of name, age, and email address.
<form> <label>Name:</label> <input type="text" name="name" /> <label>Age:</label> <input type="number" name="age" /> <label>Email:</label> <input type="email" name="email" /> </form>
null
Design an algorithm in Python that finds all the elements of an array that sum to a given number.
Not applicable
def findElements(arr, sum): result = [] for i in range(0,len(arr)-1): for j in range(i + 1, len(arr)): if arr[i] + arr[j] == sum: result.append([arr[i], arr[j]]) return result arr = [3, 5, 2, -4, 8, 11] sum = 7 print(findElements(arr, sum))
[DE Wikipedia] Wilhelm Peter Jost von Weymarn Wilhelm Peter Jost von Weymarn (; * 14. Januar 1793 in Rösarhof; † 10. Mai 1846 in Sankt Petersburg) war ein russischer Generalleutnant und Mitglied der Nikolaus-Generalstabsakademie in St. Petersburg. Werdegang Nach seiner Schulausbildung trat Wilhelm Jost zur Offiziersau...
null
null
null
[EN Wikipedia] Carità Carità or Carita is a feminine given name which may refer to: Given name Carita Grönholm (born 1991), Finnish group rhythmic gymnast Carita Hansson (born 1991), Swedish female weightlifter Carita Holmström (born 1954), Finnish pianist, singer and songwriter Carita Järvinen (born 1943), known simp...
null
null
null
null
Convert the following function written in Python to Java.
def add_two_numbers(a, b): return a + b
public int add_two_numbers(int a, int b){ return a + b; }
[HI Wikipedia] व्यंजन व्याकरण शास्त्र में प्रयोग होने वाले वर्ण जो स्वर की सहायता से बोले जाते हैं। भोज्य पदार्थ एवं पकवानों के अर्थ में भी इसका प्रयोग होता है।
null
null
null
[HI Wikipedia] डेनमार्क डेनमार्क या डेनमार्क राजशाही (डैनिश: Danmark या Kongeriget Danmark) स्कैंडिनेविया, उत्तरी यूरोप में स्थित एक देश है। इसकी भूसीमा केवल जर्मनी से मिलती है, जबकी उत्तरी सागर और बाल्टिक सागर इसे स्वीडन से अलग करते हैं। यह देश जूटलैंड प्रायद्वीप पर हज़ारों द्वीपों में फैला हुआ है। डेनमार्क ने लंबे स...
null
null
null
null
Write an SQL query to get all employee salaries whose salaries are more than 50000.
SELECT salary FROM employees WHERE salary > 50000;
null
Input a sentence with repeated words and write a Python code to remove all the repeated words.
sentence = 'The the cat cat sat sat on on the the mat'
def remove_repeated_words(sentence): words = sentence.split(" ") result = [] for word in words: if word not in result: result.append(word) return " ".join(result) print(remove_repeated_words(sentence)) # Output: The cat sat on the mat
[CS Wikipedia] Pilot Pen Tennis 2008 – muži Tenisový turnaj na okruhu ATP Pilot Pen Tennis 2008 se konal ve dnech 15. – 23. srpna v americkém New Havenu venku na kurtech s tvrdým povrchem. Odměny činily 708,000 USD. Dvouhra Nasazení hráčů V závorce je kolo, ve kterém hráč vypadl. Všichni nasazení hráči měli v 1. kole ...
null
null
null
null
Create a SQL query to calculate the count of each type of book in a library.
Noinput
SELECT books.type, COUNT(*) AS book_count FROM books GROUP BY books.type;
null
Parse the following string to get the server name.
url = "https://my.example.com/api/user"
server_name = url.split("/")[2]
null
Provide a syntax for an if-else statement in Javascript.
if (condition) { // statements when condition is true } else { // statements when condition is false }
null
Write a Python program that can accept an array and returns the column-wise sum of the given array.
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
def col_sum(arr): col_sum_arr = [] for j in range(len(arr[0])): s = 0 for i in range(len(arr)): s += arr[i][j] col_sum_arr.append(s) return col_sum_arr print(col_sum([[1, 2, 3], [4, 5, 6], [7, 8, 9]])) # Output: [12, 15, 18]
null
Generate a for loop for summing up the first 5 positive even numbers.
int sum = 0; for (int i = 2; i < 10; i += 2) { sum += i; } Console.WriteLine("The sum of the first 5 positive even numbers is: " + sum);
null
Parse this list of JSON objects to get the first name of the second employee.
[ { "firstName": "John", "lastName": "Doe", "age": 28 }, { "firstName": "Alice", "lastName": "Smith", "age": 33 }, { "firstName": "Dave", "lastName": "Moore", "age": 42 } ]
const employeeList = [ { "firstName": "John", "lastName": "Doe", "age": 28 }, { "firstName": "Alice", "lastName": "Smith", "age": 33 }, { "firstName": "Dave", "lastName": "Moore", "age": 42 } ]; const secondEmployeeFirstName = employeeList[1].firstName; // Alice
null
Write a Python script that takes in a string and prints out the frequency distribution of the letters in the string.
apple
def frequency_distribution(string): # create a dictionary of frequencies freq_dict = {} for i in string: if i in freq_dict: freq_dict[i] += 1 else: freq_dict[i] = 1 # print the result for key, value in freq_dict.items(): print (key + ': ' + str(value))
[DE Wikipedia] Fußball-Verbandsliga Mittelrhein 1979/80 Die Fußball-Verbandsliga Mittelrhein 1979/80 war die 34. Spielzeit der höchsten Spielklasse im Fußball-Verband Mittelrhein. Sie war eine Ligenebene unterhalb der Oberliga Nordrhein angesiedelt und wurde in einer Staffel ausgetragen. Im Vergleich zur Vorsaison war...
null
null
null
null
Create a program in Python to classify each item in a given list as either an even number or an odd number.
[5,4,2,7]
def classify(lst): result = [] for item in list: if item % 2 == 0: result.append("even") else: result.append("odd") return result
null
write a piece of code to print out the first n Fibonacci numbers in Python.
n = 8
def Fibonacci(n): fibList = [0, 1] if n <= 0: print("Incorrect input") elif n == 1: print(fibList[0]) elif n == 2: print(fibList) else: temp = fibList[0] + fibList[1] while len(fibList) < n: fibList.append(temp) temp = fibList[len(fibList)-1] + fibList[len(fibList)-2] return fibList print(Fibonacci(8))
null
Create a Python function that takes a list containing fruit names and returns the most common fruit name.
['Apple', 'Orange', 'Apple', 'Pineapple', 'Grape', 'Apple']
def most_common_fruit(fruit_list): # Dictionary to get count of each fruit freq_dict = {} # Count frequency of each fruit for fruit in fruit_list: if fruit in freq_dict: freq_dict[fruit] += 1 else: freq_dict[fruit] = 1 # Get maximum frequency max_fr...
[HI Wikipedia] नेपाल का साहित्य नेपाल का साहित्य नेपाल का विभिन्न भाषाऔं में लिखा हुआ साहित्य है। इन साहित्यौं में संस्कृत, पाळि, नेपालभाषा, मैथिली, नेपाली, भोजपुरी, तिब्बती आदि भाषायें प्रमुख है। नेपालभाषा ही एक ऐसी भाषा है जिसका प्रयोजन् नेपाल के साहित्य के सभी युगों में हुआ है। प्राचीन साहित्य प्राचीन काल से नेपाल ...
null
null
null
null
Given a list of dictionaries, write a python program to find the item with the highest value for the key 'price'.
[ {'name': 'apple', 'price': 3}, {'name': 'orange', 'price': 2}, {'name': 'banana', 'price': 6}, {'name': 'kiwi', 'price': 4} ]
maxVal = 0 maxItem = {} for item in items: if item['price'] > maxVal: maxVal = item['price'] maxItem = item print("The item with the highest price is: ", maxItem)
null
Create a Python program to compare two given list variables and create a third list variable containing all the common elements between the two lists.
list1 = [2, 3, 4, 5, 6] list2 = [5, 6, 7, 8, 9]
list1 = [2, 3, 4, 5, 6] list2 = [5, 6, 7, 8, 9] common_elements = [] for ele in list1: if ele in list2: common_elements.append(ele) print(common_elements)
null
Modify the code below to pull data from the API endpoint provided.
Endpoint: https://jsonplaceholder.typicode.com/posts
import requests url = 'https://jsonplaceholder.typicode.com/posts' response = requests.get(url) data = response.json() for post in data: title = post['title'] body = post['body'] print('Title: ', title) print('Body: ', body)
[EN Wikipedia] Dodole Dodole is an album by the Serbian noise-rock band Klopka Za Pionira, released in 2009 (see 2009 in music) on the Ne-ton independent label. This album is considered by many to be their most accessible to date. It took the band nearly two years to record and publish it, while they usually released ...
null
null
null
null
Write a SQL command to count the number of rows from a table ‘Orders’.
SELECT COUNT(*) FROM Orders;
null
Train a machine learning model in Python using the scikit-learn library to predict animal classification.
Not applicable
# import libraries from sklearn import datasets from sklearn.ensemble import RandomForestClassifier # load the dataset dataset = datasets.load_iris() # create the model model = RandomForestClassifier() # train the model model.fit(dataset.data, dataset.target) # make predictions predictions = model.predict(dataset.d...
null
Create a function to calculate the volume of the given 3D shape.
type: "cube" side: 6
def calculate_volume(shape, side): if shape == "cube": return side ** 3
null
Create a class in Python to find the top 5 most frequent words in a given sentence.
Sentence: The the quick brown fox jumped over the lazy dog
class FindMostFrequentWords: def __init__(self, sentence): self.sentence = sentence def find_most_frequent_words(self): # Split the sentence into words words = self.sentence.split() # Create a list of words and their frequencies frequency_list = [[word, wor...
null
Write a Python program to search a list of strings for a given string.
list = ["dog", "cat", "bird"] target = "bird"
list = ["dog", "cat", "bird"] target = "bird" for element in list: if element == target: print("Target string found: {}".format(target)) break
null
Edit the following HTML list by adding another item, number 4.
<ul> <li>item 1</li> <li>item 2</li> <li>item 3</li> </ul>
<ul> <li>item 1</li> <li>item 2</li> <li>item 3</li> <li>item 4</li> </ul>
[CS Wikipedia] Doo-wop Doo-wop je vokální žánr, založený na rhythm and blues hudbě, která se vyvinula v afroamerických komunitách ve čtyřicátých letech 20. století a byl populární během padesátých a šedesátých let minulého století. Tento žánr se vyvinul na ulicích velkých měst jako New York, Philadelphia, Chicago, Bal...
null
null
null
[CS Wikipedia] Rebecca Fergusonová Rebecca Fergusonová (nepřechýleně Ferguson, * 19. října 1983 Stockholm) je švédská herečka. Do povědomí se dostala rolí Alžběty Woodvillové v seriálu Bílá královna, za kterou získala nominaci na Zlatý glóbus v kategorii nejlepší herečka v minisérii nebo televizním filmu. Mezinárodní ...
null
null
null
null
Create a neural network architecture in Python for predicting the values of a time series dataset.
model = Sequential() model.add(LSTM(50, activation='relu', input_shape=(n_timesteps, n_features))) model.add(Dense(100, activation='relu')) model.add(Dropout(0.5)) model.add(Dense(n_outputs)) model.add(Activation('linear')) model.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy']) # fit netw...
[DE Wikipedia] Ferdinand Kirnberger Ferdinand Kirnberger (* 12. Januar 1875 in Mainz; † 25. Juni 1962 in Darmstadt) war ein hessischer Politiker (Zentrum) und Minister des Volksstaates Hessen. Ausbildung und Beruf Ferdinand Kirnberger war der Sohn des Mediziners Josef Theodor und Caroline Kirnberger. Er studierte nach...
null
null
null
null
Design a class in Java that creates an Employee record.
public class Employee { private String name; private int age; private String position; public Employee(String name, int age, String position) { this.name = name; this.age = age; this.position = position; } public String getName() { return name; } public int getAge() { return age; } public String getPosition() { return ...
[EN Wikipedia] Mary Louise Northway Mary Louise Northway ( – ) was a Canadian psychologist, recognized for her work in the area of sociometry (the measurement of social relationships). She was a faculty member at the University of Toronto. Biography Northway was born in Toronto on May 28, 1909; she was the only child ...
null
null
null
[DE Wikipedia] Evangelisch-Lutherische Kirche Probsthagen Die evangelisch-lutherische Kirche Probsthagen ist die Gemeindekirche von Probsthagen, einem Ortsteil der Stadt Stadthagen im niedersächsischen Landkreis Schaumburg. Sie gehört der Evangelisch-Lutherischen Landeskirche Schaumburg-Lippe an. Geschichte Die Pfarrk...
null
null
null
[HI Wikipedia] भौतिक विज्ञान में अनसुलझी पहेलियों की सूची भौतिक विज्ञान में कुछ अनसुलझी पहेलियाँ सैद्धांतिक हैं, कहने का मतलब यह है कि उपलब्द्ध सिद्धांत कुछ प्रायोगिक परिणामों अथवा कुछ प्रेक्षित परिघटनाओं को समझाने में सक्षम नहीं हैं। अन्य प्रायोगिक हैं, जिसका मतलब यह है कि किसी परघटना को विस्तार से समझने अथवा किसी प्...
null
null
null
null
Design a function in Python for filtering out unique elements in a list.
list = [1, 2, 2, 3, 3, 4]
def filter_list(list): filtered_list = [] for i in list: if i not in filtered_list: filtered_list.append(i) return filtered_list
null
What are the different ways to loop through a list in Python?
The different ways of looping through a list in Python are the for loop, the while loop, the list comprehension, and the map() function.
null
Design a web page with a top navigation bar and 2 different color sidebars.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My Web Page</title> <style> body { margin: 0; padding: 0; } .top-nav { position: fixed; background-color: #222; left: 0; top: 0; width: 100%; text-align: center; } .sidebar-left {...
null
Construct a valid and optimized MySQL query to get the user details of all users who are younger than 24 and have subscribed more than 10 times.
SELECT user_id, username, age, subscriptions FROM users WHERE age < 24 AND subscriptions >= 10
[CS Wikipedia] Farní sbor Českobratrské církve evangelické v Praze 3 – Žižkov II Farní sbor Českobratrské církve evangelické v Praze 3 - Žižkov II je sborem Českobratrské církve evangelické v Praze. Sbor spadá pod Pražský seniorát. Duchovním sboru je farářka Olga Mrázková, kurátorkou sboru Eva Potměšilová. Sbor byl za...
null
null
null
null
Use regex to find the number of digits in a given string.
String: "743ABC123_$*"
import re def get_digits_count(string): return len(re.findall('\d', string))
null
Sort the users in alphabetical order by their name.
users = [{'name': 'John', 'age': 25}, {'name': 'Alice', 'age': 28}, {'name': 'Bob', 'age': 39}]
sorted_users = sorted(users, key=lambda user: user['name'])
[EN Wikipedia] Bhungane II Bhungane II , Bhungan'omakhulukhulu (birth name Mlotsha) was the king of AmaHlubi tribe from 1760 until his death in 1800. He was the father of King Mthimkhulu II (Ngwadlazibomvu). He was also the grandfather to the famous King Langalibalele I. King Bhungane II was a gifted medicine-man (her...
null
null
null
null
Create a python program to remove characters from a string that's not a letter or symbol.
string = "ABC%@#XYZ"
string = "ABC%@#XYZ" new_string = ''.join(c for c in string if c.isalnum()) print(new_string) # output: ABCXYZ
null
Generate Python code to print the smallest number in a given list of numbers.
[24, 14, 67, 89, 34, 52]
list_of_numbers = [24, 14, 67, 89, 34, 52] print(min(list_of_numbers))
null
Find the index of the first occurrence of the word 'data' in the text 'The data here is important'.
The index of the first occurrence of 'data' is 4.
null
Develop a Python Program to determine if two given strings are an anagram or not.
string1 = "abcd" string2 = "cbad"
def is_anagram(string1, string2): # check if strings have equal length if len(string1) != len(string2): return False sorted1 = sorted(string1); sorted2 = sorted(string2); # check if sorted strings are the same if sorted1 == sorted2: return True return False
null
Generate an algorithm in Python that finds the number of times an element is present in an array.
arr = [4, 5, 2, 4, 2] x = 2
def countOccurrences(arr, x): count = 0 for i in range(len(arr)): if (x == arr[i]): count = count + 1 return count arr = [4, 5, 2, 4, 2] x = 2 print(countOccurrences(arr, x))
[DE Wikipedia] Niederbayerische Teilung von 1331 Die Niederbayerische Teilung von 1331 war die Aufteilung des wittelsbachischen Teilherzogtums Niederbayern unter den Enkeln Herzog Heinrichs XIII. Sie ist eine der zahlreichen Landesteilungen im Herzogtum Bayern bis zum Primogeniturgesetz von 1506. Sie endete im Jahr 13...
null
null
null
null
Write a code to convert all the letters of a string to lowercase.
Input string: "HELLO WORLD"
def lowercase_string(input_str): output_str = "" for char in input_str: output_str += char.lower() return output_str if __name__ == '__main__': print(lowercase_string("HELLO WORLD"))
null
Translate the following Ruby code to Javascript
def print_hello puts "Hello!" end print_hello
function printHello() { console.log("Hello!"); } printHello();
null
Create a Machine Learning model in Python to predict the values of a function given a set of test inputpoints.
input_values = [(-5.2, 2.3), (3.1, 4.9), (2.4, 0.3), (-2.4, -3.2)]
import numpy as np import matplotlib.pyplot as plt # List of input points input_values = [(-5.2, 2.3), (3.1, 4.9), (2.4, 0.3), (-2.4, -3.2)] # Create x and y matrix from input x = [v[0] for v in input_values] y = [v[1] for v in input_values] # Create the training data array X = np.array(x).reshape(-1, 1) Y = np.arra...
[DE Wikipedia] Tusch Der Tusch (von , „Anschlag“) ist ein musikalisches Signal, das meist chorisch von mehreren Instrumenten gespielt wird, ursprünglich von einem Trompeten-Ensemble. Das Wort ist seit 1745 im süddeutschen Sprachgebiet belegt. Der Tusch zeigt zum Beispiel das Ende eines gelungenen Tricks im Zirkus oder...
null
null
null
null
Develop a high-level algorithm for pathfinding.
def find_path(start, end): # Create an empty list to store the path path = [] # Create a dictionary to store visited nodes visited = {start: None} # Create a queue and add the initial space to it queue = [start] # Keep looping until the queue is empty while len(queue) > 0: # Get the first element in the queue curr = qu...
[CS Wikipedia] Culture Club Culture Club je britská populární novoromantická kapela, která v osmdesátých letech skórovala s hity jako "Time (Clock of the Heart)", "I'll Tumble 4 Ya", včetně velice známého hitu "Do You Really Want to Hurt Me". Mezi členy Culture Clubu patří Boy George (vokály), Mikey Craig (baskytara),...
null
null
null
null
Create a Python program to remove punctuations from the given sentence
He loves to eat Italian; pizza, pasta, and gelato
import string def remove_punctuations(sentence): translator = str.maketrans('', '', string.punctuation) return sentence.translate(translator) print(remove_punctuations("He loves to eat Italian; pizza, pasta, and gelato"))
null
Write SQL code to count the number of unique customers from the orders table.
Table Name: Orders
SELECT COUNT(DISTINCT customer_id) FROM Orders;
null
You are passed an array and a value. Write a Python program to insert the value in the array at the end.
array = [1, 2, 3, 4], value = 7
array = [1, 2, 3, 4, 7]
[DE Wikipedia] Basil da Cunha Basil da Cunha (* 1985 in Morges) ist ein schweizerisch-portugiesischer Filmregisseur und Drehbuchautor. Biografie Basil da Cunha wuchs als Sohn einer Schweizerin und eines Portugiesen in Lausanne auf. Schon als Kind entdeckte Basil da Cunha sein Interesse am Filmemachen: als er 10 Jahre ...
null
null
null
null
Generate a for loop in Python to iterate over a range of numbers from 0 to 10.
for i in range(0,11): print(i)
[CS Wikipedia] Světový pohár v běhu na lyžích 1983/1984 Světový pohár v běhu na lyžích 1983/84 byl třetím ročníkem Světového poháru v běhu na lyžích pod záštitou Mezinárodní lyžařské federace (FIS). Muži i ženy odjeli celkem 10 individuálních závodů a 4 štafety. Celkovými vítězi se stali Švéd Gunde Svan a Finka Marja-...
null
null
null
[CS Wikipedia] Adelheid (film) Adelheid je český film režiséra Františka Vláčila, natočený v roce 1969 podle stejnojmenné novely Vladimíra Körnera. Děj se odehrává v Sudetech krátce po skončení druhé světové války. Do vesnice je jako správce znárodněného majetku přidělen bývalý voják ze západní fronty (Petr Čepek), je...
null
null
null
[EN Wikipedia] Campo Alegre Campo Alegre (Portuguese or Spanish: happy field) may refer to: Campo Alegre, a neighbourhood in Caracas, Venezuela. Campo Alegre, Oporto, a parish in Oporto, Portugal. Campo Alegre, Alagoas, a Brazilian municipality in the state of Alagoas Campo Alegre, Puerto Rico, a space for farmers' ma...
null
null
null
null
Create a CLI in Python for sending emails. The CLI should be interactive and should prompt users for the To address, Subject and message body of the emails.
Not Applicable
import smtplib while True: print('========Email Tool========') to_addr = input('To: ') subject = input('Subject: ') body = input('Message: ') print('=========================') confirm = input('Send email?[y/n]: ') if confirm.lower() == 'y': smtpObj = smtplib.SMTP('smtp.gmail.com', 587) smtpObj.starttls() ...
null
Create a Python program for converting Celsius to Fahrenheit.
def celsiusToFahrenheit(celsius): return (9/5)*celsius + 32
null
Construct a while loop that prints integers from 0 to 9.
i = 0 while i < 10: print(i) i+=1
[CS Wikipedia] Plyn Plyn neboli plynná látka je jedno ze skupenství látek, při kterém jsou částice relativně daleko od sebe, pohybují se v celém objemu a nepůsobí na sebe přitažlivou silou. V chemických rovnicích se označuje písmenem g (gas). Kinetická energie částic je mnohem větší než potenciální energie, která odpo...
null
null
null
[CS Wikipedia] SpaceX CRS-14 SpaceX CRS-14 (alternativně SpX-14, nebo jednoduše CRS-14) je čtrnáctá a zároveň druhá ze tří dodatečných zásobovacích misí kosmické lodi Dragon k Mezinárodní vesmírné stanici (ISS) podstoupená v rámci kontraktu Commercial Resupply Services uzavřeného mezi společností SpaceX a NASA. Celkov...
null
null
null
null
Rewrite the following python program using a functional programming approach. The code should take a list of integers as input, filter out the odd numbers, square each even number, and return the sum of all the numbers.
[3, 4, 5, 6, 7, 8, 9, 10]
def fx(nums): return sum(map(lambda x : x*x if x % 2==0 else 0, nums)) print(fx([3, 4, 5, 6, 7, 8, 9, 10])) # Output: 240
null
Create a python dictionary consisting of the names of the seven dwarfs and a list of their ages.
""" Create a python dictionary consisting of the names of the seven dwarfs and a list of their ages """ dwarfs = {"Doc": 84, "Grumpy": 67, "Happy": 76, "Sleepy": 75, "Sneezy": 71, "Dopey": 76, "Bashful": 70} print(dwarfs)
[CS Wikipedia] Průplav Seina – severní Evropa Průplav Seina – severní Evropa, Průplav Seina–Sever nebo také Seina–Šelda je velkokapacitní vodocestný transportní systém, který se nyní realizuje, hlavní práce na stavbě průplavu mají začít v roce 2020. Průplav je projektován z řeky Oise v Janville, severně od Compiègne, ...
null
null
null
[CS Wikipedia] Na vlásku šťastně až navěky Na vlásku šťastně až navěky, (anglicky: Tangled Ever After), je americká krátkometrážní šestiminutová animovaná groteska z roku 2012, která bezprostředně navazuje na celovečerní pohádkový film Na vlásku z roku 2010. Jde o jakýsi humorný dovětek, závěrečná tečka či doplněk pův...
null
null
null
null
Given a list of strings and a letter, write a python program that returns the strings that contain the given letter in upper case.
strings = ['civic', 'legion', 'elite', 'necrop', 'dark soul'] letter = 'e'
def sort_upper(strings, letter): result = [] for string in strings: if letter in string and string.upper() == string: result.append(string) return result strings = ['civic', 'legion', 'elite', 'necrop', 'dark soul'] letter = 'e' print(sort_upper(strings, letter))
null
Write a Java code to find the maximum of two numbers a and b.
int a = 3; int b = 4;
int max; if (a > b) { max = a; } else { max = b; }
null
Generate a css code block to create a white text shadow for a given HTML element
.element { text-shadow: 1px 0 white, 0 1px white, 1px 1px white, -1px 0 white, 0 -1px white, -1px -1px white; }
[HI Wikipedia] शिवशक्ति सचदेव शिवशक्ति सचदेव (जन्म 21 मार्च 1993) एक भारतीय टेलिविजन अभिनेत्री हैं। उन्हें स्टार प्लस के धारावाहिक "सबकी लाडली बेबो" में बेबो नारंग की भूमिका निभाने के लिए जाना जाता है। सन्दर्भ बाहरी कड़ियाँ अभिनेत्री 1993 में जन्मे लोग जीवित लोग
null
null
null
null
Generate a unique ID string in Java.
import java.util.UUID; public class App { public static void main(String[] args) { // generate a unique ID string String uniqueID = UUID.randomUUID().toString(); System.out.println("Unique ID String: " + uniqueID); } }
null
Convert this given number in base 10 to base 2
34
100010
null
Create a look-up table implementation using a Python dictionary.
lookup_table = {"key1":"value1", "key2":"value2", "key3":"value3"}
null
Create a python script to generate the product of all elements in a sequence.
[2,4,6]
def product_of_sequence(sequence): product = 1 for num in sequence: product *= num return product seq = [2,4,6] print(product_of_sequence(seq))
null
Create a function that capitalizes the first letter of any given word
"python"
def capitalize_first_letter(word): return word[0].upper() + word[1:] # main word = "python" capitalized = capitalize_first_letter(word) print(capitalized)
null
Generate a Python function to reverse the order of each word in a string, leaving the absolute order of each word unchanged.
hello, world.
def reverser(string): reversed_string = [] words = string.split() for word in words: reversed_string.append(word[::-1]) return " ".join(reversed_string)
null
Substitute the correct data type for each variable in the code below.
name = <data_type> age = <data_type> if_married = <data_type>
name = str age = int if_married = bool
null
Write a Java program to sum the elements of an array except for the maximum and minimum.
Array: [1, 2, 3, 4, 5]
class Sum { public static void main(String[] args) { int[] arr = {1,2,3,4,5}; int max = arr[0]; int min = arr[0]; int sum = 0; for (int i = 0; i < arr.length; i++) { sum += arr[i]; if (arr[i] > max) { max = arr[i]; } if (arr[i] < min) { min = arr[i]; } } int res = sum - (max + min); System.out.println(res); } }
null
Create a python program for encrypting and decrypting strings
import random def encrypt(string): """Encrypts a given string using a random 2D matrix""" # Generate random 2D matrix matrix = [[random.randint(0, 9) for x in range(len(string))] for y in range(len(string))] encrypted_str = "" # Encrypt the string for col in range(len(string)): fo...
null
Design a Python program to optimize a cost function.
import numpy as np def optimize(func, n, method="gradient_descent", iter_num=100, step_size=0.01): """ Input: Cost function, dimension of the variable, optimization method, number of iterations, step size Output: Optimal variable """ # define our variable x = np.zeros(n, dtype=float) if me...
null
This code updates a game server cluster in Google Cloud Game Servers. To use it, run the script `update_cluster.py` with the following arguments: `--project-id` (your cloud project ID), `--location` (your realm location), `--realm-id` (your realm ID), and `--cluster-id` (your game server cluster ID). The script will up...
#!/usr/bin/env python # Copyright 2020 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
null
Create a Python program to create a game of Rock, Paper, Scissors. The program should have functions to set the user's choice, randomly generate the computer's choice, and compare the user's choice to the computer's choice to decide the winner.
Not applicable
import random def set_choice(user_choice): return user_choice def generate_computer_choice(): computer_choice = random.choice(['Rock', 'Paper', 'Scissor']) return computer_choice def compare_choices(user_choice, computer_choice): if user_choice == computer_choice: print('It is a tie!') el...
null
Create a memory game in Python.
import random # Create the list of possible values cards = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"] * 4 # Shuffle the cards random.shuffle(cards) # Create a variable to store the user's score user_score = 0 # Initialize the game # The user is shown a card, and asked if they remember what i...
[HI Wikipedia] डफरिन-पील कैथोलिक डिस्ट्रिक्ट स्कूल बोर्ड डफरिन-पील कैथोलिक स्कूल बोर्ड (Dufferin-Peel Catholic District School Board, DPCDSB) ओंटारियो, कनाडा के सब से बड़े स्कूली बोर्डों में से एक है। यह पूरे पील क्षेत्र (मिसिसॉगा, बरैंपटन, कैलीडोन) और डफरिन काउंटी (आरंजविल समेत) में 148 स्कूली सहूलतें (122 प्राथमिक स...
null
null
null
null
Create a function in JavaScript to sum two numbers.
function addNumbers(a, b) { return a + b; }
null
Display a Classification banner for an Xwindows session by running the Python script "classification-banner.py". The banner displays the classification level and can be customized with various options such as foreground and background colors, font face and size, and opacity. The banner can also show the user and hostna...
#!/usr/bin/python # Classification Banner # # Last update was 02 July 2018 # # Script: classification-banner.py # Description: Displays a Classification for an Xwindows session # Copyright: Frank Caviggia, 2017 # Author: Frank Caviggia <fcaviggia (at) gmail.com> # Version: 1.6.6 # License: GPLv2 import sys,os,optparse...
[EN Wikipedia] Postal River The Postal River is a river of the West Coast Region of New Zealand's South Island. It flows west from the Fenian Range, reaching the Oparara River five kilometres northeast of Karamea. The Postal River's entire length is within Kahurangi National Park. See also List of rivers of New Zealan...
null
null
null
null
Make changes to this code to fix the bug.
def example_function(a, b): c = 0 for i in range(a, b+1): c -= i return c
def example_function(a, b): c = 0 for i in range(a, b+1): c += i return c
null
Generate a Python program that can verify if a given sentence is correct or misspelled.
The sentence: "This is my new computer"
import re def spell_check(sentence): words = re.findall(r'\w+', sentence) for word in words: if not word.lower() in dict: return False return True sentence = "This is my new computer" result = spell_check(sentence) if result: print('Correct spelling') else: print('Incorrect spelling')