In C language Ive learned that we can write function prototype (the function declaration with ';' in the end) so we can write the main function before the functions definition
#include <stdio.h>
int addNumbers(int a, int b); // function prototype
int main()
{
int n1,n2,sum;
printf("Enters two numbers: ");
scanf("%d %d",&n1,&n2);
sum = addNumbers(n1, n2); // function call
printf("sum = %d",sum);
return 0;
}
int addNumbers(int a, int b) // function definition
{
int result;
result = a+b;
return result; // return statement
}
Can I do something similar in python, I like the structure that we have all function declaration on top, then the main function , and below the functions definitions
int addNumbers(int a, int b) // function prototype
def main():
addNumbers(1,2)
if __name__ == "__main__":
main()
int addNumbers(int a, int b): // function definition
result = a+b
return result // return statement
ill be glad for help
I tried this but it didn't wortk- couldn't find a relevant answer on the internet
def print() -> int:
def main():
print()
if __name__ == "__main__":
main()
def print ()->int:
print("Hello")
return 1