Intermediate Level

Calculate the multiplication and sum of two numbers


a, b = map(int, input("Enter Two Numbers: ").split())
def printSumMulti(num1, num2):
print(f"Sum is: {num1 + num2}")
print(f"Multiplication is {num1*num2}")
printSumMulti(a,b)

Print the sum of the current number and the previous number in range


ur_input = int(input("Enter Some Number: "))
def currPrevSum(num):
for n in range(num+1):
print(f"Current Number is {n}, Previous Number is {n-1} and There sum is: {n+(n-1)}")
currPrevSum(ur_input)

Print characters from a string that are present at an even index number


ur_str = input("Enter Some String: ")
def getEvenIdxChar(str_):
for idx, chr in enumerate(str_):
if idx%2==0:
print(f"Char {chr}, Present at Index of {idx}")
getEvenIdxChar(ur_str)

Remove first n characters from a string


ur_str = input("Enter Some String: ")
chr_ = int(input("Char to remove:"))
def removeChars(str_, n):
return str_[n:]
res = removeChars(ur_str, chr_)

Check if the first and last number of a list is the same


list1 = [10,20,30,40,50]
list2 = [101,102,103,104,101]
def checkFistLast(list_):
return list_[0] == list_[-1]
res = checkFistLast(list2)