[output] | for(int i=10; i>=1; i--) { System.out.println(i); } [instruction] | Create a for loop in Java to print out the integers from 10 to 1 in decreasing order. [input] |
[output] | The shape of the pandas dataframe would be (4, 5). [instruction] | If a pandas dataframe has five columns and four rows, what is the shape of the dataframe? [input] |
[output] | int result = 5 + (10 * 3); System.out.println(result); // Output: 35 [instruction] | Compute the following expression in Java. [input] | 5 + 10 * 3
[output] | public class Calculator { public int add(int a, int b) { return a + b; } public int subtract(int a, int b) { return a - b; } } [instruction] | Write a class in Java that contains two method to add and subtract two numbers. [input] |
[output] | class Hello: def __init__(self,name,age): self.name = name self.age = age def printNameAge(self): print("Name:", self.name, "Age:", self.age) obj1 = Hello("John", 25) obj1.printNameAge() [instruction] | Develop a class in Python to print the name and age of the user. [input] | Name:"John", Age:"25"
[output] | for i in range(0, 10): print("The number is " + str(i)) if i == 5: break [instruction] | Alter the code to include a break statement in the loop. [input] | for i in range(0, 10): print("The number is " + str(i))
[output] | <p style="font-size:10px;">Hello World!</p> [instruction] | Change the HTML element to have a font size of 10px [input] | <p>Hello World!</p>
[output] | string = "Hello World 123$%^&" alphabets = 0 digits = 0 special_characters = 0 for i in range(0, len(string)): if ((string[i] >= 'a' and string[i] <= 'z') or (string[i] >= 'A' and string[i] <= 'Z')): alphabets = alphabets + 1 elif (string[i] >= '0' and string[i] <= '9'): [instruction] | Create a script to count the number of alphabets, digits and special characters in a string. [input] | String = "Hello World 123$%^&"
[output] | The physical address of the code is 18446744071421161285. [instruction] | Find physical address of the code. [input] | Code: 0x7fff2ceb5de5
[output] | text = "The food I ate yesterday was really amazing. I loved the entire experience." # lowercase text = text.lower() # remove punctuation text = re.sub(r'[^\w\s]','',text) # remove digits text = re.sub(r'\d+','',text) # Tokenization tokens = word_tokenize(text) # Stopword removal filt [instruction] | Preprocess a natural language text for text classification. [input] | Text: “The food I ate yesterday was really amazing. I loved the entire experience.”
[output] | def isEven(n): if (n % 2 == 0): return True else: return False [instruction] | Create a function to find out if a number is even [input] |
[output] | CREATE TABLE table_name ( column1 datatype, column2 datatype, column3 datatype ); [instruction] | Create a SQL table with 3 columns [input] |
[output] | import json data = '{ "id": 12345, "name": "John Smith", "age": 30 }' json_data = json.loads(data) name = json_data["name"] print(name) # Output: John Smith [instruction] | Parse the following JSON data and extract the "name" field. [input] | { "id": 12345, "name": "John Smith", "age": 30 }
[output] | December [instruction] | Provide the month that is 6 months after June. [input] |
[output] | f3 [instruction] | Convert the following number from decimal to hexadecimal. [input] | 243
[output] | http://bit.ly/3fj3C6U [instruction] | Shorten the following URL using bitly. [input] | https://www.example.com/ohAIbQ
[output] | for i in list_str: print(i.upper()) [instruction] | Given the following list of strings: list_str = ["one", "two", "three", "four", "five"] Write a program that prints out the strings in uppercase. [input] |
[output] | def get_longest_word(json_string): """Return the longest word found inside the given json_string""" words = [] data = json.loads(json_string) for key,val in data.items(): words.append(key) return max(words, key=len) [instruction] | Write a basic routine that takes in a JSON string and outputs the longest word found inside. [input] | data = '{"John": 56, "Ann":64, "Victor": 23}'
[output] | import uuid random_id = uuid.uuid4() [instruction] | Generate a random unique ID and store it in a variable. [input] |
[output] | def reverse_list(input_list): """Return a reversed copy of the list""" return input_list[::-1] [instruction] | Reverse the given list using python. [input] | list_to_reverse = [2, 3, 5, 6, 8, 10, 11]
[output] | string_from_tuple = " ".join(tuple_to_string) [instruction] | Create a string variable from a tuple. [input] | tuple_to_string = ("This", "is", "a", "tuple")
[output] | [x for x in range(2, 11) if all(x % y != 0 for y in range(2,x))][:5] [instruction] | Generate a List Comprehension that returns a list containing the first 5 prime numbers [input] |
[output] | line\sbreak [instruction] | Write a regular expression that matches the string "line break". [input] |
[output] | for i in range(10, 0, -1): print(i) [instruction] | Write a loop that prints the numbers from 10 to 1, each on its own line. [input] |
[output] | no_duplicates = list(set(num_list)) [instruction] | Given a list of numbers, remove all duplicated entries. [input] | num_list = [12, 24, 12, 5, 8, 24]
[output] | hex_val = hex(num) [instruction] | Convert a given integer to its equivalent hexadecimal value. [input] | num = 67
[output] | try: num = int(input("Enter a number: ")) if num % 2 == 0: print(str(num) + " is even.") else: print(str(num) + " is odd.") except ValueError: print("Input must be an integer.") [instruction] | Design a try/except block that takes in a user-entered number and prints whether it is even or odd. [input] |
[output] | """ A PyTorch function that predicts a class label based on five numerical features. """ import torch import torch.nn as nn # Define the model class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.fc1 = nn.Linear(5, 8) self.fc2 = nn.Linear(8, 4 [instruction] | Use PyTorch to write a function that predicts a class label based on five numerical features. [input] | X = [[0.1, 0.2, 0.3, 0.4, 0.5],[0.2, 0.3, 0.4, 0.5, 0.6]]
[output] | def filter_fruits(items): """This function takes a list of grocery items and generates a list containing only the fruits.""" fruits = [] for item in items: if item in ["apple", "banana", "grapes"]: fruits.append(item) return fruits if __name__ == '__main__': [instruction] | Given a list of grocery items, write a code to generate 1 list containing only the fruits in the list. [input] | items =["apple","banana","grapes","rice","onion"]
[output] | def is_prime(n): """This function will check if a number is a prime number or not.""" # Corner case if n <= 1: return False # Check from 2 to n-1 for i in range(2,n): if n % i == 0: return False return True if __name__ == '__main__': for [instruction] | Generate a function to identify prime numbers between 0 and n. [input] |