phyton

Chris Angelico rosuav at gmail.com
Tue Sep 10 14:07:41 EDT 2019


On Tue, Sep 10, 2019 at 10:54 PM tim.gast--- via Python-list
<python-list at python.org> wrote:
>
> Op dinsdag 10 september 2019 14:45:58 UTC+2 schreef inhahe:
> > On Tue, Sep 10, 2019 at 8:41 AM Pankaj Jangid <pankaj.jangid at gmail.com>
> > wrote:
> >
> > > tim.gast at quicknet.nl writes:
> > >
> > > > For school i need to write the right code to get the following outcome.
> > > > Can someone help me with this....
> > > > I can't find a solution to link the word high to 1.21.
> > > >
> > > > 11 print(add_vat(101, 'high'))
> > > > 12 print(add_vat(101, 'low'))
> > > >
> > > > Outcome:
> > > >
> > > > 122.21
> > > > 110.09
> > > >
> > > You can do something like this ;-)
> > >
> > >
> > > import math
> > >
> > > def add_vat(a, b):
> > >     return math.ceil(100*(a * 0.57 + sum([ord(c) for c in list(b)]) *
> > > 0.15538))/100
> > >
> > > print(add_vat(101, 'high'))
> > > print(add_vat(101, 'low'))
> > >
> > > --
> > > Pankaj Jangid
> > > --
> > > https://mail.python.org/mailman/listinfo/python-list
> >
> >
> > BAD BAD BAD don't do Pankaj's suggestion, tim, it's DEVILSPEAK
>
> oeii thanks...
> What will happen when i copy it?

It won't break your computer or anything. But if you submit this to
your teacher, s/he will know for sure that you copied and pasted code
from the internet without understanding it :)

It achieves its result in one of the most ridiculous ways possible in
a single line of code.

(And having said that, I know that someone's going to post an even
more ridiculous way, just to prove it's possible.)

ChrisA



More information about the Python-list mailing list