+1 (315) 557-6473 

How Can We Help You At Python Homework?

When you write a string for the user you want to make it readable, and it is good form to make it grammatically correct. So rather than saying you have 1 card left, you would want to say you have 1 card left. So I made an extension to the string for a matter that easily enables you to do this, you would use “{cards} {cards|card}” and it replaces the normal {cards} with the value, but the {cards|card} it recognizes the | inside the expression and checks the first value to see if it is not equal to 1, if it isn’t then it uses that, otherwise it uses the string after the |. This means it can handle irregular plurals correctly.

import string

class PluralFormattter(string.Formatter):

“Adds an easy way of formatting strings, with plural values

    plural format.format(“{days} {days|day} remaining”,days=difference.days)

    the key name should be the plural form, and when you want to refer to

    the item name, you use the | to separate the 2 values, so {days|day}

    returns days if days is not equal to 1, otherwise it returns a day.

    Floating-point values are automatically displayed with 2 decimal


    def get_value(self, key, args, kwargs):

if is an instance(key, int):

val = args[key]

if is instance(val, float):

return “%.2f” % val

return Val

if key in kwargs:

val = kwargs[key]

if isinstance(Val, float):

return “%.2f” % val

return Val


plural, single = key.split(‘|’)

return single if kwargs[plural] == 1 else plural


raise KeyError(key)

pluralFormat = PluralFormattter().format

print(pluralFormat(“{days} {days|day} remaining”,days=1))

print(pluralFormat(“{days} {days|day} remaining”,days=2))

As you can see it is easy enough to use, and fairly easy to change, perhaps adding a third option for the 0 cases, or adding the ability for language translations. This is a small example of the type of features that can easily be added, and how flexible Python is as a programming language.

If you are looking for help with any Python project, including natural language processing (using NLTK), mathematics (using NumPy and matplotlib), graphics, web development (using Django, Flask, Bottle), or anything else we have experts with all of these. Because Python is used as an introductory programming language, the homework is generally easier and so we can charge less than we would do for other programming languages.

Whenever we write a program for you, we ensure it is fully commented and also that it will work on the version of Python that you are using (there are some significant differences between Python 2 and Python 3, and both are used in education, so make sure you let us know which version you are expected to use). Although Python is suitable for beginners it has a lot of features that make it popular amongst large companies such as Google. We can use the advanced features of Python, but you might not have been taught all of them yet, so let us know which features you have been taught.

You can rely on Programming Homework Help to provide any Python homework help you may need.

No comments yet be the first one to post a comment!
Post a comment