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}"
.
Lösning
Tack för dina kommentarer!
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Awesome!
Completion rate improved to 5
Challenge: Access & Ticket Perks Engine
Svep för att visa menyn
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}"
.
Lösning
Tack för dina kommentarer!
Awesome!
Completion rate improved to 5single