Python functions help #111026
Replies: 3 comments 2 replies
-
It's great that you're seeking assistance to improve your understanding of defining and calling functions in Python. To address your struggle, let's focus on defining functions and calling them appropriately. In your provided code, you're on the right track with the 'convert' function, which takes 'time' as an argument and converts it to hours and minutes. However, you're immediately reassigning 'time' with a user input, which negates the purpose of passing arguments to the function. Instead, you should remove the input prompt from within the 'convert' function and call it with a time argument from your main code. Additionally, uncomment the 'main' function and the conditional block at the bottom of your script to properly call and execute your code. This separation of concerns will improve readability and maintainability, allowing you to tackle more complex programs effectively. Keep practicing, and don't hesitate to seek further clarification or assistance when needed. |
Beta Was this translation helpful? Give feedback.
-
How about we start with something simple... try this out.
Try running this and see what happens!!! |
Beta Was this translation helpful? Give feedback.
-
Dear TheNose1, I hope this message finds you well, Hope helps |
Beta Was this translation helpful? Give feedback.
-
Body
Hello all,
I have been working with python for a couple months now getting used to the language and how to solve problems. I however am struggling with defining and calling my own functions. I cannot follow others code due to this issue and I struggle to make more complex programs due to this issue. So I am currently taking CS50P to help with this issue but am still stuck, particualarly with a class assignment using functions. I have written the code I need and it accomplishes the desired task but without using functions as deisred. I have commented out the parts of the code I previously wrote and have left the code I know works. If anyone could assist me with this lack of knowledge that would be very helpful.
I do not now how to attach code files I am sorry
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions