Question: # Part 1 : Initialization and Helper Functions # Function to move Karel forward n steps def move _ n _ steps ( n )
# Part : Initialization and Helper Functions
# Function to move Karel forward n steps
def movenstepsn:
for in rangen:
move
# Function to turn Karel around
def turnaround:
turnleft
# Helper function to turn Karel right
def turnright:
for in range:
turnleft
# Part : Hourglass Creation Functions
# Function to create the upper half of the hourglass
def createupperhalfsize:
for i in range size :
movenstepsi
putbeeper
turnaround
movenstepsi
putbeeper
turnaround
# Function to create the lower half of the hourglass
def createlowerhalfsize:
for i in rangesize :
movenstepsi
putbeeper
turnaround
movenstepsi
putbeeper
turnaround
# Part : Main Function and Execution
# Main function to create the hourglass
def createhourglass:
# Determine the size of the world
worldsize getworldsize
# Ensure the world size is greater than
if worldsize :
printWorld size must be greater than
return
# Move to the starting position
movenstepsworldsize
turnleft
# Create upper half
createupperhalfworldsize
# Move to the starting position of the lower half
turnaround
movenstepsworldsize
turnright
# Create lower half
createlowerhalfworldsize
# Call the createhourglass function to start the program
createhourglass
question: getworldsize and worldsize are not defined.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
