Well, there are dozens of code samples here in the forum which you can learn from. For problems with little input and output you can use input() and print () as shown in my posting above.
For problems with huge input it is not uncommon to use a pattern like this
[bbone=Python3,507]
import sys
for line in sys.stdin:
numbers = map(int, line.split())
do something with input numbers
result = sum (numbers)
sys.stdout.write('%d\n' % result)
[/bbone]