Coding Test Stuff

on Oct. 4, 2022, 7:35 p.m.

fibonacci series - a series of numbers in which each number is a the sum of the two preceding numbers.


fibo = [0,1]
_ = [fibo.append(fibo[-2]+fibo[-1]) for i in range(5)]
print(fibo)

Check palindrome of string a palindrome is a number or string that looks the when it gets reversed


text = 'level'
ispalindrome = text == text[::-1]
print(ispalindrome)

Transpose of a matrix


a = [
[1,2,3],
[4,5,6],
[7,8,9]
]
transpose = [list(i) for i in zip(*a)]
print(transpose)

Type casing a list


list(map(int, ['1','2','3']))
list(map(float, [1,2,3]))
[float(i) for i in [1,2,3]]