We all know we will save the Python files with .py. This .py file contains the actual source code of the each python program. The More about the Python .py and .pyc files are below How Python works? Simple Python Example def recursive_sum(n): # change this value for a different result if number < 0: Output If we store this program with the name "sample",then it will be stored as "sample.py" when we run a sample.py file, compiler creates a sample.pyc file once the code is executed it first executes .py file where as code is first turned into byte code by the compiler in the form of "sample.pyc” file Read Also
if n <= 1:
return n
else:
return n + recursive_sum(n-1)
number = 22
print("Enter a positive number")
else:
print("The sum is",recursive_sum(number))
$python3 main.py
The sum is 253
Article Contributed By :
|
|
|
|
2028 Views |