Python
ThuwarahanNant1 (0)

I tried to make a 'calculator' to help with my GCSE Astronomy course at school. I have got it to work but I think that there should be an easier way to carry this out without using lots of lines of code. So far, I have made it so that each calculation is carried out with a function that takes certain parameters that are inputted by the user. Then, all the different calculations are outputted on the terminal and the user enters the corresponding number. Each function is assigned a number and is then carried out.
I really want to know how I can make the code more efficient and readable and whether any of the calculations are incorrect. Please help!!

You are viewing a single comment. View All
Answered by malvoliothegood (147) [earned 5 cycles]
View Answer
malvoliothegood (147)

@ThuwarahanNant1
Here is a link to an example program that shows how to do what you are asking for. It is a bit more complicated as it tests user input to see that it is valid. You may not want or need to do this in your program, but in reality you would have to do this in the "real world". I used to teach programming at High School and required my students to use error checking in their programs: https://repl.it/@malvoliothegood/menu-example