Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Course on Internet of Things Exercises Session 1: | ||||||||
Line: 26 to 26 | ||||||||
| ||||||||
Added: | ||||||||
> > | https://afnog.iotworkshop.africa/pub/IoT_Course_English/REPLAndStandardPythonProgramming/calculatorV1.py.txt | |||||||
Improve this program asking the user to enter 2 real numbers (floats) separated by a space. This is how it should look like:
| ||||||||
Line: 36 to 38 | ||||||||
when the user mistypes and enters something that is not a real number, can you capture the error and simply ask the user to repeat his input, until you get 2 correct floating point numbers? | ||||||||
Added: | ||||||||
> > | https://afnog.iotworkshop.africa/pub/IoT_Course_English/REPLAndStandardPythonProgramming/calculatorV2.py.txt | |||||||
Bonus points: Writing a parser for user input is rather easy if the numbers and operator are separated by spaces (have a look at the split method of strings). It is quite a bit more tricky if you allow entering calculations without spaces between the operands and the operator. Can you write a parser accomplishing this?
Try your parser on this input: | ||||||||
Line: 49 to 53 | ||||||||
| ||||||||
Added: | ||||||||
> > | https://afnog.iotworkshop.africa/pub/IoT_Course_English/REPLAndStandardPythonProgramming/calculatorV3.py.txt | |||||||
Exercise 3: ConditionsLike in exercise2, start with 2 numbers a,b with values 5 and 7. In your program check which of the 2 numbers is bigger and print the result. | ||||||||
Line: 116 to 122 | ||||||||
| ||||||||
Added: | ||||||||
> > |
|