Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Dividing by Zero in Python Crash Windows 98, et al?

Tags:

python

windows

I was told by a professor that dividing by zero or taking a negative square root in Python crashes if you do it in Windows 98.

This seems ridiculous since Python is an interpreted language, but I don't have a way to verify this, and Windows is notorious... Can anyone confirm or deny the claim? If so, does it have to do with the fact that Python is written in C? (And would C really crash the whole OS for division by zero!?)

like image 220
JeremyKun Avatar asked Feb 20 '12 23:02

JeremyKun


2 Answers

It should result in a ZeroDivisionError exception. I can't imagine why this would be different in Windows 98.

>>> 1/0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero

What a remarkable waste of time.

Under Win98 with Python 2.3.5

Python 2.3.5 (#62, Feb  8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface.  This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************

IDLE 1.0.5      
>>> import sys
>>> sys.getwindowsversion()
(4, 10, 67766446, 1, ' A ')
>>> sys.version_info
(2, 3, 5, 'final', 0)
>>> 1/0

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in -toplevel-
    1/0
ZeroDivisionError: integer division or modulo by zero
>>>
like image 128
gfortune Avatar answered Nov 03 '22 00:11

gfortune


Python 2.7.2 (Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Joke)] on win98
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> math.sqrt(-1) / 0
A fatal exception 0E has occurred at 0028:C0011E36 in VXD VMM(01) +
00010E36.  The current application will be terminated

* Press any key to terminate the current application.
* Press CTRL+ALT+DEL again to restart your computer.  You will
  lose any unsaved information in all applications

enter image description here


*disclaimer : Of course, I made that all up. I'm inclined to agree with tito on this one - a trolling professor is the most likely explanation!

░░░░░▄▄▄▄▀▀▀▀▀▀▀▀▄▄▄▄▄▄░░░░░░░
░░░░░█░░░░▒▒▒▒▒▒▒▒▒▒▒▒░░▀▀▄░░░░
░░░░█░░░▒▒▒▒▒▒░░░░░░░░▒▒▒░░█░░░
░░░█░░░░░░▄██▀▄▄░░░░░▄▄▄░░░░█░░
░▄▀▒▄▄▄▒░█▀▀▀▀▄▄█░░░██▄▄█░░░░█░
█░▒█▒▄░▀▄▄▄▀░░░░░░░░█░░░▒▒▒▒▒░█
█░▒█░█▀▄▄░░░░░█▀░░░░▀▄░░▄▀▀▀▄▒█
░█░▀▄░█▄░█▀▄▄░▀░▀▀░▄▄▀░░░░█░░█░
░░█░░░▀▄▀█▄▄░█▀▀▀▄▄▄▄▀▀█▀██░█░░
░░░█░░░░██░░▀█▄▄▄█▄▄█▄████░█░░░
░░░░█░░░░▀▀▄░█░░░█░█▀██████░█░░
░░░░░▀▄░░░░░▀▀▄▄▄█▄█▄█▄█▄▀░░█░░
░░░░░░░▀▄▄░▒▒▒▒░░░░░░░░░░▒░░░█░
░░░░░░░░░░▀▀▄▄░▒▒▒▒▒▒▒▒▒▒░░░░█░
░░░░░░░░░░░░░░▀▄▄▄▄▄░░░░░░░░█░░

like image 38
wim Avatar answered Nov 03 '22 01:11

wim