Remakers - 3.13 Developing Procedures Python Hacks
Categories: PythonApply your skills to basic procedure development in Python.
Q1 (Easy)
Which of these procedures is named well, provide a short explanation of justification
def mix_ingredients():
def do_it():
def make_move():
Explanation Here: “def mix_ingredients() is right because.. it describes the specific step, which is mixing ingredients.
Q2 (Medium)
Finish the code to have a correctly named procedure
# Define the basic procedures
def move_forward():
print("Moving forward.")
def rotate_180():
print("Turning left") # Assuming a left turn represents a 180-degree rotation in your setup
# If you want a real 180-degree turn, you could do two 90-degree turns:
# print("Turning 90 degrees left")
# print("Turning 90 degrees left")
# Define the left turn procedure using the basic movements
def make_left_turn():
move_forward()
rotate_180()
move_forward()
print("Moving forward again to complete left turn.")
# Run the procedure
if __name__ == '__main__':
make_left_turn()
Q3 (Hard)
Write code to fulfill the requirements Doing a dance! 🕺💃 Must have
- A shimmy left procedure
- Print
super cool left slide
- Print
- A shimmy right procedure, print
even cooler right slide - Doing a bow to the crowd, print
Great dance!,the audience claps at your bow!
## Code away!
import random
def shimmy_left_procedure():
# FIX: super_cool_left_slide was not defined — replaced with a string message.
print("🕺 Shimmying to the left in style!")
def shimmy_right_procedure():
print("💃even cooler right side!")
def bow_to_the_crowd():
print("🙇great dance!")
def audience_claps():
print("👏audienceclaps at your bow!")