Challenge: Access & Ticket Perks Engine
Swipe to start coding
Fill in the expressions using only variables, basic operators, and the tools we covered: strip
, casefold
, int
, slicing, comparisons, and logical operators.
Compute:
-
age
- convertage_str
to an integer. -
has_id
- converthas_id_str
to a Boolean by normalizing text and comparing to"yes"
. -
Parse
ticket_code
intotier
,seat_number_str
,zone
using slicing by fixed positions. -
seat_number
- convertseat_number_str
to an integer. -
Rules
is_adult
:age
is at leastadult_age
.can_enter
: must have ID and be an adult.vip_perk
: tier is"VIP"
.member_fastlane
: user is a member and can enter.seat_ok
:seat_number
is in the inclusive range from 1 tomax_seat_number
using a chained comparison.entry_granted
:can_enter
andseat_ok
.
-
summary
- f-string:"{tier}-{seat_number_str}-{zone} | age={age} | enter={entry_granted} | vip={vip_perk} | fastlane={member_fastlane}"
.
Solution
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Can you explain this in simpler terms?
What are the main points I should remember?
Can you give me an example?
Awesome!
Completion rate improved to 5
Challenge: Access & Ticket Perks Engine
Swipe to show menu
Swipe to start coding
Fill in the expressions using only variables, basic operators, and the tools we covered: strip
, casefold
, int
, slicing, comparisons, and logical operators.
Compute:
-
age
- convertage_str
to an integer. -
has_id
- converthas_id_str
to a Boolean by normalizing text and comparing to"yes"
. -
Parse
ticket_code
intotier
,seat_number_str
,zone
using slicing by fixed positions. -
seat_number
- convertseat_number_str
to an integer. -
Rules
is_adult
:age
is at leastadult_age
.can_enter
: must have ID and be an adult.vip_perk
: tier is"VIP"
.member_fastlane
: user is a member and can enter.seat_ok
:seat_number
is in the inclusive range from 1 tomax_seat_number
using a chained comparison.entry_granted
:can_enter
andseat_ok
.
-
summary
- f-string:"{tier}-{seat_number_str}-{zone} | age={age} | enter={entry_granted} | vip={vip_perk} | fastlane={member_fastlane}"
.
Solution
Thanks for your feedback!
Awesome!
Completion rate improved to 5single