PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates understanding of basic statistical concepts and numerical computation—specifically population versus sample variance—and tests algorithmic implementation skills, edge-case handling, and complexity reasoning within the Coding & Algorithms domain.

  • hard
  • PayPal
  • Coding & Algorithms
  • Data Scientist

Compute Variance from a Python List

Company: PayPal

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

Given a Python list of numeric values, write a function to compute the variance without using external libraries such as NumPy or pandas. Clarify any assumptions you make, such as: - whether you are computing population variance or sample variance, - how to handle an empty list or a list with one element, - and the expected time and space complexity.

Quick Answer: This question evaluates understanding of basic statistical concepts and numerical computation—specifically population versus sample variance—and tests algorithmic implementation skills, edge-case handling, and complexity reasoning within the Coding & Algorithms domain.

Return population variance rounded to 6 decimals; return None for an empty list.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([1,2,3],)

Expected Output: 0.666667

Explanation: Population variance.

Input: ([5,5,5],)

Expected Output: 0.0

Explanation: Zero variance.

Input: ([],)

Expected Output: None

Explanation: Empty list.

Hints

  1. Model object-style prompts as arrays or operation streams when needed.
  2. Handle empty and boundary cases before the main logic.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ 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.

Related Coding Questions

  • Minimize a String Using Allowed Swaps - PayPal (medium)
  • Compute variance of a list in Python - PayPal (easy)
  • Explain list vs tuple in Python - PayPal (easy)
  • Solve common search/parse/graph frequency tasks - PayPal (medium)
  • Explain differences between Python list and tuple - PayPal (hard)