Logo video2dn
  • Сохранить видео с ютуба
  • Категории
    • Музыка
    • Кино и Анимация
    • Автомобили
    • Животные
    • Спорт
    • Путешествия
    • Игры
    • Люди и Блоги
    • Юмор
    • Развлечения
    • Новости и Политика
    • Howto и Стиль
    • Diy своими руками
    • Образование
    • Наука и Технологии
    • Некоммерческие Организации
  • О сайте

Скачать или смотреть Exception Handling part 3

  • The Light
  • 2020-06-12
  • 76
Exception Handling part 3
  • ok logo

Скачать Exception Handling part 3 бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно Exception Handling part 3 или посмотреть видео с ютуба в максимальном доступном качестве.

Для скачивания выберите вариант из формы ниже:

  • Информация по загрузке:

Cкачать музыку Exception Handling part 3 бесплатно в формате MP3:

Если иконки загрузки не отобразились, ПОЖАЛУЙСТА, НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если у вас возникли трудности с загрузкой, пожалуйста, свяжитесь с нами по контактам, указанным в нижней части страницы.
Спасибо за использование сервиса video2dn.com

Описание к видео Exception Handling part 3

#if there is no exception(run time error)
try:
print("good morning")#st1
print("how are you")#st 2
print("Python")#st 3
except TypeError:
print("we can not convert str to int")#st4
finally:
print("statement5")
print("statement 6")

"""
output:
st1:good morning
st2:how are you
st3:Python
statement5
statement 6
"""

#if there is exception at st2
try:
print("good morning")#st1
print(10/0)#st 2 Exception raised here
print("Python")#st 3
except ZeroDivisionError:
print("zero division is not possible")#st4
finally:
print("statement5")
print("statement 6")

"""
output:
good morning
zero division is not possible
statement5
statement 6
"""
#if there is exception at st2 and Corresponding Exception block is not matched
try:
print("good morning")#st1
print(10/0)#st 2 Exception raised here
print("Python")#st 3
except TypeError: #Corresponding Exception block is not matched
print("zero division is not possible")#st4
finally:
print("statement5")
print("statement 6")

"""
good morning
statement5
Exception: Abnormal Termination
"""
#if there is exception at st4 at except block
try:
print("good morning")#st1
print("Statement 2")#st 2
print("st 3:Python")#st 3
except ZeroDivisionError: #Corresponding Exception block is not matched
print(2/0)#st4: Exception raised here
finally:
print("statement5")
print("statement 6")

"""
good morning
Statement 2
st 3:Python
statement5
statement 6
"""
#if there is exception at finally block
try:
print("good morning")#st1
print("Statement 2")#st 2
print("st 3:Python")#st 3
except ZeroDivisionError: #Corresponding Exception block is not matched
print("st4")#st4: Exception raised here
finally:
print(4/0)#statement 5: Exception raised here
print("statement 6")

"""
good morning
Statement 2
st 3:Python
Exception: Abnormal Termination
"""

Note:
Within try block if anywhere exception is raised then remaining code within the try block, are not executed, despite we handled the exception.

So we have to keep only doubtful code in side the try block.

If any statement which is not part of try block raises an exception then it is always an abnormal termination.

Multiple try with except blocks:

Based on our code we can go for more than one exception block because there is chance to raise different exception..so corresponding exception blocks must be used.

Syntax:
try:
Statement(s)
except XXXError:
Statement(s)
except XXXXError:
…..


#Multiple except blocks
try:
a=int(input("enter a value:"))#8
b=int(input("enter b value:"))#two
print(a/b)#8/two..raised Exception
except(ZeroDivisionError,ValueError):
print("please provide int only but not zero")
##except ZeroDivisionError:#Corresponding excepiton is not matched
print("Don't enter zero bcoz 0 division is not possible")
##except ValueError:
print("enter only integer values")

"""
Case1:
enter a value:8
enter b value:4
2.0
Case2:
enter a value:8
enter b value:0
zero division is not possible
Case 3:
enter a value:8
enter b value:two
enter only integer values
"""

Single except block with multiple exception names:
We can write a single exception block than can handle multiple different types of exceptions.

Example:
except(ValueError,ZeroDivisionError,…..):

#Default exception block
try:
a=int(input("enter a value:"))#8
b=int(input("enter b value:"))#two
print(a/b)#8/two..raised Exception
except ZeroDivisionError:
print("zero is not divisible")
except:
print("Default exception block")
"""
enter a value:10
enter b value:2
5.0

enter a value:6
enter b value:0
zero is not divisible

enter a value:10
enter b value:four
Default exception block
"""

We can use default exception block to handle any type of exceptions.

#Default exception block
try:
a=int(input("enter a value:"))#8
b=int(input("enter b value:"))#two
print(a/b)#8/two..raised Exception
#except ZeroDivisionError:
print("zero is not divisible")
except:
print("Default exception block")
"""
nter a value:10
enter b value:0
Default exception block

enter a value:5
enter b value:one
Default exception block

"""
Syntax:

try:
….
except:
Any msg
Default exception should be last, otherwise it leads to error

Example:
Try:
…
Except …. #Error
Except ZeroDivisionError:
….
Valid example is:
except ZeroDivisionError:
print("zero is not divisible")
except:#default exception block
print("Default exception block")

Комментарии

Информация по комментариям в разработке

Похожие видео

  • О нас
  • Контакты
  • Отказ от ответственности - Disclaimer
  • Условия использования сайта - TOS
  • Политика конфиденциальности

video2dn Copyright © 2023 - 2025

Контакты для правообладателей [email protected]