Now it is time to take our computer knowledge to learn about Right Ascension, which is a set of numbers that tells a telescope how much to rotate when you are telling it where to point. In this activity, we will collect these numbers and output the values to start. Right Ascension is a measure of rotation, like longitude, and it is measured in hours, minutes and seconds from a fixed zero point on the celestial equator where the Sun crosses the celestial equator at the March equinox.
A full rotation is equivalent to one rotation of the earth in a 24 hour period, so a Right Ascension of 24h 0m 0s is one full circle. The variables "hours" and "minutes" are always whole numbers, so they are of type integer but "seconds" can have a decimal place so it is of type number. Ask the user for values for variables named hours, minutes and seconds and then output the answers each on separate lines with 3 output statements. Your solution should have 6 lines of code. To get you started, here is the first line:
integer hours = cast(integer, input("Enter hours: "))
On the next line, use the output command to display the variable's value. We can combine a text string with a variable name using the + operator to output a nicely formatted answer, like this:
output "Hours: " + hours
Remember that in astronomy calculation minutes has to be an integer and seconds has to be a number.
When you write a computer program for other people to use, you will often want to check the user's input to make sure it makes sense for your computer program. In this case, if a user enters a number over 24 or less than 0 when your program asks for hours, it does not make sense for our calculation. If you want to be sure that the user's input is correct you can use an if / else statement to decide if you should output an answer or give an error message. For this Exploration Challenge, create a conditional statement in your code that either outputs the hours or an error message. If you want to go further, put the error checking code in a repeat loop so that the program keeps asking the user for input until the input is valid.