Error EliminatorQuestions
Error EliminatorQuestions
Questions
1) Def is_even(n):
If n % 2 = 0:
Return True
Else:
Return False
# Example usage:
Answer
def is_even(n):
return True
else:
return False
# Example usage:
2) #include <stdio.h>
#include <string.h>
Int n = strlen(str);
Str[n – i] = temp;
Int main() {
Reverse_string(str);
Return 0;
Answer
#include <stdio.h>
#include <string.h>
int n = strlen(str);
int main() {
reverse_string(str);
return 0;
}
3) Def fibonacci(n):
If n <= 0:
Return []
Elif n == 1:
Return [0]
Elif n == 2:
Return [0, 1]
Fib_sequence = [0, 1]
Return fib_sequence
# Example usage:
Answer
Def fibonacci(n):
If n <= 0:
Return []
Elif n == 1:
Return [0]
Elif n == 2:
Return [0, 1]
Fib_sequence = [0, 1]
# Example usage:
4) #include <stdio.h>
#include <limits.h>
Max_so_far = max_ending_here;
If (max_ending_here < 0)
Return max_so_far;
Int main() {
Return 0;
}
Answer
#include <stdio.h>
#include <limits.h>
Max_so_far = max_ending_here;
If (max_ending_here < 0)
Return max_so_far;
Int main() {
Return 0;
5) def square(n):
return n * n + n # Error here
# Example usage:
print(square(3)) # Output should be: 9
Answer
Def square(n):
# Example usage:
Print(square(3)) # Output: 9
6) #include <stdio.h>
Int factorial(int n) {
If (n == 0) return 1;
Int main() {
Int n = 5;
Return 0;
Answer
#include <stdio.h>
Int factorial(int n) {
If (n == 0) return 1;
}
Int main() {
Int n = 5;
Return 0;
7) Def is_palindrome(s):
Return s == s[::-1]
# Example usage:
Answer
Def is_palindrome(s):
Return s == s[::-1]
# Example usage:
8) #include <stdio.h>
If (r >= l) {
Int mid = l + (r – l) / 2;
If (arr[mid] == x)
Return mid;
If (arr[mid] > x)
Return binarySearch(arr, l, mid – 1, x);
Return -1;
Int main() {
Int x = 10;
: printf(“Element is present at index %d\n”, result); // Output should be: Element is present at
index 3
Return 0;
Answer
#include <stdio.h>
If (r >= l) {
Int mid = l + (r – l) / 2;
If (arr[mid] == x)
Return mid;
If (arr[mid] > x)
Return -1;
Int main() {
Int x = 10;
Return 0;
Merged_list = []
I, j = 0, 0
Merged_list.append(list1[i])
I += 1
Else:
Merged_list.append(list2[j])
J += 1
Merged_list.append(list1[i])
I += 1
Merged_list.append(list2[j])
J += 1
Return merged_list
# Example usage:
Answer
Merged_list = []
I, j = 0, 0
Merged_list.append(list1[i])
I += 1
Else:
Merged_list.append(list2[j])
J += 1
Merged_list.append(list1[i])
I += 1
Merged_list.append(list2[j])
J += 1
Return merged_list
# Example usage: