The first challenge I took on board was to write a programme that would ask you for the year you were born, the current year and then it would tell you how old you would be this year. Here's my code below which worked, YAY!
For the next challenge, I had to write a programme that would repeatedly asks the user for the current temperature of a machine. The machine must shutdown if the temperature is 50 or greater, or if it is 0 or less. If the temperature the user has entered is within normal operating temperatures, then print Temperature OK. If the temperature is too high or low, then your program must stop asking for the temperature and should print Shutting down...
This part of the problem I got right but it what I couldn't figure out was how to use the 'while' function to keep asking the user what the temperature was. I had another problem, there were floats in the inputs. Floats are numbers with decimal points which in this scenario need to be rounded to a whole number. I think I have the round function, I can't work out how to put it together.
Example:
- Function call round(x) returns the nearest int to the float value x
- round(45.6)
- Here round is the name of the function
- 45.6 is the argument
I've just come across the main keywords for Python which will be super helpful from beginnersbook.com
No comments:
Post a Comment