Write a Python program to reverse a given list without using the built-in reverse()
method.
Input: [1, 2, 3, 4]
Output: [4, 3, 2, 1]
Given a tuple of numbers, return the sum of all elements.
Input: (1, 2, 3, 4)
Output: 10
Write a function to remove all duplicate items from a list using a set.
Input: [1, 2, 2, 3, 4, 4, 5]
Output: [1, 2, 3, 4, 5]
Given a list of elements, return a dictionary with the frequency of each element.
Input: ['a', 'b', 'a', 'c', 'b', 'a']
Output: {'a': 3, 'b': 2, 'c': 1}
Given a nested dictionary, access the inner value safely.
Input:
data = {
"student": {
"name": "Alice",
"marks": {
"math": 95
}
}
}
Output: 95
Write a Python function that returns the common elements from two sets.
Input: set1 = {1, 2, 3}, set2 = {2, 3, 4}
Output: {2, 3}