Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Generate a Pyramid Pattern
00:00
5 left

Generate a Pyramid Pattern

EasyPython

Problem

Barco ClickShare QA tooling can use predictable text patterns to verify alignment and rendering in a shared display preview. Write a function that generates a centered pyramid pattern with a configurable height and style.

For each row, use exactly 2 * row - 1 visible positions. A filled pyramid contains the symbol throughout each row. A hollow pyramid contains the symbol only at the left edge, right edge, and across the entire base. Leading spaces must center the pyramid, and trailing spaces must be removed.

Formal Specification

Implement generate_pyramid(height, hollow), where height is a positive integer and hollow is a Boolean. Return a list of strings from the top row to the base row. Use "*" as the symbol. The first row has one symbol, and the final row has 2 * height - 1 symbols.

Constraints

  • 1 <= height <= 1000
  • hollow is a Boolean
  • The output contains exactly height rows
  • Each row has no trailing spaces

Function Signature

def generate_pyramid(height, hollow):
Interviewer

Your question is Generate a Pyramid Pattern. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.