Exception Handling in Python

Опубликовано: 26 Сентябрь 2021
на канале: Nuruzzaman Faruqui
314
4

In case of any error occurs, Python interpreter stops the program execution and generate an error message. Using ‘try except’ block, we can prevent the program execution interruption by avoiding the error moving on to a designated part of the program. This approach is called exception handling. In this lesson, we will learn how to handles error in Python in ‘try error’ blocks.

The Python code used in this lesson:

try:
celsius = int(input("Temperature in Celsius: "))
fahrenheit = (celsius * (9/5)) + 32
print(fahrenheit)
print(f"F to C ratio (F/C): {fahrenheit/celsius}")
except ValueError:
print('Invalid input')
except ZeroDivisionError:
print('Celsius cannot be 0')

‘You are free to copy, edit, use and distribute this code without crediting the author. Enjoy copyright-free content.’ – Nuruzzaman Faruqui.


На этой странице сайта вы можете посмотреть видео онлайн Exception Handling in Python длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Nuruzzaman Faruqui 26 Сентябрь 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 314 раз и оно понравилось 4 зрителям. Приятного просмотра!