Porter interview question

Mostly sql queries and python code to print triangle