Results for “type()”

Showing 21–30 of 73

  1. Challenge

    Decimal comma

    An operator types 42,5 and float() crashes with a ValueError. Predict it, find out why, accept both commas and dots with replace(), then read pressures written like 1 013,25.

    Fix the code Easy 3 stages strings replace float ValueError
  2. Challenge

    Command parser

    Write parse_command(), which turns typed commands such as burn 12.5 or set mode safe into tuples and raises ValueError with a reason for anything malformed, then run a whole batch of commands and…

    Write the code Medium 2 stages project parsing strings split
  3. Challenge

    Safe number input

    The burn length is typed in by hand, and a typo stops the program with a ValueError. Catch it with try and except, keep asking until the input is a number, then also turn away zero and negative…

    Write the code Easy 2 stages errors try except ValueError
  4. Challenge

    Round or cut?

    int() cuts the decimals off, round() rounds, and round(2.5) gives 2. Predict the difference, investigate Python's rounding rule, then round a fuel reading two ways.

    Write the code Medium 3 stages int round rounding type conversion
  5. Challenge

    Approved payloads

    …whole items rather than parts of text, then normalise IDs typed by hand and print a clear cleared or not-cleared message.

    Write the code Easy 2 stages lists in membership if
  6. Article Mini projects

    Medical dispenser - Don’t trust the user

    …f, indent=2) def _create_event(self, event_type, success, reason=""): """Create a tamper-evident event record with proper HMAC""" # Use UTC time for persistence across restarts utc_now =…

  7. Challenge

    Config loader

    …settings over a copy of the defaults, check each value's type and range and report every problem in one go, then wrap it all in a load_config() that never crashes, even on broken JSON.

    Write the code Hard 3 stages project json configuration validation
  8. Article Python Fundamentals

    Numbers and Basic Math Operations in Python

    …through space exploration examples. Learn about number types, operators, and practical applications that will help you start your programming journey in an engaging way.