<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>divide by zero error in python Archives -</title>
	<atom:link href="https://mitindia.in/tag/divide-by-zero-error-in-python/feed/" rel="self" type="application/rss+xml" />
	<link>https://mitindia.in/tag/divide-by-zero-error-in-python/</link>
	<description></description>
	<lastBuildDate>Thu, 31 Oct 2019 07:43:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://mitindia.in/wp-content/uploads/2023/03/cropped-android-chrome-512x512-1-32x32.png</url>
	<title>divide by zero error in python Archives -</title>
	<link>https://mitindia.in/tag/divide-by-zero-error-in-python/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Exception Handling in Python</title>
		<link>https://mitindia.in/exception-handling-in-python/</link>
		
		<dc:creator><![CDATA[SKB]]></dc:creator>
		<pubDate>Thu, 31 Oct 2019 07:43:05 +0000</pubDate>
				<category><![CDATA[Artificial Intelligence]]></category>
		<category><![CDATA[Machine Learning]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[divide by zero error in python]]></category>
		<category><![CDATA[exception handling in python]]></category>
		<category><![CDATA[file not found error in python]]></category>
		<guid isPermaLink="false">http://www.mitindia.in/?p=1010</guid>

					<description><![CDATA[<p>Python Exception Handling An exception is a problem that arises during the execution of a program. An exception can occur for many different reasons, including the following: A user has entered invalid data. A file that needs to be opened cannot be found. A network connection has been lost in the middle of communications etc. [&#8230;]</p>
<p>The post <a href="https://mitindia.in/exception-handling-in-python/">Exception Handling in Python</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1><span style="color: #993300;">Python Exception Handling</span></h1>
<p>An exception is a problem that arises during the execution of a program. An exception can occur for many different reasons, including the following:</p>
<p>A user has entered invalid data.<br />
A file that needs to be opened cannot be found.<br />
A network connection has been lost in the middle of communications etc.</p>
<h2><strong>Programs on Exception Handling in Python </strong></h2>
<div><strong><span style="color: #ff0000;">#Divide by Zero Error using Python</span></strong></div>
<div>try:</div>
<div>a=int(input(&#8220;Enter num1:&#8221;))</div>
<div>b=int(input(&#8220;Enter num2:&#8221;))</div>
<div>c=a/b</div>
<div>print(c)</div>
<div>except Exception:</div>
<div>print(&#8216;Divide by ZERO Error&#8217;)</div>
<div>else:</div>
<div>print(&#8216;Done!&#8217;)</div>
<div></div>
<blockquote>
<div><strong><span style="color: #0000ff;">OUTPUT:</span></strong></div>
<div>Enter num1:2</div>
<div>Enter num2:0</div>
<div>Divide by ZERO Error</div>
</blockquote>
<div></div>
<div></div>
<div><strong><span style="color: #ff0000;">#Array Index Error using Python</span></strong></div>
<div>a=[1,2,3]</div>
<div>try:</div>
<div>print(a[3])</div>
<div>except IndexError:</div>
<div>print(&#8216;Invalid index&#8217;)</div>
<div></div>
<blockquote>
<div><strong><span style="color: #0000ff;">OUTPUT:</span></strong></div>
<div>Invalid index</div>
</blockquote>
<div></div>
<div><span style="color: #ff0000;"><strong># File not found error &#8211; python exception</strong></span></div>
<div>try:</div>
<div>    file= open(&#8220;D:/Test.txt&#8221;,&#8221;r&#8221;)</div>
<div>except IOError:</div>
<div>    print(&#8220;File not found&#8221;)</div>
<div>else:</div>
<div>    print(&#8220;The file opened successfully&#8221;)</div>
<div>    file.close()</div>
<div></div>
<blockquote>
<div><span style="color: #0000ff;"><strong>OUTPUT:</strong></span></div>
<div>The file opened successfully</div>
</blockquote>
<div></div>
<div><strong><span style="color: #ff0000;">#Raise error using Python</span></strong></div>
<div>try:</div>
<div>    age = int(input(&#8220;Enter your age:&#8221;))</div>
<div>    if age&lt;18:</div>
<div>        raise ValueError;</div>
<div>    else:</div>
<div>        print(&#8220;Eligible for vote&#8221;)</div>
<div>except ValueError:</div>
<div>    print(&#8220;Not Eligible for vote&#8221;)</div>
<div></div>
<blockquote>
<div><span style="color: #0000ff;"><strong>OUTPUT:</strong></span></div>
<div>Enter your age:18</div>
<div>Eligible for vote</div>
</blockquote>
<div></div>
<div><strong><span style="color: #ff0000;">#Arithmetic Exception using Python</span></strong></div>
<div>try:</div>
<div>    a = int(input(&#8220;Enter a:&#8221;))</div>
<div>    b = int(input(&#8220;Enter b:&#8221;))</div>
<div>    if b is 0:</div>
<div>        raise ArithmeticError;</div>
<div>    else:</div>
<div>        print(&#8220;a/b = &#8220;,a/b)</div>
<div>except ArithmeticError:</div>
<div>    print(&#8220;Second number should be non-zero&#8221;)</div>
<div></div>
<blockquote>
<div><span style="color: #0000ff;"><strong>OUTPUT:</strong></span></div>
<div>Enter a:2</div>
<div>Enter b:0</div>
<div>Second number should be non-zero</div>
</blockquote>
<div><a href="https://www.mitindia.in/object-oriented-programming-with-python/" target="_blank" rel="noopener">Object-oriented-programming-with-python</a></div>
<div><a href="https://www.mitindia.in/collections-in-python/" target="_blank" rel="noopener">collections-in-python</a></div>
<div><a href="https://www.mitindia.in/built-in-and-user-defined-functions-in-python/" target="_blank" rel="noopener">built-in-and-user-defined-functions-in-python</a></div>
<div></div>
<p><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fmitindia.in%2Fexception-handling-in-python%2F&amp;linkname=Exception%20Handling%20in%20Python" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fmitindia.in%2Fexception-handling-in-python%2F&amp;linkname=Exception%20Handling%20in%20Python" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fmitindia.in%2Fexception-handling-in-python%2F&#038;title=Exception%20Handling%20in%20Python" data-a2a-url="https://mitindia.in/exception-handling-in-python/" data-a2a-title="Exception Handling in Python"><img src="https://static.addtoany.com/buttons/favicon.png" alt="Share"></a></p><p>The post <a href="https://mitindia.in/exception-handling-in-python/">Exception Handling in Python</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
