Python - The easy way

Python - The easy way

Hello world, how y'll are doing?

This is my first issue of this newsletter, I will be telling you some good concepts in as short as possible. You wanna subscribe? Get a free cheatsheet from adicode.ml/gumroad and you will be subscribed.

images.jpg

1. Map Function

Map takes a function and a collection of items. It makes a new, empty collection, runs the function on each item in the original collection and inserts each return value into the new collection.

image.png

2. Lambda Function

The idea of lambda function is to evaluate expressions easily. The parameters of the lambda are defined to the left of the colon. The function body is defined to the right of the colon.

image.png

3. Complex Numbers

People dont usually focus on this topic, but python cmath has a variety of functions for this topic as well.

  • If we want to write 2+3i as complex number in python, it would be written as 2+3j

  • You can also define complex numbers using the complex() function

  • We can also use “a.real” and “a.imag” to filter equation

image.png

4. Try.....Except.......Finally

The try block is used to check some code for errors. Whereas the code inside the except block will execute whenever the program encounters some error in the try block. No matter what is exception, code inside finally is always executed.

image.png

Thats it from my side for this week’s newsletter. Meet you in next wednesday. Can’t wait till next week? Follow me on twitter where I post these stuff daily.

Did you find this article valuable?

Support Aditya Tiwari by becoming a sponsor. Any amount is appreciated!