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
Object Oriented Card Game
00:00
5 left

Object Oriented Card Game

MediumPython

Problem

Implement a card game using object-oriented design (implement the game rules as classes). Asked in the Technical call / onsite OOP stage. Implement a two-player high-card game: each round deals one card to each player, the higher rank wins one point, and equal ranks produce a tie with no points.

Contract

Implement play_card_game(cards, rounds). cards is a list of objects with integer rank values from 2 through 14 and a suit string. Deal cards in order. Return {"scores": [player0_score, player1_score], "winners": [0, 1, or -1 per round]}.

Constraints

  • 1 <= rounds <= 500
  • cards contains exactly 2 * rounds cards
  • 2 <= cards[i].rank <= 14
  • cards[i].suit is a non-empty string
  • Suits do not affect the winner

Function Signature

def play_card_game(cards, rounds):
Interviewer

Your question is Object Oriented Card Game. 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.