Aiffel Day 3
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
- Class: templates for creating objects, contain variables and functions which define the class objects
- Module: python programs that can be imported into another python program, importing a module enables the usage of the module's functions and variables into another program.
You can download packages from here.
Author And Source
이 문제에 관하여(Aiffel Day 3), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@serena/Aiffel-day-3저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)