A safe quotient
Task
The program reads two whole numbers (each on its own line) and prints their quotient - the result of the / operator.
- If an input is not a whole number, it prints
Neplatný vstup.(invalid input). - If the divisor is zero, it prints
Delenie nulou.(division by zero).
Handle it with try and except blocks - no if.
Examples
Input
7 2
Expected output
3.5
Input
x 2
Expected output
Neplatný vstup.
Input
5 0
Expected output
Delenie nulou.
Rules
Handle the errors with
tryandexcept- noif.
After you submit, 5 hidden tests will also check your solution: division without remainder, a decimal number in the input, zero divided by a number, a bad second input, negative numbers.
Python starts the first time you run code.
Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.
Input (stdin)
Each line = one call to input().
Output
Hints
Try it yourself first. Each hint reveals a little more - and lowers the reward a little.
Signed out, hints are free - but no XP is awarded either.
Solution
The solution unlocks after the last hint.