- Find the Last Element of a Array or List
- Task: Write a function that returns the last element of a Array or List.
- Instructions: Do not use built-in functions like
list[-1]
. - Example:
- Input: [1, 2, 3, 4, 5]
- Output: 5
- Find the Kth Element of a Array or List
- Task: Write a function that returns the Kth element of a Array or List (counting from 0).
- Instructions: Avoid using Array or List indexing directly.
- Example:
- Input: ([1, 2, 3, 4, 5], 2)
- Output: 3
- Find the Length of a Array or List
- Task: Write a function that returns the length of a Array or List.
- Instructions: Do not use the built-in
len()
function. You must manually count the elements. - Example:
- Input: [1, 2, 3, 4, 5]
- Output: 5
- Reverse a Array or List
- Task: Write a function that reverses a Array or List.
- Instructions: Do not use slicing or the
reverse()
method. - Example:
- Input: [1, 2, 3, 4, 5]
- Output: [5, 4, 3, 2, 1]
- Check if a Array or List is Empty
- Task: Write a function that checks if a Array or List is empty.
- Instructions: Do not use
if not list:
or any built-in functions. - Example:
- Input: []
- Output: True
- Sum of a Array or List
- Task: Write a function that returns the sum of all elements in a Array or List.
- Instructions: Avoid using the
sum()
function. - Example:
- Input: [1, 2, 3, 4, 5]
- Output: 15
- Find the Maximum of a Array or List
- Task: Write a function that returns the maximum element of a Array or List.
- Instructions: Do not use the built-in
max()
function. - Example:
- Input: [1, 2, 3, 4, 5]
- Output: 5
- Find the Minimum of a Array or List
- Task: Write a function that returns the minimum element of a Array or List.
- Instructions: Do not use the built-in
min()
function. - Example:
- Input: [1, 2, 3, 4, 5]
- Output: 1
- Count Occurrences of an Element in a Array or List
- Task: Write a function that counts how many times a given element appears in a Array or List.
- Instructions: Do not use the
count()
method. - Example:
- Input: ([1, 2, 3, 1, 4, 1], 1)
- Output: 3
- Remove Duplicates from a Array or List
- Task: Write a function that removes duplicates from a Array or List.
- Instructions: Do not use the
set()
function or any built-in function. - Example:
- Input: [1, 2, 2, 3, 4, 4]
- Output: [1, 2, 3, 4]
- Check if an Element Exists in a Array or List
- Task: Write a function that checks if an element exists in a Array or List.
- Instructions: Do not use the
in
operator. - Example:
- Input: ([1, 2, 3, 4, 5], 3)
- Output: True
- Concatenate Two Array or Lists
- Task: Write a function that concatenates two Array or Lists.
- Instructions: Do not use the
+
operator for Array or Lists. - Example:
- Input: ([1, 2], [3, 4])
- Output: [1, 2, 3, 4]
- Find the Index of an Element in a Array or List
- Task: Write a function that returns the index of the first occurrence of an element in a Array or List.
- Instructions: Do not use the
index()
method. - Example:
- Input: ([1, 2, 3, 4], 3)
- Output: 2
- Flatten a Array or List of Array or Lists
- Task: Write a function that flattens a Array or List of Array or Lists into a single Array or List.
- Instructions: Avoid using Array or List comprehension or built-in functions like
extend()
. - Example:
- Input: [[1, 2], [3, 4], [5]]
- Output: [1, 2, 3, 4, 5]
- Zip Two Array or Lists
- Task: Write a function that zips two Array or Lists into a Array or List of tuples.
- Instructions: Do not use the built-in
zip()
function. - Example:
- Input: ([1, 2, 3], ['a', 'b', 'c'])
- Output: [(1, 'a'), (2, 'b'), (3, 'c')]
- Unzip a Array or List of Tuples
- Task: Write a function that unzips a Array or List of tuples into two Array or Lists.
- Instructions: Do not use the
zip()
function. - Example:
- Input: [(1, 'a'), (2, 'b'), (3, 'c')]
- Output: ([1, 2, 3], ['a', 'b', 'c'])
- Find the Intersection of Two Array or Lists
- Task: Write a function that returns the intersection of two Array or Lists.
- Instructions: Avoid using built-in functions like
intersection()
. - Example:
- Input: ([1, 2, 3], [2, 3, 4])
- Output: [2, 3]
- Find the Union of Two Array or Lists
- Task: Write a function that returns the union of two Array or Lists.
- Instructions: Do not use
set()
or any built-in function. - Example:
- Input: ([1, 2, 3], [2, 3, 4])
- Output: [1, 2, 3, 4]
- Find the Difference of Two Array or Lists
- Task: Write a function that returns the difference of two Array or Lists.
- Instructions: Do not use set operations.
- Example:
- Input: ([1, 2, 3], [2, 3, 4])
- Output: [1]
- Multiply All Elements of a Array or List
- Task: Write a function that multiplies all elements of a Array or List together.
- Instructions: Do not use the
reduce()
function. - Example:
- Input: [1, 2, 3, 4]
- Output: 24
- Find the Second Largest Element of a Array or List
- Task: Write a function that returns the second largest element in a Array or List.
- Instructions: Do not sort the Array or List.
- Example:
- Input: [1, 2, 3, 4, 5]
- Output: 4
- Merge Two Sorted Array or Lists
- Task: Write a function that merges two sorted Array or Lists into one sorted Array or List.
- Instructions: Avoid using the
sorted()
function orsort()
. - Example:
- Input: ([1, 3, 5], [2, 4, 6])
- Output: [1, 2, 3, 4, 5, 6]
- Check if a Array or List is Sorted
- Task: Write a function that checks if a Array or List is sorted in ascending order.
- Instructions: Do not use the
sort()
method orsorted()
. - Example:
- Input: [1, 2, 3, 4, 5]
- Output: True
- Find the Average of a Array or List
- Task: Write a function that finds the average of the elements in a Array or List.
- Instructions: Do not use the
sum()
orlen()
functions. - Example:
- Input: [1, 2, 3, 4, 5]
- Output: 3.0
- Check if a String is a Palindrome
- Task: Write a function that checks if a string is a palindrome.
- Instructions: Avoid using slicing or built-in functions like
reverse()
. - Example:
- Input: "madam"
Output: True
- Count Vowels in a String
- Task: Write a function that counts the number of vowels in a string.
- Instructions: Do not use the
count()
method. - Example:
- Input: "hello"
- Output: 2
- Remove Punctuation from a String
- Task: Write a function that removes punctuation from a string.
- Instructions: Do not use the
translate()
method. - Example:
- Input: "Hello, world!"
- Output: "Hello world"
- Check if Two Strings are Anagrams
- Task: Write a function that checks if two strings are anagrams.
- Instructions: Do not use sorting.
- Example:
- Input: ("Array or Listen", "silent")
- Output: True
- Reverse a String
- Task: Write a function that reverses a string.
- Instructions: Do not use slicing or the
reverse()
method. - Example:
- Input: "hello"
- Output: "olleh"
- Find the Number of Words in a String
- Task: Write a function that counts the number of words in a string.
- Instructions: Do not use the
split()
method. - Example:
- Input: "Hello world"
- Output: 2
- Find the GCD of Two Numbers
- Task: Write a function that finds the greatest common divisor (GCD) of two numbers.
- Instructions: Do not use the built-in
gcd()
function. - Example:
- Input: (12, 15)
- Output: 3
- Check if a Number is Prime
- Task: Write a function that checks if a number is prime.
- Instructions: Do not use any built-in prime-checking function.
- Example:
- Input: 7
- Output: True
- Calculate the Factorial of a Number
- Task: Write a function that calculates the factorial of a number.
- Instructions: Do not use the
math.factorial()
function. - Example:
- Input: 5
- Output: 120
- Find Fibonacci Sequence Up to Nth Term
- Task: Write a function that returns the Fibonacci sequence up to the Nth term.
- Instructions: Avoid using recursion or built-in functions.
- Example:
- Input: 5
- Output: [0, 1, 1, 2, 3]
- Calculate the Power of a Number
- Task: Write a function that calculates the power of a number.
- Instructions: Do not use the
**
operator orpow()
. - Example:
- Input: (2, 3)
- Output: 8
- Find the Sum of Digits in a Number
- Task: Write a function that returns the sum of the digits of a number.
- Instructions: Do not use string manipulation.
- Example:
- Input: 123
- Output: 6
- Convert Decimal to Binary
- Task: Write a function that converts a decimal number to binary.
- Instructions: Do not use the built-in
bin()
function. - Example:
- Input: 5
- Output: "101"
- Convert Binary to Decimal
- Task: Write a function that converts a binary number to decimal.
- Instructions: Do not use the built-in
int()
function. - Example:
- Input: "101"
- Output: 5
- Check if a Number is Armstrong
- Task: Write a function that checks if a number is an Armstrong number.
- Instructions: Do not use any built-in functions.
- Example:
- Input: 153
- Output: True
- Merge Two Dictionaries
- Task: Write a function that merges two dictionaries.
- Instructions: Avoid using
update()
. - Example:
- Input: ({'a': 1}, {'b': 2})
- Output: {'a': 1, 'b': 2}
- Count Keys in a Dictionary
- Task: Write a function that counts the number of keys in a dictionary.
- Instructions: Do not use the
len()
function. - Example:
- Input: {'a': 1, 'b': 2}
- Output: 2
- Find the Value of the Maximum Key in a Dictionary
- Task: Write a function that finds the key with the maximum value in a dictionary.
- Instructions: Do not use the
max()
function. - Example:
- Input: {'a': 10, 'b': 5}
- Output: 'a'
- Find the Common Keys Between Two Dictionaries
- Task: Write a function that returns the common keys between two dictionaries.
- Instructions: Do not use any built-in set methods.
- Example:
- Input: ({'a': 1, 'b': 2}, {'b': 3, 'c': 4})
- Output: ['b']
- Sum of Dictionary Values
- Task: Write a function that sums all the values of a dictionary.
- Instructions: Do not use the
sum()
function. - Example:
- Input: {'a': 1, 'b': 2}
- Output: 3
- Remove a Key from a Dictionary
- Task: Write a function that removes a key from a dictionary.
- Instructions: Do not use the
del
statement orpop()
method. - Example:
- Input: {'a': 1, 'b': 2}, 'a'
- Output: {'b': 2}
- Convert a Dictionary to a Array or List of Tuples
- Task: Write a function that converts a dictionary to a Array or List of tuples.
- Instructions: Do not use the
items()
method. - Example:
- Input: {'a': 1, 'b': 2}
- Output: [('a', 1), ('b', 2)]
- Create a Dictionary from Two Array or Lists
- Task: Write a function that creates a dictionary from two Array or Lists (one for keys and one for values).
- Instructions: Avoid using the
zip()
function. - Example:
- Input: ['a', 'b'], [1, 2]
- Output: {'a': 1, 'b': 2}
- Find the Sum of Odd Numbers in a Array or List
- Task: Write a function that returns the sum of all odd numbers in a Array or List.
- Instructions: Do not use any built-in functions or filtering techniques.
- Example:
- Input: [1, 2, 3, 4, 5]
- Output: 9
- Check if a Array or List is Symmetrical
- Task: Write a function that checks if a Array or List is symmetrical (same forward and backward).
- Instructions: Do not use slicing or built-in reverse methods.
- Example:
- Input: [1, 2, 3, 2, 1]
- Output: True
- Create a Simple Calculator
- Task: Write a simple calculator that takes two numbers and an operation (+, -, *, /) and performs the operation.
- Instructions: Do not use
eval()
or any similar functions. - Example:
- Input: (3, 4, '+')
- Output: 7