text stringlengths 0 4.46k |
|---|
Create an array of length 5 which contains all even numbers between 1 and 10. Formulate an equation to calculate the height of a triangle given the angle, side lengths and opposite side length. Write a replace method for a string class which replaces the given string with a given set of characters. string = "Hello Wo... |
replace_with = "Greetings!" Create an array of length 15 containing numbers divisible by 3 up to 45. Write a function to find the number of distinct states in a given matrix. matrix = [[1, 0, 0], |
[1, 0, 1], |
[1, 1, 1]] Create a nested loop to print every combination of numbers between 0-9 Write a function to find the maximum difference between two numbers in a given array. arr = [5, 3, 17, 11, 9] Write a function to generate the nth Fibonacci number. < noinput > Write a class to represent a 2D point with x and y... |
print(i) Write code to find the sum of all numbers between 1 and 10. Create a function to calculate the area of a given circle. Follow the comments in the code to complete the program which prints a conversion table from Fahrenheit to Celsius. # This program prints a conversion table from Fahrenheit to Celsius |
# Print a heading for the table |
# TODO |
# Print the column headings |
# TODO |
# Calculate and print the table body |
# TODO Develop a classification algorithm in Python to predict whether a bird is a hawk or a falcon. Create a function in Java for computing the factorial of a positive integer number. Create a C++ program for randomly shuffling an array of integers. Use the function to debug the given program and prevent the segmen... |
int main() { |
int array[] = {1, 2, 3, 4, 5}; |
int n = 5; |
int i; |
// TODO |
for (i = 0; i <= n; i++) { |
printf("%d\n", array[i]); |
} |
return 0; |
} Replace the placeholder with a for loop for iterating over the numbers from 1 to n and printing them. for i in range(n): |
# TODO Use try-except statements to detect and handle exceptions in the code. for i in range(n): |
x = 1/i Re-write the code segment as a list comprehension. numbers = [] |
for i in range(10): |
if i % 2 == 0: |
numbers.append(i) Remove the boilerplate code from the program for printing 10 random numbers. import random |
# Generate 10 random numbers |
for i in range(10): |
# TODO Modify the code to perform the mathematical expression “x to the power of y”. # Calculate x to the power of y |
# TODO Create a dictionary for counting the occurrence of each letter in the given string. string = "hello world" |
#TODO Follow the comments to complete the code that finds the maximum value in an array. # Find the maximum value in an array |
arr = [4, 5, 2, 8, 7] |
# TODO Write a function in HTML for creating a table of n rows and m columns. Create a CSS script that centers the login form on the webpage. Create a Java program that prints out the sum of the numbers in the array. int[] numbers = {1, 2, 3 , 4, 5}; Write a SQL query to calculate the total number of orders in the "o... |
end_date = '2020-02-01' Create a Ruby code that prints out the median of a given array of numbers. nums = [1, 7, 3, 6] Create a PHP code to check if an array contains a given item. $input_array = array(1,2,3,4,5); |
$item_to_check = 3; Edit the code to create a try-except block to handle the exception. a = 5 |
b = 0 |
ans = a/b Write a script using Bash that replaces all vowels with a number. Change the variable `x` to the data type desired. x = 'Hello World!' Create a function that takes an array as an argument and returns the sum of all the elements in the array. arr = [1, 2, 3, 4, 5] Sort the array in ascending order. arr = [3, ... |
console.log(num) |
} Create a JSON object with three key-value pairs. Count the number of characters in the string. text = "Hello World!" Generate a random number between 0 and 1 (inclusively). Compose a function named average_list which takes a list of numbers as its argument and computes the average. Generate a snippet of code to ex... |
int sum = 0; |
for (int i = 0; i < 3; i++) |
{ |
sum += arr[i]; |
} Write a MySQL query to print the column names of a table named 'employees'. Generate a regular expression to match a valid email address. How to delete a particular row in an SQLite database table? Is it possible to set a breakpoint that is not associated with any source code line in a GDB program? Write a C++ co... |
for element in lst: |
if (type(element) == int): |
lst.append(element + 5) |
return lst |
example_func([1, 2, "hello"]) Write a C++ function to generate a random integer between 0 and 10. Create a table to store customer information. Create a class in Java named Puppy that has two instance variables, age and name and two methods, bark and sleep. Parse the string and return the number of unique alphabets ... |
num2 = 10 |
if num1 < num2: |
print("num1 is smaller than num2") |
else: |
print("num1 is greater than or equal to num2") Write a script to check if a given number is a palindrome or not. inputNumber = 121 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”)) What is the output of the following code? list1 = ['a', 'b', 'c'] |
list2 = [1, 2, 3] |
for x, y in zip(list1, list2): |
print(x * y) Write a function to remove all whitespace characters from a given string. myString = "Hello World " Edit the following code to add try catch block. x = "5" |
y = "2" |
sum = int(x) + int(y) |
print("Sum of x and y is", sum) Write a Python function that takes two lists of equal length and creates a dictionary of the elements in each list that have the same index. list_one = [1, 2, 3, 4] |
list_two = ["a", "b", "c", "d"] Create a quick-sort algorithm in Python. Develop an algorithm to find the value of n where n is the index of the Fibonacci sequence. Create a program that finds all the prime numbers less than or equal to a given number. Write a function that takes in a list of numbers and prints out ... |
[4, 5, 6], |
[7, 8, 9] |
] Design an algorithm that creates a random password of 8 characters. FOr a given list, create a program that prints out the standard deviation of the elements in the list. list = [1, 4, 9, 16] Create a program that can filter out words of a string that contain a specific character. string = "This is a senten... |
character = 's' Create a program that can calculate the distance between two points in three-dimensional space. point1 = (1, 5, 9) |
point2 = (4, 2, 8) Create a program that ciphers a given text using the caesar cipher. text = "This is a secret message" |
key = 3 Find the second smallest element in an integer array of size n. array = [4, 5, 8, 2, 9, 13] Write a SQL query to find all the users in a database with age greater than 25. Create a function to calculate the maximum of two numbers. Write a Python program to split a string on a given character separator. mystri... |
separator = "," Write a Python program to get the day of week from a given date and time. from datetime import datetime |
date = datetime(2020, 4, 20, 19, 15, 0) Write a Javascript function to determine if the given number is an even number or not. Write a Python program to print out an ASCII art of a given word. word = "happy" Write a JavaScript function to validate a given URL. Write a C# program to find the maximum and minimum of thr... |
separator = "-" Write a C program to find the sum of all digits of a given number Write a Java program to generate random numbers Rewrite the following Python code using a for-loop. i = 0 |
while i <= 10: |
print(i) |
i += 1 Write a code to print the current date and time in ISO format. Create a new folder called 'data' within the current working directory. Write a code to sort the following array in increasing order. [10, 2, 7, 8, 32, 4] Create a function in JavaScript that takes an array of integers and returns the largest n... |
date2: 2019-05-13 10:00:00 Write a code to connect to a remote database. username: john |
password: john123 |
IP: 100.10.0.10 Create an HTML form with a textbox, a submit button, and two radio buttons. Write a code to access the nth element of a linked list. Create a function in JavaScript to find the number of occurrences of a letter in a word. word: hello |
letter: l Write a code to add two linked lists of different sizes. list1 = [2->4->3] |
list2 = [5->6->4->1] Create a function in Java to convert a list of strings to a 2D array. list: ["aa", "bb", "cc"] Modify the code below to make it calculate the sum of all the numbers from 1 to n. num = 5 |
sum = 0 |
for i in range(num): |
sum += i Create a program to generate a histogram using data from a set of numbers. values = [3, 4, 2, 5, 8, 1, 2, 6] Create a function to convert Celsius to Fahrenheit. Write a function to find the number of occurrences of an element in a list. arr = [10, 20, 10, 40, 40, 40, 50] Write a JavaScript code snippet to p... |
b = [5, 4, 3, 2, 1] Create a list comprehension that takes all the elements of list_one and creates a new list where all the elements are doubled. list_one = [1, 2, 3, 4, 5] You are given a matrix of m rows and n columns. Write a function that calculates the transpose of the given matrix. matrix = [[1, 2, 3], [4, 5, 6]... |
second = "silent" Write a code to delete all the vowels from a given string. string = "hello world" Write a code to convert a given list of strings to uppercase. mylist = ["hello","world"] Write a code to find the maximum in a given list of integers. mylist = [1,2,3,4,5] Write a code to generate the multiplication tabl... |
list2 = [4,5,6] Write a code to compute the mean of an input list of numbers. mylist = [1,2,3,4,5] Create a program to convert the input sentence to Pig Latin. I am a computer programmer Create a program to write an overwriting if-else logic for the following switch statement switch(a) { |
case 1: |
End of preview. Expand in Data Studio
No dataset card yet
- Downloads last month
- 23