PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Waymo

Implement Safe Average Function

Last updated: May 3, 2026

Quick Overview

This question evaluates proficiency with basic programming fundamentals including numeric computation, handling edge cases such as empty inputs, input immutability, and data type consistency.

  • medium
  • Waymo
  • Coding & Algorithms
  • Data Scientist

Implement Safe Average Function

Company: Waymo

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

Write a Python function `average(values)` that returns the arithmetic mean of a list of numbers. Requirements: - If `values` is empty, return `0`. - The input is a flat list of numeric values such as integers or floats. - Do not mutate the input list. Examples: - `average([1, 2, 3])` returns `2.0` - `average([-1, 1])` returns `0.0` - `average([])` returns `0`

Quick Answer: This question evaluates proficiency with basic programming fundamentals including numeric computation, handling edge cases such as empty inputs, input immutability, and data type consistency.

Related Interview Questions

  • Expand Nested Repetition Expressions - Waymo (medium)
  • Find Shortest Paths to Target Nodes - Waymo (medium)
  • Serialize Expression Tree Minimizing Parentheses - Waymo (medium)
  • Find Shortest Knight Path - Waymo (medium)
  • Implement Fibonacci generator, balanced BST, frozenset - Waymo (medium)
Waymo logo
Waymo
Mar 7, 2026, 12:00 AM
Data Scientist
Take-home Project
Coding & Algorithms
1
0

Write a Python function average(values) that returns the arithmetic mean of a list of numbers.

Requirements:

  • If values is empty, return 0 .
  • The input is a flat list of numeric values such as integers or floats.
  • Do not mutate the input list.

Examples:

  • average([1, 2, 3]) returns 2.0
  • average([-1, 1]) returns 0.0
  • average([]) returns 0

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Waymo•More Data Scientist•Waymo Data Scientist•Waymo Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.