text
stringlengths
141
2.89k
⌀
instruction
stringlengths
19
1.5k
⌀
input
stringlengths
0
800
⌀
output
stringlengths
1
2.5k
⌀
null
Create a program that finds the average of two numbers.
7 and 9
def find_average(num1, num2): return (num1 + num2) / 2 if __name__ == '__main__': print(find_average(7, 9))
null
Create a basic Python program that prints a message in the console every 3 seconds.
Not applicable
import time while True: print 'This message is printed every 3s' time.sleep(3) # Sleep for 3 seconds
null
You need to compute the Average of all numbers stored in an array
arr = [3, 2, 5, 9, 6]
average = 5.4
null
Augment an integer list with zeros after every 4 elements.
List = [1,2,3,4,5,6,7,8]
def list_augment(int_list): """ This function takes in a list of integers and augments it with zeros after every 4 elements. """ augmented_list = [] for i in range(0, len(int_list), 4): augmented_list.append(int_list[i:i + 4]) augmented_list.append(0) augmented_list.pop() return [item for sublist in augmented_list for ...
[DE Wikipedia] Kloster Ripalta di Puglia Das Kloster Ripalta di Puglia (S. Maria di Ripalta di Puglia) ist ein ehemaliges Zisterzienserkloster in der Region Apulien, Italien. Lage Das Kloster lag 7 km von Lesina in der Provinz Foggia am rechten Ufer des Flusses Fortore auf einer kleinen, Ripalta genannten Anhöhe, in d...
null
null
null
null
Edit the following Python program to make it run without any syntax errors.
def sum(alist) total 0 for i in range alist total += i return total
def sum(alist): total = 0 for i in alist: total += i return total
null
Write a regular expression to validate a domain name.
regex = r"^(([a-zA-Z]{1})|([a-zA-Z]{1}[a-zA-Z]{1})|([a-zA-Z]{1}[0-9]{1})|([0-9]{1}[a-zA-Z]{1})|([a-zA-Z0-9][a-zA-Z0-9-_]{1,61}[a-zA-Z0-9]))\.([a-zA-Z]{2,6}|[a-zA-Z0-9-]{2,30}\.[a-zA-Z]{2,3})$"
[EN Wikipedia] 1994 Nations Cup The 1994 Nations Cup was held in Gelsenkirchen on November 17–20. Medals were awarded in the disciplines of men's singles, ladies' singles, pair skating, and ice dancing. Results Men Ladies Pairs Ice dancing External links Skate Canada results Nations Cup, 1994 Bofrost Cup on Ice
null
null
null
null
How can you flatten a list of lists?
from itertools import chain flattened_list = list(chain.from_iterable(list_of_lists))
null
Using HTML, write a code to create a link that redirects to a specified webpage.
Link: https://www.google.com
<a href="https://www.google.com">Click here to visit Google</a>
null
Write a Python function that validates a given credit card number.
def validate(number): """ Validate credit card number using Luhn algorithm """ num = [int(x) for x in str(number)] return (sum(num[::-2] + [sum(divmod(d*2,10)) for d in num[-2::-2]]) % 10 == 0
null
Edit the following code to find the maximum of three numbers
a = 3 b = 5 c = 7
a = 3 b = 5 c = 7 maximum = max(a, b, c) print("The maximum of three numbers is: ", maximum)
null
Create a loop in Python with the given requirements.
Print out the numbers from 1 to 10, inclusive
for x in range(1, 11): print(x)
[EN Wikipedia] Nuritamburia chlorocalla Nuritamburia chlorocalla is a moth of the family Tortricidae. It was first described by Lord Walsingham in 1907. It is endemic to the island of Hawaii. External links Archipini Endemic moths of Hawaii
null
null
null
null
Write a query for filtering an array of objects in a MongoDB collection by their 'age' field.
The collection is named 'users' and the filter should return objects with age greater than 21
db.users.find({"age": { $gt: 21 }});
null
Generate a list of the first 10 Fibonacci numbers in Python.
def fibonacci(n): a = 0 b = 1 if n < 0: print("Incorrect input") elif n == 0: return a elif n == 1: return b else: for i in range(2,n+1): c = a + b a = b b = c return b # Driver Program fib_list = [] fo...
null
Create a web crawler in Python that takes a given URL and prints out a list of links.
https://www.example.com
from bs4 import BeautifulSoup import requests url = 'https://www.example.com' response = requests.get(url) soup = BeautifulSoup(response.text, 'lxml') for link in soup.find_all('a'): print(link.get('href'))
null
Create a method in Python to sort all the elements in the given dictionary in descending order of the values.
dictionary = {"A": 30, "B": 40, "C": 20}
def sortByValue(dictionary): sorted_dict = dict(sorted(dictionary.items(), key=lambda x: x[1], reverse=True)) return sorted_dict dictionary = {"A": 30, "B": 40, "C": 20} result = sortByValue(dictionary) print(result) # prints {'B': 40, 'A': 30, 'C': 20}
null
Create a hash table in C with 5 elements.
#include <stdio.h> #include <stdlib.h> struct HashTable { int key; int value; } h[5]; void main() { for (int i = 0; i < 5; i++) { h[i].key = i; h[i].value = i * i; } for (int i = 0; i < 5 ; i++) printf("%d %d\n", h[i].key, h[i].value); }
[HI Wikipedia] संस्कृत भाषा संस्कृत (संस्कृतम्, ) भारत की एक भाषा है। संस्कृत एक हिंद-आर्य भाषा है जो हिंद-यूरोपीय भाषा परिवार की एक शाखा है। संस्कृत दिव्य एवं समृद्ध भाषा है। ऐतिहासिकता की दृष्टि में यह संसार की सभी भाषाओं की जननी है। संस्कृत संसार की प्राचीनतम एवं प्रथम भाषा है। भारतीय आर्ष ग्रंथ का समस्त ज्ञान इसी ...
null
null
null
null
Add a method to a given class to check if an element is present in it.
class MyClass: def __init__(self, elements): self.elements = elements def contains(self, element): return element in self.elements
null
Create a SQL statement to list all the entries with a rating greater than 3 from the table "movies".
SELECT * FROM movies WHERE rating > 3;
[HI Wikipedia] ईरोस ईरोस (यूनानी : एरोस ) प्राचीन यूनानी धर्म के प्रमुख देवताओं में से एक थे। वो प्यार, कामना, वासना और संभोग के देवता थे। कुछ इतिहासकारों के मुताबिक वो पुरुष-पुरुष प्रेम का ख़ास तौर पर प्रतिनिधित्व करते थे। प्राचीन रोमन धर्म में उनके समतुल्य देवता थे क्यूपिड। हिंदू समतुल्य देवता कामदेव. यूनान के देवी-...
null
null
null
[HI Wikipedia] कोयंबतूर कोयम्बतूर (Coimbatore) या कोयंबुत्तूर भारत के तमिल नाडु राज्य के कोयम्बतूर ज़िले में स्थित एक नगर है। यह ज़िले का मुख्यालय भी है। विवरण कर्नाटक और तमिलनाडु की सीमा पर बसा शहर मुख्य रूप से एक औद्योगिक नगरी है। शहर रेल और सड़क और वायु मार्ग से अच्छी तरह पूरे भारत से जुड़ा है। कोयंबुत्तूर एक महत्व...
null
null
null
null
Suggest a method in Java to compare two strings.
The easiest way to compare two strings in Java is to use the built-in String class's equals() method. This method compares all characters in the strings, and returns true if the strings are equal or false otherwise. For example, given the strings "Hello" and "Goodbye", the following code would evaluate to false: String...
null
Write an if statement to check if a string is equal to "Hello".
word = "Hello"
// program to check if a string is equal to "Hello" if (word == "Hello") { console.log("String is equal to 'Hello'") }
null
Train a Random Forest classifier in Python on the Iris dataset.
import pandas as pd from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier # Import Iris dataset iris_data = pd.read_csv("iris.csv") # Split dataset into training and testing X = iris_data.drop("species", axis=1) y = iris_data['species'] X_train, X_test, y_train, y_test...
null
Generate a Python program that creates a list of five random integers between 1 and 100.
Not applicable
import random my_list = [] for i in range(5): my_list.append(random.randint(1,100)) print(my_list)
[DE Wikipedia] Elisabeth Borchers Elisabeth Borchers (* 27. Februar 1926 in Homberg, Niederrhein; † 25. September 2013 in Frankfurt am Main) war eine deutsche Schriftstellerin und literarische Übersetzerin. Leben Elisabeth Borchers wuchs in Homberg auf und lebte während des Zweiten Weltkrieges bei ihren Großeltern im ...
null
null
null
null
Compare two integers and print the larger one.
a = 3, b = 5
if a > b: print(a) else: print(b)
[EN Wikipedia] Analog signal An analog signal is any continuous-time signal representing some other quantity, i.e., analogous to another quantity. For example, in an analog audio signal, the instantaneous signal voltage varies continuously with the pressure of the sound waves. In contrast, a digital signal represents ...
null
null
null
null
Write a python program to classify a text into one of three categories: positive, negative, or neutral.
The airport experience was not bad at all.
import nltk # load in the text and tokenize it text = "The airport experience was not bad at all." tokens = nltk.word_tokenize(text) # define the category labels labels = ['positive', 'negative', 'neutral'] # define a function to predict the sentiment def classify_sentiment(tokens): # TODO: write code to classif...
null
Generate a password strength checker in Python that follows the NIST guidelines.
import re def check_password_strength(password): '''This function checks if the given password is strong according to NIST guidelines''' # check if password is atleast 8 characters long if len(password) < 8: return False # check if password contains atleast one lowercase letter if not ...
null
Create a python program to edit the given nested dictionary by adding a new element.
nested_dict = { 'makers': ['John', 'Alan'], 'printers':{ 'color':['hp', 'canon'], 'black_white': ['epson'] } } New element to add: {'copiers':['Xerox', 'Ricoh']}
def edit_dict(nested_dict, new_element): """Edit the given nested dictionary by adding a new element.""" nested_dict.update(new_element) return nested_dict # Usage Example nested_dict = { 'makers': ['John', 'Alan'], 'printers':{ 'color':['hp', 'canon'], 'black_white...
[EN Wikipedia] Wilbur Mack Wilbur Mack (born George Frear Runyon, July 29, 1873 – March 13, 1964) was an American film actor and early vaudeville performer from the 1920s through the 1960s. His film acting career began during the silent film era. Biography Mack was born and raised in Binghamton, New York, and began ac...
null
null
null
[DE Wikipedia] Karl Kugler Karl Kugler (* 20. Mai 1803 in Monheim (Schwaben); † 30. April 1881 in Eichstätt) war ein deutscher Lehrer und Heimatforscher. Leben Kugler wurde im Mai 1803 in Monheim als Sohn eines Handelsmannes aus Monheim geboren. Er lernte als Schüler an den Königlichen Studien-Schulen zu Eichstätt im ...
null
null
null
[DE Wikipedia] Dorothee Lebeda Dorothee Lebeda (* 1967) ist eine deutsche Pflegewissenschaftlerin und Professorin für Pflegepädagogik mit dem Schwerpunkt Beratung an der Katholischen Hochschule Nordrhein-Westfalen, Abteilung Köln. Leben Lebeda absolvierte eine Ausbildung als Krankenschwester, studierte Pflegewissensch...
null
null
null
null
Modify the code below to create a new function called "addSquares()" that adds the squares of two numbers and returns the result.
def add(x, y): return x + y
def add(x, y): return x + y def addSquares(x, y): return x*x + y*y
null
Correct the following Python code so it prints out the current hour in 24-hour format.
import datetime current_hour = datetime.now() print("Current hour is") print(current_hour.hour)
import datetime current_time = datetime.datetime.now() print("Current hour is") print(current_time.strftime("%H"))
null
Generate all the permutations of a string using Python.
str = "abc"
def permutations(str): if len(str) <= 1: return [str] perms = [] for i in range(len(str)): rest_strings = str[:i] + str[i+1:] for perm in permutations(rest_strings): perms.append(str[i:i+1] + perm) return perms str = "abc" perms = permutations(str) print(perms) # ['abc', 'acb', 'bac', 'bca', 'cab', 'c...
null
Write a CSS style to make a <div> element of width 500px and height 400px.
div { width: 500px; height: 400px; }
null
Develop a Python script to add a given list of numbers.
[4, 8, 15, 20]
def sum_list(list_of_nums): total = 0 for number in list_of_nums: total += number return total result = sum_list([4, 8, 15, 20]) print(result)
null
Create a Swift program to print out the following: “Hello, World!”
print("Hello, World!")
[DE Wikipedia] Atomwaffenfreie Zone Der Begriff atomwaffenfreie Zone oder kernwaffenfreie Zone bezeichnet einen räumlichen Bereich, der frei von Kernwaffen ist. Erstmals tauchte er in den 1950er Jahren auf, als im Kalten Krieg das atomare Wettrüsten zwischen Ost und West begann und auch in der Bundesrepublik Deutschla...
null
null
null
null
Generate a code to sort a list of floats.
[4.5, 7.5, 1.5, -2.5]
def sort_floats(arr): arr.sort(key=float) return arr
null
Create a user-defined type in Python to store information about a person.
class Person: def __init__(self, firstname, lastname, age): self.firstname = firstname self.lastname = lastname self.age = age person1 = Person('John', 'Smith', 25)
[EN Wikipedia] Heterogyna Heterogynaidae is a minor and disputed lineage (only eight described species in a single genus, Heterogyna) of small spheciform wasps occurring in Madagascar, Botswana, Turkmenistan, Oman, the United Arab Emirates, and the Eastern Mediterranean area. The majority are dark in color and range i...
null
null
null
[DE Wikipedia] Younes Lalami Younes Lalami Laaroussi (; * 18. April 2001 in Montreal, Kanada) ist ein kanadisch-marokkanischer Tennisspieler. Persönliches Lalami Laaroussi wurde in Montreal, Quebec, geboren, spielt Tennis aber für das Geburtsland seines Vaters, Marokko. Seine Schwester Nadia Lalami (* 1990) erreichte ...
null
null
null
null
How many lines would the following algorithm require?
# Find all the prime numbers between two given numbers # Input: two numbers, n1 and n2 # Output: list of prime numbers between n1 and n2
It would require approximately 9 lines of code.
null
Construct a regular expression that extracts substrings that match the pattern "AAA_BBB_CCC".
Regex: ^([A-Za-z]{3})_([A-Za-z]{3})_([A-Za-z]{3})$
null
Write a Python program that takes a list of numbers and creates a new list of even numbers only.
lst = [2, 3, 5, 6, 7, 8, 10, 11]
def get_even_numbers(lst): even_lst = [] for num in lst: if num % 2 == 0: even_lst.append(num) return even_lst
null
What can be changed in the following Python code to improve its readability?
def findMax(list): x=list[0] for i in list: if i>x: x=i return x
def findMax(list): # initialize the maximum variable to the first element of the list. maximum = list[0] # iterate through the list and compare each element to the current maximum element. for element in list: if element > maximum: maximum = element # return the maximum ele...
null
Write a Python program to optimize the performance of a network by pruning redundant neurons in the model.
A simple MLP neural network with 9 neurons in the input layer, 2 hidden layers with 6 neurons each, and 2 output neurons.
import numpy as np from sklearn.neural_network import MLPClassifier # define model model = MLPClassifier(hidden_layer_sizes=(6, 6), activation='relu') # prune redundant neurons pruned_model = MLPClassifier(hidden_layer_sizes=(4, 4), activation='relu') # define data x = np.random.rand(1000, 9) y = np.random.randint(2...
null
Create a Ruby script to return the nth Fibonacci number.
# Function to return the nth Fibonacci number def calculateFibonacci(num) if num < 0 return 'Incorrect input' elsif num == 0 return 0 elsif num == 1 return 1 end #Recursive Function return calculateFibonacci(num - 1) + calculateFibonacci(num - 2) end # Driver Program puts calculateFibonacci(7)
null
Replace each occurrence of the given character in a string with a space.
String: abcde Character: c
String: ab de
null
Create an angle converter function which converts degrees to radians.
function degToRad(deg) { return deg * (Math.PI/180); }
null
Convert the following function call from Python to JavaScript.
def my_function(a, b): return a + b my_function(3, 4)
function myFunction(a, b) { return a + b; } myFunction(3, 4);
null
Given a string, write a program to reverse the words in the string.
def reverse_words(s): return ' '.join(s.split()[::-1])
null
Create a JavaScript program to validate the username entered by the user.
function validateUsername(username) { let rx = new RegExp('^[A-Za-z0-9_]{3,20}$'); return rx.test(username); }
null
Develop a program to convert an infix expression to prefix notation.
A*(B+C)-D/(E+F)
def infix_to_prefix(exp): # stack to store operators stack = [] # prefix expression pref_exp = "" # traverse through the expression for char in exp: # if the character is an operand # add it to prefix expression if char.isalpha(): pref_exp += char # if the character is an operator elif char in "*/+-^": # push the opera...
null
Modify the following Python program to calculate the factorial of a given number.
n=5
def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) num = 5 print(f"The factorial of {num} is {factorial(num)}")
[HI Wikipedia] नंगलामी भाषा नंगलामी (Nangalami, ), जिसे ग्रंगाली (Grangali) भी कहते हैं, कुनर (कुनड़) शाखा की एक दार्दी भाषा है जो अफ़ग़ानिस्तान​ के कुनर प्रान्त और नंगरहार प्रान्त की सीमा पर विस्तृत क्षेत्र में बोली जाती है जहाँ निंगलाम गाँव भी पड़ता है। यह पेच नदी और वाएगल नदी के संगम स्थल के पास है। इसकी तीन उपभाषा...
null
null
null
null
Create a Python script for a sorting algorithm that can efficiently sort an array of integers.
[8, 3, 5, 1, 4, 6]
def bubble_sort(lst): for i in range(len(lst)): for j in range(0, len(lst) - i - 1): if lst[j] > lst[j + 1] : lst[j], lst[j + 1] = lst[j + 1], lst[j] return lst lst = [8, 3, 5, 1, 4, 6] sorted_list = bubble_sort(lst) print("Sorted Array:", sorted_list)
null
Parse the following JSON string and create a JavaScript object.
{"name":"John", "age":30, "city":"New York"}
const jsonString = '{"name":"John", "age":30, "city":"New York"}'; const obj = JSON.parse(jsonString); console.log(obj); // {"name":"John", "age":30, "city":"New York"}
null
Write a script which receives two integers as parameters and returns their average as output.
def average(a, b): return (a+b)/2
null
Create a Python class that contains methods to calculate the area of a square and a rectangle.
class AreaCalculator: def __init__(self): pass def square_area(self, side_length): return side_length * side_length def rectangle_area(self, length, width): return length * width
null
Write a short python program to sort a list of words in lowercase alphabetical order
def sort_words(word_list): word_list.sort(key = lambda x : x.lower()) return word_list
[CS Wikipedia] Rechenburk Rechenburk (někdy též Rechemberk) je zaniklý hrad mezi Horním Starým Městem a Libčí v Trutnově v Královéhradeckém kraji. Existoval po krátkou dobu ve druhé polovině třináctého století, kdy ho jako mocenský opěrný bod postavili páni ze Švábenic. Historie Hrad, jehož název je odvozen z osobního...
null
null
null
null
Clone a remote Git repository using a Python program.
import git # Clone a remote Git repository repo = git.Repo.clone_from("https://github.com/username/repo.git")
[HI Wikipedia] धानीप्राणी धानीप्राणी या मारसूपियल​ (Marsupial) स्तनधारी जानवरों की एक वर्ग है जो अपने शिशुओं को अपने पेट के पास बनी हुई एक धानी (थैली) में रखकर चलते हैं। यह ज़्यादातर पृथ्वी के [अपने अस्तित्व में आने के समय से ही उत्तरी गोलार्ध ]] (हेमिस्फ़ीयर​) में पाए जाते हैं। जाने-माने धानीप्राणियों में कंगारू, कोआ...
null
null
null
null
Write a Python program to reformat a string using a given dictionary.
"Hello {name}, it's {time} to go",{'name':'John', 'time':'2pm'}
def reformat_string(string, mapping): for k, v in mapping.items(): string = string.replace('{' + k + '}', v) return string if __name__ == "__main__": string = "Hello {name}, it's {time} to go" mapping = {"name": "John", "time": "2pm"} print(reformat_string(string, mapping)) # Output: Hello ...
null
Develop a function that returns the sum of three numbers
three integers a, b, c
# Python3 program to return the sum of three numbers def sum_three(a,b,c): return a + b + c
null
Write a distributed Python program which can generate the Fibonacci series using Spark.
Not applicable
import findspark findspark.init() from pyspark import SparkContext sc = SparkContext('local', 'fibonacci-generator') def generate_fibonacci(): rdd = sc.parallelize([0,1]) for _ in range(100): rdd = rdd.flatMap(lambda x: [x, x + rdd.takeSample(withReplacement=True)[0]]) return rdd.collect() result = generate_fib...
null
Create a function in Python to generate a multiplication table with numbers in a range given start and end parameters.
start = 5 end = 10
def multiplication_table(start, end): for x in range(start, end + 1): for y in range(start, end + 1): print(x * y, end = " ") print("\n") multiplication_table(start, end)
null
Create a program in Python that implements bubble sort.
def bubble_sort(nums): for i in range(len(nums)-1): for j in range(len(nums)-i-1): if nums[j] > nums[j+1]: nums[j], nums[j+1] = nums[j+1], nums[j] return nums
null
Create a new View subclass of UIView and name it "MainView".
class MainView: UIView { override func draw(_ rect: CGRect) { // code to customize the main view } }
null
Write a Python function to calculate the cosine similarity between two vectors.
vector1 = [1,2,3] vector2 = [2,4,6]
def cosine_similarity(vector1, vector2): ''' Calculate the cosine similarity between two vectors Inputs: vector1 - list of numbers vector2 - list of numbers Output: cosine_similarity - float value ''' import math #Error handling if len(vector1) != len(vector2): return "Error: vector lengths must be equal" #...
null
Write a function that checks if a given string contains a valid date.
function isValidDate(dateString) { var regEx = /^\d{4}-\d{2}-\d{2}$/; if(!dateString.match(regEx)) return false; // Invalid format var d = new Date(dateString); if(Number.isNaN(d.getTime())) return false; // Invalid date return d.toISOString().slice(0,10) === dateString; };
null
Generate a correct Python program to compute the reverse of the given string
string = "hello"
def reverse_string(string): output = "" for i in range(len(string)): output += string[len(string)-1-i] return output
null
Use the string `'Hello world!'` and print it reversed.
!dlrow olleH
null
Create an HTML form to ask the user for their email and password.
<form action="authenticate.php" method="post"> Email: <input type="text" name="email" /> <br /> Password: <input type="password" name="password" /> <br /> <input type="submit" value="Submit" /> </form>
null
Design a SQL query to select the top 5 movies based on the number of 'likes'.
Table Name: Movies Columns: Movie_ID, Movie_Name, Likes
SELECT Movie_Name FROM Movies ORDER BY Likes LIMIT 5;
null
Create a Python script that takes two strings as an input and returns the longest common subsequence of those two strings.
ABCD BCEA
def longestCommonSubsequence(str1, str2): # find the length of the strings m = len(str1) n = len(str2) # declaring the array for storing the dp values L = [[None]*(n+1) for i in range(m+1)] """Following steps build L[m+1][n+1] in bottom up fashion Note: L[i][j] contains length of...
[DE Wikipedia] Zlib Die zlib ist eine freie Programmbibliothek zum Komprimieren und Dekomprimieren von Daten mit dem Deflate-Algorithmus. Technik zlib kann sowohl gzip-Dateien (.gz) erstellen als auch einen Datenstrom bearbeiten. Das Format des ausgegebenen Datenstromes, der Deflate-Algorithmus und das gzip-Dateiforma...
null
null
null
null
Create a function in Python which takes a list as input and returns the sum of the items in the list.
def sum_list(input_list): sum = 0 for i in input_list: sum += i return sum
null
Generate a Python program that computes the Euclidean distance between two points in a two-dimensional space.
Point A - x: 3, y: 5 Point B - x: 7, y: 6
import math # Define the two points pointA = (3, 5) pointB = (7, 6) # Calculate the Euclidean distance distance = math.sqrt( (pointB[0] - pointA[0])**2 + (pointB[1] - pointA[1])**2 ) print("The Euclidean distance between the two points is:", distance)
null
Write an HLSL code snippet that creates a 3D vector with the components (x, y, z) = (1, 0, 1).
float3 vec = float3(1.0f, 0.0f, 1.0f);
null
Create an AI chatbot in Python to respond to simple natural language questions about the weather.
Not Applicable
#create a simple AI chatbot in Python def chatbot(): print("Hello, my name is Weather Bot. I can help you with questions about the weather!") while True: query = input("You: ") query = query.lower() # exit the loop is the user enters "quit" if query == "quit": ...
[EN Wikipedia] Louise Jordan (disambiguation) Louise Jordan was a geologist. Louise Jordan may also refer to: Louise Jordan (novelist) See also Louise Jordan Smith, American painter and academic Louisa Jordan (disambiguation)
null
null
null
null
Design a basic graphic user interface (GUI) for a calculator.
import tkinter as tk root = tk.Tk() # design the window root.title("Calculator") root.geometry("200x250") # create the buttons button1 = tk.Button(root, text="1", width=5, height=2) button1.grid(row=0, column=0, padx=4, pady=4) button2 = tk.Button(root, text="2", width=5, height=2) button2.grid(row=0, column=1, padx=4,...
null
Write a Python program to sum up the prime numbers below 100.
def sum_prime_numbers(limit): sum = 0 for num in range(2, limit + 1): if all(num % i != 0 for i in range(2, num)): sum += num return sum print(sum_prime_numbers(100))
null
How does the following CSS style the first letter of a paragraph?
p::first-letter { font-weight: bold; }
The first letter of a paragraph will be rendered with a bold font style.
null
Use the Paginator library in Python to create a list of items divided into multiple pages.
Items: ["apple", "banana", "carrot", "date", "elderberry", "fig", "grape", "honeydew", "iceberg lettuce"]
from paginator import Paginator def page_items(items, page_number): p = Paginator(items, 3) # items per page return p.page(page_number).object_list page_1 = page_items(["apple", "banana", "carrot", "date", "elderberry", "fig", "grape", "honeydew", "iceberg lettuce"], 1) print(page_1) # ["apple", "banana", "ca...
null
Create a python program to check the length of a given string
def check_length(string): return len(string)
null
Create a Python program to sort a dictionary in order of the values.
# using lambda function to sort the dictionary sorted_by_value = sorted(dictionary.items(), key = lambda kv: kv[1]) # printing the dictionary sorted by value print(sorted_by_value)
null
Develop a code in Java to calculate the BMI given the height and weight of a person.
public double calculateBMI(double height, double weight){ double bmi; height = height/100; bmi = weight / Math.pow(height, 2); return bmi; }
null
Create a function in Python that will convert a string to all uppercase letters.
input_string = "This Is A String"
def uppercase_string(input_string): return input_string.upper()
[EN Wikipedia] Dora del Hoyo Dora del Hoyo Alonso, (11 January 1914 - 10 January 2004; born Salvadora Honorata del Hoyo Alonso in Leon, Spain) was one of the first women members of Opus Dei. A domestic worker by profession, del Hoyo was the first to join the Prelature of Opus Dei as an assistant numerary meaning that ...
null
null
null
[HI Wikipedia] ऐक्विटेन ऐक्विटेन (Aquitaine) फ्रांस के २७ प्रभागों में से एक है। परिचय यह फ्रांस के दक्षिण-पश्चिम भाग में स्थित एक नीची भूमिवाला प्रदेश है, जिसमें शाराँत, गारौं तथा आदूर घाटियाँ समिलित हैं। यह ऊबड़ खाबड़ त्रैकोणिक मैदान है, जो पूर्व की ओर ऊँचा होता हुआ मध्य पठार हो गया है। यह प्रदेश भूमध्यसागर तटीय प्र...
null
null
null
null
Generate an object using JavaScript that contains the numbers from 1 to 10.
const myObject = { "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9, "10": 10 };