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
Temperature Card UI Implementation
00:00
5 left

Temperature Card UI Implementation

MediumPython

Problem

Given the UX specifications above, build a temperature card based off of the reference images above.

Asked in the Android take-home stage. The card has three temperature phases, Bedtime, Night, and Dawn, four states, Off, Idle, Cooling, and Warming, and a selected phase. Tapping OFF turns temperature on. Tapping the temperature value turns it off. Adjustments are disabled when Off, and values range from -10 to +10, where 0 is neutral. The chevron has no click behavior.

Input and Output

Implement temperature_card(initial_temperatures, initial_state, actions). Temperatures are a three-item list ordered Bedtime, Night, Dawn. Actions are dictionaries such as {"type": "select", "phase": 2}, {"type": "increment"}, {"type": "decrement"}, {"type": "tap_off"}, {"type": "tap_value"}, {"type": "set_state", "state": "Cooling"}, or {"type": "tap_chevron"}. Return the final state as {"temperatures": [...], "selected": index, "state": state}.

Constraints

  • initial_temperatures contains exactly three integers ordered Bedtime, Night, Dawn
  • -10 <= initial_temperatures[i] <= 10
  • initial_state is one of Off, Idle, Cooling, or Warming
  • 0 <= action phase < 3
  • Each action type is valid
  • The number of actions is at most 10^5

Function Signature

def temperature_card(initial_temperatures, initial_state, actions):
Interviewer

Your question is Temperature Card UI Implementation. 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.