Steve B Song
1 min readApr 29, 2021

--

JavaScript To Python

If you are thinking about switching from JavaScript to Python, you are reading the right blog! Bear with me for next 2 minutes. I am challenging myself to switch from JS to Python for algorithm questions for two reasons. First, I am currently using algoexpert.io and the videos for solutions are python based. And, I think Python has more community in algorithm. Second, I want to learn new language. Yeah…simply out of curiosity.

Week 1

Day 1

Well, during the first week, I just tried a few basic codes to familiarize myself with Python.

To befriend with Python, begin with easy questions. I know you probably can do it in JS in one second. Don’t forget you are are learning Python. Don’t be arrogant and stay humble!

Find max value in a given arraysolution 1)array = [1, 16, 4, 7, 9]def find_max_num(array):
for num in array:
for compare_num in array:
if num < compare_num:
break
else:
return num
solution 2)def find_max_num(array):
max_num = array[0]
for num in array:
if num > max_num:
max_num = num
return max_num

Solution 2 is better in Time complexity.

--

--