Subroutine
A subroutine tells the computer that a piece of code exists and to go run that code again and again...
EXAMPLE :
def rollDice():
import random
dice = random.randint(1, 6)
print("You rolled", dice)
Call the Subroutine
We need to 'call' the code by adding one more line to our code with the name of the subroutine and the empty
()
: EXAMPLE :
def rollDice():
import random
dice = random.randint(1, 6)
print("You rolled", dice)
rollDice()
Comments
Post a Comment