"Cai Gengyang" wrote in message
news:d34dc21b-fe74-40fc-9b54-c37110529...@googlegroups.com...
meal = 44.50
tax = 0.0675
tip = 0.15
meal = meal + meal * tax
total = meal + meal * tip
print("%.2f" % total)
What do the lines inside the parentheses in this statement print("%.2f" %
total) mean
On Sun, Nov 22, 2015 at 5:30 PM, Cai Gengyang wrote:
> What do the lines inside the parentheses in this statement print("%.2f" %
> total) mean ?
>
> What does "%.2f" % total represent ?
>
This is called "percent formatting" or "printf-style formatting". It's
a means of formatting a tuple of valu
print the two digits after the point.
On 11/21, Cai Gengyang wrote:
>
> meal = 44.50
> tax = 0.0675
> tip = 0.15
>
> meal = meal + meal * tax
> total = meal + meal * tip
>
> print("%.2f" % total)
>
> What do the lines inside the parentheses in this statement print("%.2f" %
> total) mean ?
meal = 44.50
tax = 0.0675
tip = 0.15
meal = meal + meal * tax
total = meal + meal * tip
print("%.2f" % total)
What do the lines inside the parentheses in this statement print("%.2f" %
total) mean ?
What does "%.2f" % total represent ?
Thanks alot ...
Gengyang
--
https://mail.python.org
On Fri, 20 Nov 2015 02:42 am, Ian Kelly wrote:
> On Thu, Nov 19, 2015 at 5:45 AM, Steven D'Aprano
> wrote:
>> But if you want the default value to be evaluated exactly once, and once
>> only, there is no real alternative to early binding. You could use a
>> global variable, of course, but that is
On Fri, 20 Nov 2015 10:59 pm, BartC wrote:
> On 20/11/2015 01:05, Steven D'Aprano wrote:
>> Here's another use for function defaults, as static storage:
[...]
>> This is a quick and easy way to memoise a function which would otherwise
>> be horribly slow. And it only works because _memo is bound
Greetings,
It is my duty and honor to announce the immediate availability of Python
2.7.11 release candidate 1. Python 2.7.11 will be another bug fix
release for the 2.7.x series.
Downloads are at:
https://www.python.org/downloads/release/python-2711rc1/
Please test the candidate and report
On 11/20/2015 07:30 PM, Dylan Riley wrote:
i am learning python and was tasked with making a program that flips a coin 100
times and then tells you
the number of heads and tails.
I have done so coming up with this piece of work but it doesnt run can anyone
help me out?
#This is credited to dy
On Sun, Nov 22, 2015 at 9:49 AM, Cai Gengyang wrote:
> Hmm .. I am a slow learner and have poor memory. Sometimes when I see a new
> programming operator, I have to type it out so that I can remember it and let
> it sink into my brain
>
I recommend creating a text file of notes. Every time you
Hmm .. I am a slow learner and have poor memory. Sometimes when I see a new
programming operator, I have to type it out so that I can remember it and let
it sink into my brain
On Sunday, November 22, 2015 at 6:24:28 AM UTC+8, Jon Ribbens wrote:
> On 2015-11-21, Cai Gengyang wrote:
> > Comparat
On 2015-11-21, Cai Gengyang wrote:
> Comparators, interesting ...
>
booltwo = (10 + 18) == 3**17
booltwo
> False
What's interesting about that?
--
https://mail.python.org/mailman/listinfo/python-list
Comparators, interesting ...
>>> booltwo = (10 + 18) == 3**17
>>> booltwo
False
>>> boolone = (50 - 35) > 35
>>> boolone
False
>>> booltwo = (65 - 35) > 15
>>> booltwo
True
>>> boolalpha = 3 < 6
>>> boolalpha
True
>>> boolbeta = 100 == 10*30
>>> boolbeta
False
>>>
--
https://mail.python.org/mail
On Monday, November 2, 2015 at 1:45:58 PM UTC-5, Ben Finney wrote:
> Lee Bradley writes:
>
> > http://pastebin.com/ndDYjYe1
>
> We much prefer to discuss code in the context of plain text messages
> right here, because this forum is archived longer than the expected
> lifetime of content hosted
On 2015-11-21 18:49, david burstein wrote:
im pretty new in python and i didnt get how to use the re.split function.
for example if i have a string and i want to split it by two conditions:
first one splitting when " [ " appears second one when "]" appears
re.split(r" \[ |\]", string)
You need
im pretty new in python and i didnt get how to use the re.split function.
for example if i have a string and i want to split it by two conditions:
first one splitting when " [ " appears second one when "]" appears
--
https://mail.python.org/mailman/listinfo/python-list
On суббота, 21 ноября 2015 г. 6:30:02 MSK, Dylan Riley wrote:
Also some more notes:
heads = int("1")
tails = int("2")
Why use this strange initialization? The usual way:
heads = 1
tails = 2
gives the same result.
while flips != 0:
flips -= 1
There's no need to use while and flips vari
On суббота, 21 ноября 2015 г. 6:30:02 MSK, Dylan Riley wrote:
i am learning python and was tasked with making a program that
flips a coin 100 times and then tells you
the number of heads and tails.
First, you have a syntax error:
if result = heads:
should be:
if result == heads:
Second, ther
On Sun, Nov 22, 2015 at 2:01 AM, Ian Kelly wrote:
>> and then the decorator could wrap the function. I'm not entirely sure
>> I could implement it reliably, but even leaving that aside, having to
>> put "lambda:" in front of everything is pretty ugly.
>
> Note that "lambda: []" can also be spelled
On 11/21/2015 10:26 AM, BartC wrote:
On 21/11/2015 10:41, vostrus...@gmail.com wrote:
Hi,
I have a file with one parameter per line:
a1
b1
c1
a2
b2
c2
a3
b3
c3
...
The parameters are lines of characters (not numbers)
I need to load it to 2D array for further manipulations.
So far I managed to
On 21/11/2015 10:41, vostrus...@gmail.com wrote:
Hi,
I have a file with one parameter per line:
a1
b1
c1
a2
b2
c2
a3
b3
c3
...
The parameters are lines of characters (not numbers)
I need to load it to 2D array for further manipulations.
So far I managed to upload this file into 1D array:
Parame
In a message of Sat, 21 Nov 2015 15:22:55 +0100, Laura Creighton writes:
>At this point you might get a bit frustrated. Python is happily telling
>you that you don't have a newarray[0][0] which is hardly news to you who
>was trying to initialise the thing.
My bad. I was thinking about 2 dimentio
On Sat, Nov 21, 2015 at 1:46 AM, Chris Angelico wrote:
> On Sat, Nov 21, 2015 at 7:38 PM, Todd wrote:
>> Rather than a dedicated syntax, might this be something that could be
>> handled by a built-in decorator?
>>
>> Maybe something like:
>>
>> @late_binding
>> def myfunc(x, y=[]):
>
> No, it can
In Python we don't write while loops that often.
instead we do:
for i in range(NumberOfColumns):
for j in range(NumberOfRows):
do_something()
But for the particular case that you are after, constructing lists,
we have something even neater -- list comprehensions.
So you might write:
>>> bill = 100
>>> bill *= 1.08
>>> bill
108.0
>>>
On Saturday, November 21, 2015 at 9:47:29 PM UTC+8, Frank Millman wrote:
> "Cai Gengyang" wrote in message
> news:a76b1b5b-4321-41bb-aeca-0dac78775...@googlegroups.com...
>
> > This is a piece of code that calculates tax and tip :
> >
> > d
On Sat, Nov 21, 2015 at 8:39 AM, Steven D'Aprano
wrote:
> On Sun, 22 Nov 2015 12:20 am, Cai Gengyang wrote:
>
> > Does bill *= 1.08 mean bill = bill * 1.15 ?
>
> No. It means `bill = bill * 1.08`, not 1.15.
>
>
>
> --
> Steven
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
Other
"Cai Gengyang" wrote in message
news:a76b1b5b-4321-41bb-aeca-0dac78775...@googlegroups.com...
This is a piece of code that calculates tax and tip :
def tax(bill):
"""Adds 8% tax to a restaurant bill."""
bill *= 1.08
print "With tax: %f" % bill
return bill
def tip(bill):
"
On Sun, 22 Nov 2015 12:20 am, Cai Gengyang wrote:
> Does bill *= 1.08 mean bill = bill * 1.15 ?
No. It means `bill = bill * 1.08`, not 1.15.
--
Steven
--
https://mail.python.org/mailman/listinfo/python-list
On 21/11/2015 13:20, Cai Gengyang wrote:
This is a piece of code that calculates tax and tip :
def tax(bill):
"""Adds 8% tax to a restaurant bill."""
bill *= 1.08
print "With tax: %f" % bill
return bill
def tip(bill):
"""Adds 15% tip to a restaurant bill."""
bill *
This is a piece of code that calculates tax and tip :
def tax(bill):
"""Adds 8% tax to a restaurant bill."""
bill *= 1.08
print "With tax: %f" % bill
return bill
def tip(bill):
"""Adds 15% tip to a restaurant bill."""
bill *= 1.15
print "With tip: %f" % bill
return
vostrus...@gmail.com wrote:
> Hi,
> I have a file with one parameter per line:
> a1
> b1
> c1
> a2
> b2
> c2
> a3
> b3
> c3
> ...
> The parameters are lines of characters (not numbers)
>
> I need to load it to 2D array for further manipulations.
> So far I managed to upload this file into 1D arra
Hi,
I have a file with one parameter per line:
a1
b1
c1
a2
b2
c2
a3
b3
c3
...
The parameters are lines of characters (not numbers)
I need to load it to 2D array for further manipulations.
So far I managed to upload this file into 1D array:
ParametersRaw = []
with open(file1) as fh:
Parameters
On Sat, Nov 21, 2015 at 7:38 PM, Todd wrote:
> Rather than a dedicated syntax, might this be something that could be
> handled by a built-in decorator?
>
> Maybe something like:
>
> @late_binding
> def myfunc(x, y=[]):
No, it can't; by the time the decorator runs, the expression has
already been
On Nov 19, 2015 20:48, "Chris Angelico" wrote:
>
> On Fri, Nov 20, 2015 at 5:42 AM, Ian Kelly wrote:
> > BartC on the other hand is just complaining about an aspect of Python
> > that is legitimately controversial.
>
> IMO it's controversial mainly because there's an easy and obvious
> syntax for
33 matches
Mail list logo