Microsoft interview question

Write how tfidf works and try to implement it using python?