, June 15, 2017 1:53 AM
To: William Gan ; tutor@python.org
Subject: Re: [Tutor] Fahrenheit to Celsius Conversion another problem and
Programming Paradigm
Hi William,
Glad to see the tutor list is being of help in your learning.
On 14/06/17 09:20, William Gan wrote:
> if unit == 'C' or
...@graniteweb.com]
Sent: Thursday, June 15, 2017 2:04 AM
To: tutor@python.org
Subject: Re: [Tutor] Fahrenheit to Celsius Conversion another problem and
Programming Paradigm
> On Jun 14, 2017, at 09:20, William Gan wrote:
>
> However, today I modified only the print instruction a little
]
Sent: Thursday, June 15, 2017 2:15 AM
To: tutor@python.org
Subject: Re: [Tutor] Fahrenheit to Celsius Conversion another problem and
Programming Paradigm
On 14/06/17 15:20, William Gan wrote:
> print('Enter C for Celsius to Fahrenheit or F for Fahrenheit to
> Celsius.')
>
>
> On Jun 15, 2017, at 13:16, William Gan wrote:
>
> Hi David,
>
> Very much thanks for taking time to help.
>
> Your explanation has helped me understand that syntax issue better. I have
> resolved that error.
>
> Your counsel on the second issue has given me encouragement. Thank you.
I’m g
On Thu, Jun 15, 2017 at 12:52:10PM +, Neil Cerutti wrote:
On 2017-06-14, Peter Otten <__pete...@web.de> wrote:
Sebastian Silva wrote:
Or shorter:
if unit in 'Cc':
Don't do that. You are in for nasty surprises:
def check(unit):
... if unit in "Cc":
... return "Celsius"
...
On 2017-06-14, Peter Otten <__pete...@web.de> wrote:
> Sebastian Silva wrote:
>
>> Or shorter:
>>
>> if unit in 'Cc':
>
> Don't do that. You are in for nasty surprises:
>
def check(unit):
> ... if unit in "Cc":
> ... return "Celsius"
> ... return "unknown"
> ...
check("
On 2017-06-14 12:22, Mats Wichmann wrote:
Of course if you do any serious argument handling, it's better to use
something like optparse (and earlier argparse) module so you're not
reinventing a wheel which has been massively worked on already.
At the suggestion of a posting on this list some
On 06/14/2017 12:18 PM, Sibylle Koczian wrote:
> Correct usage would be:
>
> if myvar == val1 or myval == val2:
> or
> if myvar in (val1, val2):
Just piling on here to say I find the second form very useful to collect
arguments in a "friendly" way, if you don't have a reason to very
rigidly con
Sebastian Silva wrote:
> Or shorter:
>
> if unit in 'Cc':
Don't do that. You are in for nasty surprises:
>>> def check(unit):
... if unit in "Cc":
... return "Celsius"
... return "unknown"
...
>>> check("c")
'Celsius'
>>> check("C")
'Celsius'
>>> check("F")
'unknown'
Fine so
Am 14.06.2017 um 16:20 schrieb William Gan:
Good day Everyone,
I am seeking help on two issues.
ISSUE 1:
Yesterday I posted a problem on this tiny script I wrote for temperature
conversion (as practice for a newbie). My error was pointed out to me that
there is a difference in upper and lower
Hi William,
Glad to see the tutor list is being of help in your learning.
On 14/06/17 09:20, William Gan wrote:
> if unit == 'C' or 'c':
In this case, it will always be true, because there are two conditions,
either:
* unit == 'C' or
* 'c'
As you can see, the second condition is not a co
On 14/06/17 15:20, William Gan wrote:
> print('Enter C for Celsius to Fahrenheit or F for Fahrenheit to Celsius.')
>
> if unit == 'C' or 'c':
You have hit a common error for beginners. reading this as a human
it is quite clear what is meant but the computer sees it
differently. It sees:
if (uni
> On Jun 14, 2017, at 09:20, William Gan wrote:
>
> However, today I modified only the print instruction a little to try to print
> out ℃ (in the second print clause). When I subsequently ran the script all
> the outputs were executed from the if clause, even when I input other letters
> (Ple
Good day Everyone,
I am seeking help on two issues.
ISSUE 1:
Yesterday I posted a problem on this tiny script I wrote for temperature
conversion (as practice for a newbie). My error was pointed out to me that
there is a difference in upper and lowercase letters. After correcting that
error, I
14 matches
Mail list logo