Modification of the code is necessary for learning. Numbers in the output are not clear to me !? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula gr√°tis
+ 8

Modification of the code is necessary for learning. Numbers in the output are not clear to me !?

https://code.sololearn.com/c03u82cyaR1X/?ref=app

3rd Apr 2018, 10:08 PM
Vuńćko/–í—É—á–ļ–ĺ/Vuchko
Vuńćko/–í—É—á–ļ–ĺ/Vuchko - avatar
1 Resposta
+ 2
try:, 'tries' to execute some code. If an exception occurs, the code is not executed, but instead the except: clause is executed. If no exception occurs, then the else clause is executed. 1 divided by zero gives a divide by zero exception, as 0 goes into 1 an infinite amount of times! Therefore the first and last bits of code, the try: and else: clauses are executed, but in the second bit of code, only the except: clause is executed.
3rd Apr 2018, 10:32 PM
Emma