[output] | public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Get reference to button Button switchModeButton = (Button) findViewById(R.id.s [instruction] | Create an Android app with a button to switch between light and night mode. [input] |
[output] | const formatTime = (secs) => { let d = new Date(0); d.setSeconds(secs); let hh = d.getHours().toString().padStart(2, '0'); let mm = d.getMinutes().toString().padStart(2, '0'); let ss = d.getSeconds().toString().padStart(2, '0'); return `${hh}:${mm}:${ss}`; } [instruction] | Write a JavaScript function to format a given number to HH:MM:SS. [input] | // Given a number of seconds input let secs = 85
[output] | <body style="margin: 0; padding: 0; font-family: sans-serif; box-sizing: border-box; font-size: 16px; line-height: 1.5; background-color: #f5f5f5; color: #222222;"> <h2>Hello World</h2> </body> [instruction] | Edit the following HTML to give a baseline styling to the body. [input] | <body> <h2>Hello World</h2> </body>
[output] | class MyClass: def __init__(self, given_list): self.given_list = given_list def check_equal_to_10(self): if len(self.given_list) == 0: return False for num in self.given_list: if num != 10: return False print("Endle [instruction] | Implement a Python class that prints a given given text when a certain condition is satisfied. [input] | Print a text "Endless fun" when the numbers given in a list equals to 10
[output] | CREATE TABLE Employee ( Id INT NOT NULL UNIQUE PRIMARY KEY, Name VARCHAR(50) NOT NULL, Age INT NOT NULL ); CREATE TABLE Department ( Id INT NOT NULL UNIQUE PRIMARY KEY, Name VARCHAR(50) NOT NULL ); CREATE TABLE Employee_Department ( EmployeeId INT NOT NULL UNIQUE, DepartmentId INT NO [instruction] | Create a SQL database containing three tables. [input] |
[output] | #!/bin/bash CMD="echo "The result is 120"" eval $CMD | grep -o "The result is.*" [instruction] | Generate a Bash script to grep a given line from the command output. [input] | grep the line "The result is" from the following command "echo "The result is 120""
[output] | let objKeyNames = Object.keys(obj); console.log(objKeyNames); // outputs ["name", "age", "job"] [instruction] | Generate a JavaScript code to get the key names of an object. [input] | key names of the following object let obj = {name: "John", age: 30, job: "teacher"};
[output] | SELECT DISTINCT data_type FROM products WHERE column_name = 'price'; [instruction] | Identify and display all the data types within the column 'price' in a table named 'products'. [input] |
[output] | num1 = int(input("Enter the first number: ")) num2 = int(input("Enter the second number: ")) # add two numbers sum = num1 + num2 # display the sum print("The sum of {0} and {1} is {2}".format(num1, num2, sum)) [instruction] | Create a basic Python script to accept two numbers from the user and print out the sum. [input] |
[output] | using System; public class Program { public static void Main() { Console.WriteLine(DateTime.Now.ToString()); } } [instruction] | Create a basic C# program to print out the current date and time. [input] |
[output] | SELECT e.name FROM employees e WHERE e.salary > (SELECT AVG(salary) FROM employees); [instruction] | Find and display all the employees who earn more than the average salary across all departments. [input] |
[output] | def countVowels(str): vowel = 0 for i in str: if i.lower() in ['a', 'e', 'i', 'o', 'u']: vowel += 1 return vowel # Driver code str = "Hello World" print("Number of vowels are:", countVowels(str)) [instruction] | Create a Python program to accept a string from the user and print out the number of vowels in the string. [input] | Hello World