text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
null | Write a procedure in PL/SQL to count the number of employees in a company. | CREATE OR REPLACE PROCEDURE count_employees AS BEGIN SELECT COUNT(*) FROM Employees; END; | |
null | Create a function in Python to return the length of the longest word in a list of words. | words = ["cat", "longestword", "dog", "night"] | def findLongestWordLength(words):
longest_length = 0
for word in words:
if len(word) > longest_length:
longest_length = len(word)
return longest_length
longest_word_length = findLongestWordLength(["cat", "longestword", "dog", "night"])
print(longest_word_length) |
[EN Wikipedia] Seaforth River
The Seaforth River is a river in New Zealand, flowing into Dusky Sound. About and up from Supper Cove in Dusky Sound is Lake Maree. The river rises about another to the north, on the slopes of the Black Giants, at about . Like many former British Empire locations, it and its lakes have Sc... | null | null | null |
[HI Wikipedia] सचिन तेंदुलकर
सचिन रमेश तेंडुलकर Sachin Tendulkar, जन्म: 24 अप्रैल 1973) क्रिकेट के इतिहास में विश्व के सर्वश्रेष्ठ बल्लेबाज़ में माने जाते हैं। भारत के सर्वोच्च नागरिक सम्मान भारत रत्न से सम्मानित होने वाले वह सर्वप्रथम खिलाड़ी और सबसे कम उम्र के व्यक्ति हैं। राजीव गांधी खेल रत्न पुरस्कार से सम्मानित ह... | null | null | null |
null | Output the current date in YYYYMMDD format. | let today= new Date(); let dd = String(today.getDate()).padStart(2, '0'); let mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0! let yyyy = today.getFullYear(); console.log(yyyy+mm+dd); | |
[EN Wikipedia] Ronga River
The Ronga River is a river of the Marlborough Region of New Zealand's South Island. Although its source is on a ridge only from the island's north coast, the river flows south, reaching the Rai River close to the township of Rai Valley. References Rivers of the Marlborough Region Rivers of N... | null | null | null |
null | Program a function to remove all the even numbers from an array | def remove_even(arr): new_arr = [] for num in arr: if num % 2 != 0: new_arr.append(num) return new_arr | |
null | Given a Python list of integers, write a function to find the sum of the elements in the list. | nums = [1, 2, 3, 4, 5] | def findSum(nums):
total = 0
for num in nums:
total += num
return total |
null | Create an array of strings from an array of integers. | [1, 4, 8] | ["1", "4", "8"] |
null | Given a list of words and a target word, determine if the target word is in the list | list_words = ["apple", "banana", "orange", "mango"] target_word = "pineapple" | list_words = ["apple", "banana", "orange", "mango"] target_word = "pineapple" if target_word in list_words: print ("Target word is in the list") else: print ("Target word is not in the list") |
null | Create a Python program that displays the elements of an array in reverse order. | def reverse_array(arr):
"""Prints the elements of an array in reverse order"""
length = len(arr)
for i in reversed(range(length)):
print(arr[i], end=" ") | |
null | Write a JavaScript program to find the most commonly occurring item in a given object. | function mostCommonlyOccuring(obj) { let count = {}; let maxCount = 0; let mostCommon = null; for (const key in obj) { if (obj.hasOwnProperty(key)) { if (obj[key] in count) { count[obj[key]]++; } else { count[obj[key]] = 1; } if (count[obj[key]] > maxCount) { maxCount = count[obj[key]]; mostCommon = obj[key]; } } } ret... | |
null | Build a web scraping tool using Python that extracts data from a given web page. | import requests
from bs4 import BeautifulSoup
# Function to make a GET request to a given URL
def get_page_data(url):
# Make a GET request
response = requests.get(url)
# Parse the HTML from the GET request
soup = BeautifulSoup(response.text, 'html.parser')
# Extract the desired data
data = so... | |
null | Develop a Python program for classifying data into two categories - positive and negative. | Not applicable | import pandas as pd
# Read the data
data = pd.read_csv('data.csv')
# Create input features
X = data[['feature1','feature2','feature3']]
# Create output label
y = data['label']
# Split data into training and testing sets
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = tra... |
[DE Wikipedia] In all meinen Träumen bist Du
In all meinen Träumen bist Du ist eine US-amerikanische Filmbiografie aus dem Jahr 1951 von Michael Curtiz über den Musiker Gus Kahn (1886–1941), der von Danny Thomas dargestellt wurde. In weiteren Rollen spielten Doris Day und Frank Lovejoy. Der Film wurde von Warner Bros.... | null | null | null |
null | Provide an algorithm in Python to merge two sorted arrays into a single sorted array. | [3, 8, 11] and [1, 4, 9] | def merge_arrays(arr1, arr2):
merged_arr = []
# Make copies of arrays
arr1_copy = arr1[:]
arr2_copy = arr2[:]
# add elements from both array in sorted order
while arr1_copy and arr2_copy:
if arr1_copy[0] <= arr2_copy[0]:
merged_arr.append(arr1_copy.pop(0))
else:
... |
null | Write a Python program to generate a combination of random characters. | import random
characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
length = 8
randstring = ''.join(random.choice(characters) for i in range(length)) | |
null | Create a HTML table to present student information. | <table> <tr> <td>Name</td><td>Age</td><td>Gender</td><td>Address</td> </tr> <tr> <td>John Doe</td><td>24</td><td>Male</td><td>123 Main Street</td> </tr> </table> | |
null | Create a python program to find the length of the longest run of 1s in the binary form of a positive integer. | def longest_run_of_ones(n):
max = 0
count = 0
while n > 0:
if n % 2 == 1:
count += 1
else:
if count > max:
max = count
count = 0
n //= 2
if count > max:
max = count
return max | |
null | Construct a Python program to convert degrees Celsius to Fahrenheit. | C = 32 | #Program to convert Celsius to Fahrenheit
#user input
C = 32
#Celsius to Fahrenheit conversion
F = (C*9/5)+32
#print the result
print('%0.2f degree Celsius is equal to %0.2f degree Fahrenheit' %(C, F)) |
null | Using the HTML provided, add an ID attribute to the div tag to specify the unique identifier "box1" | <div>Hello World!</div> | <div id="box1">Hello World!</div> |
[CS Wikipedia] Miláček (film, 2012)
Miláček (v originále Bel Ami) je historické drama, další z řady filmových adaptací stejnojmenného klasického románu francouzského autora Guy de Maupassanta z roku 1885. Natočen byl v britské, francouzské a italské koprodukci podle scénáře Rachel Bennette. Film režírovali Declan Donn... | null | null | null |
null | Write a SQL statement to select the names of employees beginning with 'A'. | SELECT name FROM employees WHERE name LIKE 'A%'; | |
[HI Wikipedia] मिर्ज़ापुर
मिर्ज़ापुर (Mirzapur) भारत के उत्तर प्रदेश राज्य के मिर्ज़ापुर ज़िले में स्थित एक नगर है। यह ज़िले का मुख्यालय भी है। विवरण पर्यटन की दृष्टि से मिर्ज़ापुर उत्तर प्रदेश का काफी महत्वपूर्ण जिला माना जाता है। यहां की प्राकृतिक सुंदरता और धार्मिक वातावरण बरबस लोगों का ध्यान अपनी ओर खींचती है। मिर... | null | null | null |
null | Change the comment to a print statement in the code. | x = 1 # print the value of x | x = 1 print(x) |
null | Edit the following code so that the item at index 4 is multiplied by two. | arr = [1, 2, 3, 4, 5, 6] | arr = [1, 2, 3, 4, 10, 6] |
[EN Wikipedia] Rhabdochaeta queenslandica
Rhabdochaeta queenslandica is a species of tephritid or fruit flies in the genus Rhabdochaeta of the family Tephritidae. Distribution Australia. References Tephritinae Insects described in 1996 Diptera of Australasia | null | null | null |
null | Convert the following enum type expression in Java for days of the week to equivalent C# syntax. | enum Weekday {SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY}; | enum Weekday { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; |
null | Create an algorithm in Python to optimize the order of parallel computations so that the total time required to finish all computations is minimized. | operations = { A: 10, B: 5, C: 15, D: 20 } | # Compute the optimal order
def compute_optimal_order(operations):
# Create a list to store the order.
order = []
# Sort the operations in ascending order by time.
sorted_operations = sorted(operations.items(), key=lambda x: x[1])
# Total time for the operations in the order.
total_time = 0
... |
null | Create a Django web application that allows users to view, add, and edit blog posts. | # create our Django project
django-admin startproject blogapp
# create our app
cd blogapp
python manage.py startapp posts
# create a model for our blog posts
# in posts/models.py:
from django.db import models
class Post(models.Model):
title = models.CharField(max_length=255)
content = models.TextField()
... | |
[EN Wikipedia] 1811 in Denmark
Events from the year 1811 in Denmark. Incumbents Monarch – Frederick VI Prime minister – Frederik Moltke Events 3 March Sparekassen Bikuben is founded in Copenhagen. 27 March – The Battle of Anholt during the Gunboat War. 30 June Hassel & Teudt is founded in Copenhagen. Undated Christian... | null | null | null |
null | Create a JavaScript function named 'calculateAge' that determines a person's age based on the birth year given. | function calculateAge(birthYear) { let age = 2019 - birthYear; return age; } | |
null | Suggest improvements to the code fragment given below. | x = 25 if x < 20 print("x is less than 20") | if x < 20: print("x is less than 20") |
[EN Wikipedia] 1834 in Denmark
Events from the year 1834 in Denmark. Incumbents Monarch – Frederick VI Prime minister – Otto Joachim Events 29 November P. Hertz is founded by Peter Hertz in Copenhagen. Undated Fædrelandet is established as a weekly journal by and Johannes Dam Hage. Henning Smith's Iron Foundry is esta... | null | null | null |
null | Write a Python code using list comprehension to get the power of each element in a list. | list_num = [1, 2, 3, 4, 5] | power_list = [num**2 for num in list_num] print(power_list) # prints [1, 4, 9, 16, 25] |
null | What is the minimum number of arguments needed to call the function "foo". | The minimum number of arguments needed to call the function "foo" is 0. | |
[EN Wikipedia] Linguistic Systems
Linguistic Systems, Inc., also known as LSI, provides language translation services (conversion) for all media in over 115 languages. LSI focuses on the translation of legal, medical, business, institutional, academic, government and personal documents. LSI is headquartered in Cambrid... | null | null | null |
[HI Wikipedia] जिब्राल्टर में क्रिकेट
जिब्राल्टर औबेरियन प्रायद्वीप और यूरोप के दक्षिणी छोर पर भूमध्य सागर के प्रवेश द्वार पर स्थित एक स्वशासी ब्रिटिश विदेशी क्षेत्र है। 6.843 वर्ग किलोमीटर (2.642 वर्ग मील) में फैले इस देश की सीमा उत्तर में स्पेन से मिलती है। जिब्राल्टर ऐतिहासिक रूप से ब्रिटेन के सशस्त्र बलों के लिए ए... | null | null | null |
null | Write an SQL query to select the productname and the total price of orders with more than 10 items | SELECT productname, SUM(price) AS total_price FROM Orders JOIN OrderItems USING (orderId) JOIN Products USING (productId) WHERE quantity > 10 GROUP BY orderId | |
null | Reverse the order of the values in the input list using Python. | list = [1, 4, 5, 6, 7] | list = [7, 6, 5, 4, 1] def reverse_list(input_list): """Reverse the order of the values in the input list.""" return input_list[::-1] if __name__ == '__main__': list = [1, 4, 5, 6, 7] print(reverse_list(list)) |
null | What is the best data structure to store a dictionary? | The best data structure to store a dictionary is a hash table. A hash table is an efficient data structure that uses key-value pairs to store data. It provides fast insertion, deletion and search operations, allowing it to be used to search for a specific key in a dictionary quickly and easily. | |
null | Create a loop in Python that prints out a list of numbers from 1 to 10 multiplied by 3. | for i in range(1, 11):
print(i * 3) | |
null | Design a Django web application to store user profiles. | # models.py from django.db import models class Profile(models.Model): user = models.OneToOneField("auth.User", on_delete=models.CASCADE) first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) birth_date = models.DateField() # views.py from django.shortcuts import render from .models ... | |
[EN Wikipedia] Linford Wood
Linford Wood is a Local Nature Reserve in East Tilbury in Essex. It is owned and managed by Thurrock Council. The site has mixed woodland, a willow plantation, hedges, ditches and an open area. Birds include tawny owls, great spotted woodpeckers and green woodpeckers. It is part of the prop... | null | null | null |
null | Refactor this function to be less complex and more readable. | def calculate_price(products): total_price=0 for p in products: total_price+=p[0]*p[1] return total_price | def calculate_price(products): total_price = 0 for price, quantity in products: total_price += price * quantity return total_price |
null | In C#, write a loop to sum up a given array of numbers. | int[] numbers = {1, 2, 3, 4, 5}; | int sum = 0; for(int i = 0; i < numbers.length; i++) { sum += numbers[i]; } |
null | Create a Python program to filter out all negative numbers from a list. | def filter_negative(data):
"""Filters out all negative numbers from a list"""
return [x for x in data if x >= 0] | |
null | Print out the average of all elements within a given array. | arr = [3, 7, 4, 8, 9] | arr = [3, 7, 4, 8, 9] sum = 0 for num in arr: sum += num average = sum / len(arr) print(average) # prints 6.4 |
[HI Wikipedia] रेमिका थापा
रेमिका थापा नेपाली भाषा की भारतीय कवियित्रि है। इनका जन्म 28 अक्तूवर 1971 को मांग्पू दार्जिलिंग में हुआ। सन्दर्भ नेपाली साहित्यकार 1971 में जन्मे लोग जीवित लोग | null | null | null |
[CS Wikipedia] Viktor Spasov
Viktor Spasov ( * 19. července 1959) je bývalý ukrajinský atlet, halový mistr Evropy ve skoku o tyči z roku 1982. Kariéra Jeho prvním úspěchem bylo vítězství na mistrovství Evropy juniorů v roce 1977. V roce 1982 se stal halovým mistrem Evropy ve skoku o tyči, zároveň si vytvořil svůj osob... | null | null | null |
null | Create a SQL query to update all rows of the table "product" if their stock is below 10. | UPDATE product SET stock = 10 WHERE stock < 10; | |
[CS Wikipedia] Paz (satelit)
Paz (španělsky „mír“), dříve označován také jako SEOSAR, je španělská vojenská radarová družice, kterou vyrobila francouzská společnost Airbus a provozovatelem je společnost Hidesat. Její pracovní pozice je na heliosynchronní dráze ve výšce 514 km. Paz byl vynesen pomocí nosné rakety Falco... | null | null | null |
null | Create an SQL query that returns the names and phone numbers of customers from the state of Virginia. | SELECT name, phone FROM customers WHERE state= 'Virginia'; | |
null | Create an array of length 10 from a given list of values. | given_list = [1, 2, 3, 4, 5] | final_list = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5] |
null | Convert the given code by replacing for loop with a while loop. | for i in range(5): print(i) | i = 0 while i < 5: print(i) i += 1 |
null | Write a Python program to create a function for adding two numbers. | def add(a, b):
return a + b | |
null | Edit the following HTML code snippet to change the color of the heading to blue. | <h1>Heading</h1> | <h1 style="color: blue;">Heading</h1> |
null | Create a RNN model using Python that can classify a piece of text as either positive or negative sentiment. | # Load the required libraries
import numpy as np
import tensorflow
from tensorflow.keras.preprocessing.text import Tokenizer
from tensorflow.keras.preprocessing.sequence import pad_sequences
from tensorflow.keras.layers import Embedding, LSTM, Dense, Dropout
# Load the training dataset
sentences = ['This is a good sen... | |
[EN Wikipedia] François Boucher (disambiguation)
François Boucher may refer to: François Boucher, French painter Francois Boucher (art historian), French art historian François Boucher (violinist), Canadian violinist | null | null | null |
null | Given a string, what is the best way to reverse the characters in it? | <noinput>> | """ The best way to reverse the characters in a string is by using the slicing option of a string object. The string slicing reverses a string by slicing it from the end of the string and going to the beginning of the string. This can be done with the following syntax: string_name[::-1] For example, to reverse the stri... |
[CS Wikipedia] Farní sbor Českobratrské církve evangelické ve Velkém Meziříčí
Farní sbor Českobratrské církve evangelické ve Velkém Meziříčí je sborem Českobratrské církve evangelické ve Velkém Meziříčí. Sbor spadá pod Horácký seniorát. Farářkou sboru je Markéta Slámová a kurátorkou Dana Konvalinková. Faráři sboru Jos... | null | null | null |
null | Create a data frame from a dictionary. | my_dict = {'state': ['Ohio', 'Ohio', 'Ohio', 'Nevada', 'Nevada'], 'year': [2000, 2001, 2002, 2001, 2002], 'pop': [1.5, 1.7, 3.6, 2.4, 2.9]} | import pandas as pd my_df = pd.DataFrame(my_dict) print(my_df) |
null | Parse the given XML document. | <?xml version="1.0" encoding="UTF-8"?> <bookstore> <book> <title>A Game of Thrones</title> <author>George R. R. Martin</author> <price>9.99</price> </book> <book> <title>A Clash of Kings</title> <author>George R. R. Martin</author> <price>12.99</price> </book> </bookstore> | #import the required modules import xml.etree.ElementTree as ET # parse the given xml document tree = ET.parse('document.xml') root = tree.getroot() # iterate over all the elements in the document for book in root.findall('book'): title = book.find('title').text author = book.find('author').text price = book.find('pric... |
[HI Wikipedia] एस्पेरान्तो का प्राग इश्तिहार
एस्पेरान्तो की प्रगति चाहने वाले हम लोग यह इश्तिहार सब सरकारों अन्तर्राष्ट्रीय संस्थाओं और सज्जनों के नाम दे रहे हैं; यहाँ दिये गए उद्देश्यों की ओर दृढ़ निश्चय से काम करने की घोषणा कर रहे हैं; और सब संस्थाओं और लोगों को हमारे प्रयास में जुटने का निमन्त्रण दे रहे हैं। एस्पेर... | null | null | null |
null | Create a web application using Python Flask for managing a library database, including models for Book, Author, and Publisher. | Not applicable | from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(name)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)
class Book(db.Model):
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(80), unique=True)
author_id = db.Column(db.Integer,... |
[DE Wikipedia] Laurence Doherty
Hugh Laurence „Laurie“ Doherty (* 8. Oktober 1875 in London; † 21. August 1919 in Broadstairs, Kent) war ein englischer Tennisspieler. Er gewann 1900 zwei olympische Titel, zwischen 1902 und 1906 fünf Mal den Einzeltitel der Wimbledon Championships sowie als erster Nichtamerikaner 1903 ... | null | null | null |
[DE Wikipedia] Sky
Sky (englisch „Himmel“, „Himmelsgewölbe“) steht für: Sky, ehemalige norddeutsche Verbrauchermarktkette, siehe coop eG Sky (Band), britische Rockband Sky: Kinder des Lichts, auch Sky, Computerspiel von Thatgamecompany (2019) Sky Airline, chilenische Fluggesellschaft Sky Airlines, türkische Charterflu... | null | null | null |
[HI Wikipedia] गोदी
नौनिवेश या गोदी या 'डॉक' (dock) जलयानों के ठहरने के स्थान को कहते हैं। यदि स्थान पूरी तरह घिरा हुआ नहीं है, बल्कि उसका मुख समुद्र से आने-जाने के लिए सदा खुला रहता है, तो उसके लिए 'बेसिन' नाम अधिक उपयुक्त है, यद्यपि यह नाम सर्वव्यापी नहीं है। गोदियों के मुख पर फाटक या कोठियाँ लगी होती हैं, जिससे उनम... | null | null | null |
null | Calculate the maximum of three numbers in Java. | int a = 10; int b = 15; int c = 20; | int max = Math.max(a, Math.max(b, c)); System.out.println("Maximum of the three numbers is: "+max); |
null | Design a class in Python that could represent a book. | class Book:
def __init__(self, title, author, year):
self.title = title
self.author = author
self.year = year
# other methods, such as get_title(), set_title(), get_author(), set_author(), etc. could go here | |
null | Write an R program to find the unique values in a vector. | data = c(10, 20, 30, 20, 40, 30, 50) | data = c(10, 20, 30, 20, 40, 30, 50) uniq_data = unique(data) print(uniq_data) # Outputs: 10, 20, 30, 40, 50 |
[DE Wikipedia] Flinders-Halbinsel
Die Flinders-Halbinsel (englisch: Flinders Peninsula) ist eine Halbinsel im Süden des australischen Bundesstaates Western Australia. Sie bildet den östlichen Abschluss der rund 15 Kilometer langen Torndirrup Peninsula. Nördlich der Halbinsel liegt der King George Sound mit dem Ort Alb... | null | null | null |
[EN Wikipedia] United Business Institutes
UBI Business School, or UBI, (formerly known as United Business Institutes) is a private establishment of higher education located in Brussels, Luxembourg and Shanghai delivering BSc, MSc, MBA and DBA programmes in Business Studies and Administration. The school was founded as... | null | null | null |
null | Name two methods of sorting a list in Python. | The two methods of sorting a list in Python are the sorted() function and the .sort() method. | |
null | Create a MySQL query to return the employee details from the "employees" table with the minimum salary. | Table Name: Employees Columns: Emp_ID, First_Name, Last_Name, Job_Position, Salary | SELECT * FROM Employees ORDER BY Salary ASC LIMIT 1 |
[CS Wikipedia] Haimann
Příjmení Haimann nese více osob, mimo jiné: Julius Haimann (1887–1939) – německý filmový producent Karel Haimann (1902–?) – český projektant, autor vzduchotechniky vily Tugendhat Petr Haimann (* 1938) – český historik a teoretik architektury, numismatik | null | null | null |
null | Write a Python program to determine the maximum of two numbers. | a = 15, b = 20 | def get_max(a, b):
if a > b:
return a
else:
return b
a = 15
b = 20
max_value = get_max(a, b)
print("The maximum value is:", max_value) |
null | Using the data provided below, create an SQL query to find the first name, last name and age of all employees over the age of 40. | Table: employees Columns: first_name, last_name, age | SELECT first_name, last_name, age FROM employees WHERE age > 40 |
null | Create a vectorized function in Python that computes the sigmoid of a given number. | import numpy as np
def sigmoid(x):
"""
Compute the sigmoid of an array of numbers x.
"""
# Apply the sigmoid function to every element of x
sig = np.vectorize(lambda x: 1/(1 + np.exp(-x)))
return sig(x)
print(sigmoid(5)) | |
null | Build a Python program to decrypt a given secret code. | def decrypt(code):
# create a shift list
shift_list = [1, 3, 5, 7, 9, 11]
# empty list to store decoded message
decoded_message = ''
# iterate over characters in the secret code
for char in code:
# store character's ASCII value in a variable
char_ascii_value = ord(char... | |
null | Create a Python dictionary that stores the number of occurrences of each character in a string. | s = "Hello World!" | def countCharacters(s):
# Create empty dictionary
chars_dict = {}
# Iterate over each character in the string
for char in s:
# If the character is not in the dictionary, set the value to 1
if char not in chars_dict:
chars_dict[char] = 1
# Otherwise, increment the value
else:
char... |
null | Create a function that takes two integers, A and B, and returns the largest common divisor between A and B. | def get_largest_common_divisor(a, b): while a != 0 and b != 0: if a > b: a %= b else: b %= a return a + b if __name__ == '__main__': print(get_largest_common_divisor(15, 9)) | |
[EN Wikipedia] Muddiman Committee
The Muddiman Committee or the Reforms Enquiry Committee (1924) was a committee led by Sir Alexander Muddinman, organized by the British and Indian government, to meet the demand of Indian leaders in the context of Indians new ( swaraj party resolution 1920]] (India's Independence). Th... | null | null | null |
null | Generate a Python program that determines the largest number in the given array. | [7, 12, 5, 9] | arr = [7, 12, 5, 9]
def find_max(arr):
max_num = arr[0]
for num in arr:
if num > max_num:
max_num = num
return max_num
print("The largest number is:", find_max(arr)) |
null | Write a python program to remove all the elements from a list that are less than 10. | mylist = [4, 7, 21, 24, 88, 12] | def remove_less_than_10(mylist): return [n for n in mylist if n >= 10] |
null | Transform a given XML document into a JSON object using Python. | import xmltodict # open the XML document with open("document.xml") as f: xml_data = f.read() # convert to json json_data = xmltodict.parse(xml_data) # print the JSON object print(json.dumps(json_data, indent=2)) | |
null | Write a Python program that merges two sorted lists into one. | list_1 = [1, 3, 5, 7, 9]
list_2 = [2, 4, 6, 8, 10] | list_1 = [1, 3, 5, 7, 9]
list_2 = [2, 4, 6, 8, 10]
def merge_lists(list_1, list_2):
'''Merges two sorted lists into one'''
merged_list = []
while list_1 and list_2:
if list_1[0] < list_2[0]:
merged_list.append(list_1.pop(0))
else:
merged_list.append(list_2.pop(0))
merged_list.extend(list_1 + list_2)
retur... |
null | Given an array with n elements, find the maximum element of the array. | [1, 10, 5, 33, 4] | 33 |
null | Write a code to find the day of the week corresponding to a given date using the calendar module? | Day: 25 Month: December Year: 2020 | """ Find the day of the week corresponding to a given date using calendar module """ import calendar def get_day_of_week(day, month, year): dayNumber = calendar.weekday(year,month,day) dayName = calendar.day_name[dayNumber] return dayName if __name__ == '__main__': day = 25 month = 12 year = 2020 print(get_day_of_week(... |
[DE Wikipedia] Alois Schertzinger
Alois Schertzinger (* 13. Juli 1787 in Gütenbach; † in Sarata, gebürtig Aloysius Schertzinger) war Uhrmacher, Kapellmeister und Mitbegründer der deutschen Siedlung Sarata in Bessarabien. Leben Alois Schertzinger wurde am 13. Juli 1787 in Gütenbach bei Furtwangen im Schwarzwald geboren... | null | null | null |
null | Create a function which takes two parameters and returns true if the second parameter is a power of the first parameter. | x = 16 y = 4 | def is_a_power_of(x, y): if x == y: return True if x > y and y != 0: return is_a_power_of(x/y, y) else: return False power_of = is_a_power_of(x, y) |
[DE Wikipedia] Thomas Keating
Thomas Aquinas Keating OCSO (* 7. März 1923 in New York; † 25. Oktober 2018 in Spencer, Massachusetts) war ein US-amerikanischer Trappistenmönch und Abt sowie einer der Mitbegründer des Centering Prayer. Leben Thomas Keating studierte nach dem Besuch der Deerfield Academy Philosophie und ... | null | null | null |
null | Create a Python program that takes an input of a list of numbers and prints out the median of the list. | [2, 9, 4, 8, 0, 7, 1] | def median(nums):
# Sort the list
nums.sort()
length = len(nums)
# Check for even length list
if length % 2 == 0:
# Get average of two middle elements
median = (nums[int(length / 2)] + nums[int(length / 2 - 1)]) / 2
else:
# Return middle element
median = nums[int(length / 2)]
return median
nums = [2... |
[HI Wikipedia] लाल सागर मुहाफ़ज़ाह
लाल सागर मुहाफ़ज़ाह (अरबी: , अंग्रेज़ी: Red Sea) मिस्र का एक मुहाफ़ज़ाह (उच्च-स्तरीय प्रशासनिक विभाग) है। यह देश के दक्षिण-पूर्वी कोने में नील नदी और लाल सागर के दरम्यान स्थित है। इसकी दक्षिणी सीमा सुडान से लगती है। इसमें 'हलाइब त्रिकोण' नामक क्षेत और सियाल द्वीप भी आते हैं जिनको लेक... | null | null | null |
[DE Wikipedia] Ko Mak
Ko Mak (auch: Ko Maak, Thai ) ist eine Insel in Thailand. Geografie Ko Mak gehört zur Provinz Trat und liegt im östlichen Golf von Thailand zwischen Ko Chang (nördlich) und Ko Kut (südlich) und hat einen Umfang von 27 Kilometer mit einigen Sandstränden. Die Insel hat einen Durchmesser von sechs K... | null | null | null |
null | Write an SQL query that returns the seating capacity of a given theater. | theater name = “Fox Theatre” | SELECT theater_name, seating_capacity FROM theater WHERE theater_name = 'Fox Theatre'; |
[CS Wikipedia] Viskozita
Viskozita (také vazkost) je fyzikální veličina udávající poměr mezi tečným napětím a změnou rychlosti v závislosti na vzdálenosti mezi sousedními vrstvami při proudění skutečné kapaliny. U pevných látek se viskozita projevuje různou deformační odezvou v závislosti na délce trvání působení zatí... | null | null | null |
null | Create an API in Python that takes in an integer as an input parameter and returns whether the number is prime or not. | num: 37 | # Import the required library
import math
# Check if a number is prime
def is_prime(num):
if num < 2:
return False
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
# Main program
num = int(input('Enter a number: '))
if is_prime(num):
print(f'{num} is a prime number')
else:
... |
null | Port a Java code snippet to Python 3. | public class Foo {
public int foo( int a, int b ) {
return a + b;
}
} | def foo(a, b):
return a + b |
null | Create a web scraper using Python that collects data from the given URL - http://example.com/ | http://example.com/ | import requests
from lxml import html
# Get the response
resp = requests.get('http://example.com/')
# Parse the response
doc = html.fromstring(resp.text)
# Extract the data
data = doc.xpath('//div/span/text()')
# Print out the data
print(data) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.