Aiffel Day 3
2195 ワード
LMS & Python master class day 3
What I've learned
Try - Except
Lambda expression
Class, Module, Pacakge
1. Try - Except
With the help of try-except and try-except-else, you can avoid many unknown problems that could arise from your code.
The try block is used to check some code for errors. The code inside the try block will execute when there is no error in the program.
Whereas the code inside the except block will execute whenever the program encounters some error in the preceding try block.
try:
# Some Code
except:
# Executed if error in the
# try block
else()
and finally()
are used also with try()
and except()
.Seems not too difficult but it's not the best way to handle all of the errors. There are plenty of other ways to do so.
Errors and Exceptions
Lambda expression
A lambda function is a small anonymous function. It can take any number of arguments, but can only have one expression. The form may look like
lambda argument(s): expression
.#Normal python function
def a_name(x):
return x+x
#Lambda function
lambda x: x+x
Lambda expressions are used for lots of different occasions but I'll get into that later.higher-order fucntions look this up
Class, Module, Package
Reference
この問題について(Aiffel Day 3), 我々は、より多くの情報をここで見つけました https://velog.io/@serena/Aiffel-day-3テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol