Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Oct 3, 2025

This PR implements two reusable robotics-themed functions in 03_functions.py for the RobotX Workshops Python coding examples collection.

Changes

Created 03_functions.py with the following functions:

1. calculate_distance(speed, time)

Calculates the distance traveled by a drone given its speed and flight time.

Parameters:

  • speed (float): Speed in meters per second
  • time (float): Time in seconds

Returns: Distance traveled in meters

Example:

distance = calculate_distance(5.0, 10.0)
print(distance)  # Output: 50.0

2. format_sensor_data(x, y, z)

Formats sensor position data into a human-readable string representation.

Parameters:

  • x, y, z (float): Coordinate values

Returns: Formatted string like "Position: (x=10, y=20, z=5)"

Example:

formatted = format_sensor_data(10, 20, 5)
print(formatted)  # Output: "Position: (x=10, y=20, z=5)"

Demo Output

When running python3 03_functions.py, the following demonstration output is displayed:

Example 1: Distance traveled
  Speed: 5.0 m/s
  Time: 10.0 s
  Distance: 50.0 m

Example 2: Sensor data formatting
  Raw coordinates: x=10, y=20, z=5
  Formatted: Position: (x=10, y=20, z=5)

Both functions include comprehensive docstrings with parameter descriptions, return types, and usage examples following Python best practices.

Original prompt

Create Themed Functions
This prompt focuses on building reusable code blocks (functions) that directly relate to drone operations.

In 03_functions.py, create two robotics-themed functions with clear docstrings.

  1. A function calculate_distance(speed, time) that returns the distance traveled.
  2. A function format_sensor_data(x, y, z) that returns a formatted string like "Position: (x=10, y=20, z=5)".
    Show an example of calling each function and printing the result.

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: anjrew <26453863+anjrew@users.noreply.github.com>
@Copilot Copilot AI changed the title Create Themed Functions This prompt focuses on building reusable code blocks (functions) that directly relate to drone operations. In 03_functions.py, create two robotics-themed functions with clear docstrings. 1. A function `calculate_distance(spee... Add robotics-themed functions for drone operations Oct 3, 2025
@Copilot Copilot AI requested a review from anjrew October 3, 2025 15:53
Copilot finished work on behalf of anjrew October 3, 2025 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants