← 목록

Synth · CodeAlpaca일부

총 20,022개 · 페이지 487/668
🔀 랜덤
불러오는 중…

[output] | x = [] [instruction] | Change the last line of the code to assign a list value to the variable x. [input] | x = None

[output] | print(*L[::-1]) [instruction] | Write a one-liner to print the elements from list L in reverse order. [input] | L = ["apple", "pear", "banana"]

[output] | integer [instruction] | What data type does the output of this Python code have? [input] | x = 5

[output] | x = "hello world" [instruction] | Change the code to make it a valid Python program. [input] | x = "hello world

[output] | T[2] [instruction] | How can you access the third element of a tuple T? [input] |

[output] | print(x + 1) [instruction] | Change the code to make it an Expression Statement in Python [input] | x + 1

[output] | The command for cloning a GitHub repository is `git clone <repository-url>`. [instruction] | What is the command for cloning a GitHub repository? [input] |

[output] | The output of the code snippet is 22, since the value of x will be incremented twice, from 7 to 16 and then again from 16 to 22. [instruction] | Determine the output of this code snippet in C++: int x = 7; x = x + x + 2; [input] |

[output] | d = { 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: ' [instruction] | Create a dictionary where the numbers 1 to 100 are the keys and the strings "one" to "one hundred" are the values. [input] |

[output] | for i in range(10, 0, -1): print(i) [instruction] | Rewrite the following code so that the loop runs in reverse (decreases rather than increases). [input] | for i in range(0, 10): print(i)

[output] | def count_words(str): """Counts how many words are in a string. Parameters: str (str): string to be counted """ return len(str.split()) if __name__ == '__main__': string = "Hello world!" print(count_words(string)) [instruction] | Count how many words are in a string and output the count. [input] | string = "Hello world!"

[output] | def is_palindrome(str): """Checks if a given string is a palindrome. Parameters: str (str): string to be tested """ str = str.lower() return str[::-1] == str if __name__ == '__main__': string = "racecar" print(is_palindrome(string)) [instruction] | Create a function to output true if the given string is a palindrome, otherwise output false. [input] | string = "racecar"

[output] | date = int(input("Enter the date: ")) month = int(input("Enter the month: ")) [instruction] | Replace the comments in the code with the proper Python code. [input] | #TODO: get the date from the user #TODO: get the month from the user

[output] | def word_count(str): """Counts the number of different words in a string of unlimited length. Parameters: str (str): string to be counted """ words = str.split() return len(set(words)) if __name__ == '__main__': string = "This is a long sentence about nothing." [instruction] | Find the number of different words in a string of unlimited length. [input] | string = "This is a long sentence about nothing."

[output] | def is_digits(str): """Checks if a string contains only digits. Parameters: str (str): string to be tested """ return str.isdigit() if __name__ == '__main__': string = "1234567890" print(is_digits(string)) [instruction] | Write a code to check if a string contains only digits and output true or false. [input] | string = "1234567890"

[output] | def first_last_words(arr): """Gets the first and last word from each string. Parameters: arr (list): array of strings """ result = [] for string in arr: words = string.split() result.append((words[0], words[-1])) return result if __name__ == '__main_ [instruction] | Create a function that takes in an array of strings and outputs an array of tuples of the first and last word in each string. [input] | array = ["Hello World", "Foo Bar", "Goodbye Moon"]

[output] | <!DOCTYPE html> <html> <head> <title>Date Page</title> </head> <body> <p> <?php echo "Current date: " . date("d-m-Y"); ?> </p> </body> </html> [instruction] | Create an HTML webpage which when opened displays the current date in a paragraph. [input] |

[output] | SELECT TOP 3 name, salary FROM employees ORDER BY salary DESC; [instruction] | Write a SQL query to find the top 3 highest paying employee’s name and salary. [input] |

[output] | function coinFlip(){ let flipResult = Math.floor(Math.random() * 2); if (flipResult == 0){ return "Heads"; } else { return "Tails"; } } let result = coinFlip(); console.log(result); [instruction] | Create a script in JavaScript for flipping a coin. [input] |

[output] | SELECT COUNT(*) FROM employees WHERE salary > 50000; [instruction] | Write an SQL query to find the number of employees working in a company with a salary over 50000. [input] |

[output] | SELECT name, age FROM employees WHERE age > 40; [instruction] | Write a SQL query that finds the names and ages of employees who are older than 40 years. [input] |

[output] | # Initializing list list_of_numbers = [2, 4, 32, 41, 19] # Finding the highest number max_number = max(list_of_numbers) # Printing the result print(max_number) # Output: 41 [instruction] | Create a Python program that finds the highest number in a list of numbers. [input] | [2, 4, 32, 41, 19]

[output] | public class CubeVolume { public static void main(String[] args) { double sideLenght = 10; double volume; volume = sideLenght * sideLenght * sideLenght; System.out.println("Volume of a cube with side lenght "+ sideLenght +" is: " + volume); } } [instruction] | Create a Java program to compute the volume of a cube. [input] |

[output] | string search_term = "coffee shop"; list results = requests.get("https://api.example.com/search?term="+search_term).json() print(results) [instruction] | Replace the placeholder with actual API calls to execute the following code. [input] | string search_term = "coffee shop"; list results = API_call(search_term) print(results)

[output] | import asyncio async def myfunc(): print("I'm in a coroutine") loop = asyncio.get_event_loop() try: loop.run_until_complete(myfunc()) finally: loop.close() [instruction] | Create an asyncio event loop and execute a coroutine. [input] |

[output] | SELECT * FROM customer WHERE customer_name = 'John'; [instruction] | Write a query in SQL that returns all customers with the name "John". [input] | No input

[output] | class Button extends React.Component { handleClick = () => { console.log('Button was clicked!') } render() { return ( <button onClick={this.handleClick}> Click Me! </button> ) } } [instruction] | Use a framework like React to create a button component that fires an event when clicked. [input] |

[output] | def combinations_with_sum(n, m): for i in range(1, m): for j in range(i, m): if i + j == n: print(i, '+', j, '=', n) [instruction] | Create a function in Python that takes two integers N and M and prints out all possible combinations of numbers that add up to N and are at most M. [input] | N=8, M=3

[output] | class Paragraph extends React.Component { render() { return <p>{this.props.text}</p> } } [instruction] | Create a React class component that renders a paragraph of text from props. [input] |

[output] | import numpy as np A = np.array([[1,2], [3,4]]) B = np.array([[5,6], [7,8]]) C = np.matmul(A,B) print(C) [instruction] | Multiply two input matrices using numpy. [input] | matrix A: [[1,2], [3,4]] matrix B: [[5,6], [7,8]]

← → 방향키로 페이지 이동 · 숫자 입력 후 Enter로 점프