← 목록

Synth · CodeAlpaca일부

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

[output] | highest = 0 highest_phone = None for number in phone_numbers: number_digits = ''.join(filter(str.isdigit, number)) if int(number_digits) > highest: highest_phone = number highest = int(number_digits) print(f"The phone number with highest digits is {highest_phone}.") [instruction] | Given a list of phone numbers, write a code to find the one with the highest digits. [input] | phone_numbers = ["+440123456789", "+45987654321", "+441234567890"]

[output] | SELECT MAX(price) FROM products; [instruction] | Formulate an SQL query to find the most expensive product in a given database. [input] |

[output] | def replace_letter_A(string): string = string.replace('A', 'Z') return string print(replace_letter_A(string)) [instruction] | Construct a code to replace all instances of 'A' with 'Z' in a given string. [input] | string = "This is a string A with multiple A's"

[output] | max_num = max([num for num in numbers]) print(max_num) [instruction] | Rewrite the following code using List Comprehension to print the maximum number from a list of integers. [input] | numbers = [3, 2, 5, 4, 6]

[output] | true [instruction] | Write a code to detect if a string is a palindrome or not. Output true if it is a palindrome, output false if it is not. [input] | "racecar"

[output] | return string[string.length-1] [instruction] | Write a code to accept a string and return the last character. [input] | "Hello World"

[output] | assert email.lower() == email, "Email address should be all lowercase" [instruction] | You are given the following code. Write an 'assert' statement that checks if the email address is all lowercase or not. [input] | email = "THIS_IS_TEST@EMAIL.COM"

[output] | if b != 0: output = a/b assert output.is_integer(), "Result of division is not an integer" [instruction] | Edit the following code to check if the resulting output of the division is an integer. [input] | a = 15 b = 4 output = a/b

[output] | class SortNum(): def selection_sort(self, list): for i in range(len(list)): min_idx = i for j in range(i + 1, len(list)): if list[min_idx] > list[j]: min_idx = j list[i], list[min_idx] = list[min_idx], list[i] [instruction] | Create a class in Python that implements an algorithm for sorting a list of numbers. [input] | list = [3, 2, 5, 1, 4]

[output] | total = 0 for row in array: for element in row: total += element print(total) [instruction] | Sum the numbers in the following array and print the result. [input] | array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

[output] | cars = [] cars.append(Car("Ford", "Mustang", 2019)) cars.append(Car("Toyota", "Corolla", 2020)) for car in cars: print(car.__dict__) [instruction] | Create a list of objects of the following class and print the objects as dictionary. [input] | class Car: def __init__(self, make, model, year): self.make = make self.model = model self.year = year

[output] | # Create a Django view to handle GET requests. def product_list_view(request): # Get the list of products products = Product.objects.all() # Return the list of products context = { 'products': products } return render(request, 'product_list.html', context) [instruction] | Create a Django view to handle GET requests for displaying a list of products. [input] | appname/models.py class Product(models.Model): name = models.CharField(max_length=200) description = models.TextField() price = models.DecimalField(max_digits=10, decimal_places=2)

[output] | def first_occurrence(arr, element): for i in range(len(arr)): if arr[i] == element: return i return -1 [instruction] | Return the index of the first occurrence of an element in the given array. [input] | arr = [2, 3, 3, 1, 5, 2]

[output] | for element in list: if element % 5 == 0: print(element) break [instruction] | Print the first element that occurs in the list and is divisible by 5. [input] | list = [2, 3, 5, 10, 15, 30]

[output] | SELECT name, salary FROM Employees WHERE salary > 80000; [instruction] | Write a MySQL query to find the names and salaries of all employees who have salaries greater than 80,000. [input] |

[output] | .show-on-hover { display: none; &:hover { display: block; } } [instruction] | Write a CSS class to create a link which shows on hover. [input] |

[output] | SELECT * FROM Table_Name WHERE column_name IS NULL; [instruction] | Create a SQL query to select all columns in a table but exclude the contents of a specific column. [input] |

[output] | .submit { /* CSS properties here */ } [instruction] | Write a CSS selector to style all buttons with the class 'submit'. [input] |

[output] | Using AWS Amazon EC2 and S3 services, you can host a website. You can use EC2 to set up a web server, and S3 can be used to store static website content such as HTML, CSS, and images. [instruction] | Create an AWS service to host a website. [input] |

[output] | public static void armstrongInRange(int lower, int upper) { int num, originalNum, remainder, n = 0; // Calculates the number of digits a number has for(originalNum = lower + 1; originalNum < upper; originalNum++) { num = originalNum; while(num != 0) [instruction] | Create a Java program to print out Armstrong numbers in a given range. [input] |

[output] | 7 [instruction] | You need to program a function to calculate the dot product of two arrays. [input] | array1=[1, 2, 3] array2=[-1, 0, 4]

[output] | [2, 3, 4, 5] [instruction] | You need to write a function to remove all the elements with a given value from a given array. [input] | array1=[1, 1, 2, 3, 4, 5, 1] value=1

[output] | elephant [instruction] | You need to write a program that takes a list of words as an input and returns the longest word in the list. [input] | word_list=["cat", "dog", "elephant", "ants"]

[output] | true [instruction] | You need to write a program that takes a given string and checks if it is a valid IP address. [input] | string1="255.255.0.10"

[output] | 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47 [instruction] | You need to write a program to print out the prime numbers between a given range of numbers. [input] | start=1 end=50

[output] | [1, 2, 4, 5] [instruction] | You need to write a program to delete a given node from a singly linked list. [input] | head = [1, 2, 3, 4, 5] node_data = 3

[output] | y = 17 [instruction] | Execute this line of code and tell me what is the value of `y`? [input] | int x = 5; int y = 3*x+2;

[output] | You are trying to print the numbers 0 to 4 (inclusive) by using a while loop. [instruction] | What am I trying to do with this code? [input] | i = 0 while i < 5: print(i) i += 1

[output] | The variable str1 is not updated and remains as 'This is a string' when you add a suffix to str2. This means that the values of str1 and str2 are no longer the same. [instruction] | What is wrong with this code? [input] | str1 = 'This is a string' str2 = str1 str2 += ' with a suffix'

[output] | import random def generate_random(): return random.randint(0,100) [instruction] | What should I add in this function to generate a random number? [input] | def generate_random(): # Your code here

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