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!!

@malvoliothegood Thank you so much. I really appreciate it. Also, is there a way to keep repeating the instruction and menu functions until the user enters something like "quit"?

@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

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!!

@malvoliothegood Thank you so much. I really appreciate it. Also, is there a way to keep repeating the instruction and menu functions until the user enters something like "quit"?

@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