Skip to content

Ch10 Variable scope has confusing variable name #196

Open

Description

@DrJonnyT

How could the content be improved?

Ch0 Variable scope section has this code:

initial_fine = 0.25
late_fine = 0.50

def calc_fine(days_overdue):
    if days_overdue <= 10:
        days_overdue =  days_overdue * initial_fine
    else:
        days_overdue = (days_overdue * initial_fine) + (days_overdue * late_fine)
    return days_overdue

There are two different uses of days_overdue, one of which would be measured in days, and one of which would be measured in dollars (pounds for us!). It would be better as something like:

def calc_fine(days_overdue):
    if days_overdue <= 10:
        total_fine =  days_overdue * initial_fine
    else:
        total_fine = (days_overdue * initial_fine) + (days_overdue * late_fine)
    return total_fine

Which part of the content does your suggestion apply to?

Ch10 Variable scope

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions