Re: [Tutor] I need help with the following question

2013-09-10 Thread Dino Bektešević
> Message: 3
> Date: Tue, 10 Sep 2013 09:58:31 +0200
> From: Thabile Rampa 
> To: tutor@python.org
> Subject: [Tutor] [Re:] I need help with the following question
> Message-ID:
> 
> Content-Type: text/plain; charset="iso-8859-1"
>
> On Aug 27, 2013, at 3:40 AM, isaac Eric wrote
>
> 
> > print "For a circle of radius %s the area is %s" % (radius,area)
> > Question: What is the purpose of %s ?
>
> I will admit that this is homework for me. However, this is more for my log
> book and not for marks.
>
> According to my understanding, the purpose of the %s is to turn the numbers,
> which the program has recognized as numbers, into strings, so that they fit
> in the print command without any syntax errors.
>
> Could you guide me in the right direction if it is completely off?
>
> *Tab Tab*


I'm not a python "brainiac" so I apologize in advance if my answer is
lacking I'll try to be as thorough as possible.
In the light of another recent question on here "Where do I start
python" I want to point out there's been tons of linkage to places
where it's rather easy to find the answer what %s %d and %r are
One of my favs is the http://learnpythonthehardway.org/book/ and if
you start from exercise 5 onwards you should get a better idea of all
the print options there are in Python and how to use them efficiently.

If you were inquiring SPECIFICALLY about 'formaters' (the %s,d,i,r
look no further then basic Python manual here:
http://docs.python.org/2/library/stdtypes.html#string-formatting

Lucky for you the %s automatically converts any argument to string
with str() which works for everything in Python, except you might not
like the look of the output.
Be careful to use %i or %d for integers otherwise floats will be rounded up.
Printing strings when using %i will report an error.
I don't think there's any difference between %d (d does NOT stand for
double) and %i.
If you want pretty decimals (1.1) and not floats (1.10001) use the
decimal module.

Else if you were interested in all the ways you can print in python
just look at the learn python link but here's the crash course anyhow.
I don't think you should have any problems if you ever worked in any
of the big c's before.
Printing in Python 3 onwards needs parentheses around the arguments
you're printing, I think for Python <3 following should work:
Basically if in python you want to print string, python can
automatically connect them in a sentence:
 print "This"+"is"+"ok"
This is ok
but that won't work if the print arguments are not strings i.e.:
 print "This"+"is"+"not" + 6 + "ok"
TypeError: cannot concatenate string and integer objects
and it's also silly to do that, could you imagine explicitly
converting everything to string?
 print str(hours)+":"+str(minutes)+":"+str(seconds))
fugly!

What you want to do, resembles the c and c++ printf syntax
print "You can add string %s and number %d like this" %(string, number)
You can add string Banana and number 5 like this

Or also fine, valid only for python>=2.6, and also the way that I
prefer for longer strings is the C# syntax (I think):
print "Something is here: {0}".format(anything)
Something is here: (any number or string)
Because it avoids the necessity for declaring exactly what is it
you're printing and program won't crash, or at least it avoids the
need to add special try catch blocks just for printing. If you see
your output is not what you want you can return and try to work out
exactly what happened.
Hope no serious rules were broken by answering to this question...

Regards,
Dino
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] i need help with the following question

2013-08-27 Thread Don Jennings

On Aug 27, 2013, at 3:40 AM, isaac Eric wrote:



> print "For a circle of radius %s the area is %s" % (radius,area)

> Question: What is the purpose of %s ?

Okay, so you're just getting started with python. We're happy to do some 
hand-holding, but we encourage you to think first.

You've followed the rest of the instructions and run the program? Don't worry 
about being precise with your answer to this question. Just try to express what 
you think is happening (we'll build on what you give us to make it clearer).

Take care,
Don

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] i need help with the following question

2013-08-26 Thread Alan Gauld

On 26/08/13 19:31, Joel Goldstick wrote:
___

From: JAMIE shelley 
To: Alan Gauld 
effectively just a knowledge base but one that can change the area of it's
specialization.


So, the original question about ways to output from python has nothing
to do with your questions now?


The problem is that Jamie Shelley has used a post from Eric Isaac to 
post his question so we have two questions on the same thread.



just constant iteration , while and import, then OFC for GUI linking some
xyz matrix code. - or even run that kinda stuff on programs like Houdini


Where will you put the flux capacitor?


LOL :-)

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] i need help with the following question

2013-08-26 Thread Joel Goldstick
First of all, ONLY use text mode for sending messages to the mailing list.

On Mon, Aug 26, 2013 at 1:55 PM, ALAN GAULD  wrote:
> You need to include the tutor list (use ReplyAll)
> if you want to send to the list.
>
> I'm not sure I understand what you are after, can
> you give a bit more background. What do you mean by
> "knowledge base", "object code", "a.i. style of program",
> OFC, GUI linking, "xyz matrix code" etc? I could guess,
> but I might get it wrong.
>
> I assume Houdini is some kind of package or app but
> I've never heard of it and don't know what it does.
>
> Python is a general purpose programming language and
> so can likely do whatever you want it to do. But you
> will need to figure out how. It's unlikely to be a
> trivial exercise.
>
> Alan Gauld
> Author of the Learn To Program website
> http://www.alan-g.me.uk/
>
> ________________
> From: JAMIE shelley 
> To: Alan Gauld 
> Sent: Monday, 26 August 2013, 18:47
> Subject: RE: [Tutor] i need help with the following question
>
> hello, not sure id this is correct method to publish a question to th
> emailing list but hear goes :)

Not sure what that last sentence means.

> (for a start let me just add that i'm moving onto electronic electrical
> extended lvl 3 diploma mainly due to very poor computing teaching quality
> -among other things- budget cuts :c )

For starters, this is a list with many Americans and people from all
over the world.  I have no idea what extended lvl 3 diploma is, and
you lose points by complaining about your teachers.  Maybe you don't
ask questions very well (a thought!)

> - So my interest in python is no longer academic, until uni
> but still... :)
>



> wondering if you could tell me if it's possible to make a program that is
> effectively just a knowledge base but one that can change the area of it's
> specialization.

So, the original question about ways to output from python has nothing
to do with your questions now?

Maybe you are talking about a general purpose data base.

At this point, let me back up and ask if you could describe your
general level of programming experience.  What language(s)? Do you
understand what an algorithm is? A database?

>
> To clear it up a bit , coupled with the possibility of a GUI or object code
> as to allow your avg joe to input said questions in any format and the
> program can interpret it, not so much using a.i style of program (don't
> think efficiency of the code will be a problem here) but rather reference
> imported libraries/lists.

Sorry, this last paragraph looks like something made up by a bot to
sound intelligent.  It reminds me of the Dilbert Corporate philosophy
generator.

On what basis are we to compare GUI to object code .  How does this
relate to a.i

I want to be positive and helpful, but the more I look at this thread,
the less of a question I see.

Earlier a responder posted a link describing how to ask a good
question on a mailing list.  You should read that.
>
> I've been  thinking about it for a while and the best I can come up with is
> just constant iteration , while and import, then OFC for GUI linking some
> xyz matrix code. - or even run that kinda stuff on programs like Houdini

Where will you put the flux capacitor?

>
> If I haven't waffled enough; what I would like to achieve
>
> simple general purpose code for matching keyword in said locations to serial
> lists, be able to outomaticly append the list to allow retrieval of most
> common searches faster
>
> linking a program like Houdini to xyz (courtesan) code
>
>
> any info on this is great greatly appreciated, or even just ideas to get me
> going
>
> regards
> -j.shelley
>
>> To: tutor@python.org
>> From: alan.ga...@btinternet.com
>> Date: Mon, 26 Aug 2013 17:32:14 +0100
>> Subject: Re: [Tutor] i need help with the following question
>
>>
>> On 26/08/13 09:29, isaac Eric wrote:
>> > describe different ways of displaying output using python!
>>
>> This smells like homework.
>> We don;t do your homework for you although we will try to point
>> you in the right direction. But you need to show that you are
>> at least trying to figure it out for yourself.
>>
>> Also, in general, it helps if you tell us what version of Python
>> you use on which OS and what tutorial, if any, you are following.
>>
>> Then be as specific as possible in your question so that we can
>> give you a specific answer.
>>
>> As it stands I'd say the answer to your question is:
>>
>> Python can output on stdout, to named fi

Re: [Tutor] i need help with the following question

2013-08-26 Thread ALAN GAULD
You need to include the tutor list (use ReplyAll) 
if you want to send to the list.

I'm not sure I understand what you are after, can 
you give a bit more background. What do you mean by 
"knowledge base", "object code", "a.i. style of program", 
OFC, GUI linking, "xyz matrix code" etc? I could guess, 
but I might get it wrong.

I assume Houdini is some kind of package or app but 
I've never heard of it and don't know what it does.

Python is a general purpose programming language and 
so can likely do whatever you want it to do. But you 
will need to figure out how. It's unlikely to be a 
trivial exercise.
 
Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/



>
> From: JAMIE shelley 
>To: Alan Gauld  
>Sent: Monday, 26 August 2013, 18:47
>Subject: RE: [Tutor] i need help with the following question
> 
>
>
> 
>hello, not sure id this is correct method to publish a question to th emailing 
>list but hear goes :)
>(for a start let me just add that i'm moving onto electronic electrical 
>extended lvl 3 diploma mainly due to very poor computing teaching quality 
>-among other things- budget cuts :c ) 
>- So my interest in python is no longer academic, until uni 
>but still... :)
>
>wondering if you could tell me if it's possible to make a program that is 
>effectively just a knowledge base but one that can change the area of it's 
>specialization.
>
>
>To clear it up a bit , coupled with the possibility of a GUI or object code as 
>to allow your avg joe to input said questions in any format and the program 
>can interpret it, not so much using a.i style of program (don't think 
>efficiency of the code will be a problem here) but rather reference imported 
>libraries/lists. 
>
>I've been  thinking about it for a while and the best I can come up with is 
>just constant iteration , while and import, then OFC for GUI linking some xyz 
>matrix code. - or even run that kinda stuff on programs like Houdini  
>
>
>If I haven't waffled enough; what I would like to achieve
>
>simple general purpose code for matching keyword in said locations to serial 
>lists, be able to outomaticly append the list to allow retrieval of most 
>common searches faster
>
>
>linking a program like Houdini to xyz (courtesan) code  
>
>
>
>
>any info on this is great greatly appreciated, or even just ideas to get me 
>going 
>
>
>regards
>-j.shelley
>
>
>> To: tutor@python.org
>> From: alan.ga...@btinternet.com
>> Date: Mon, 26 Aug 2013 17:32:14 +0100
>> Subject: Re: [Tutor] i need help with the following question
>> 
>> On 26/08/13 09:29, isaac Eric wrote:
>> > describe different ways of displaying output using python!
>> 
>> This smells like homework.
>> We don;t do your homework for you although we will try to point
>> you in the right direction. But you need to show that you are
>> at least trying to figure it out for yourself.
>> 
>> Also, in general, it helps if you tell us what version of Python
>> you use on which OS and what tutorial, if any, you are following.
>> 
>> Then be as specific as possible in your question so that we can
>> give you a specific answer.
>> 
>> As it stands I'd say the answer to your question is:
>> 
>> Python can output on stdout, to named files, to a GUI or to a network.
>> The output can be in the form of text strings or bytes.
>> Which of those, if any, counts as 'display' is up to you.
>> 
>> -- 
>> Alan G
>> Author of the Learn to Program web site
>> http://www.alan-g.me.uk/
>> 
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>
>
>___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] i need help with the following question

2013-08-26 Thread Alan Gauld

On 26/08/13 09:29, isaac Eric wrote:

describe different ways of displaying output using python!


This smells like homework.
We don;t do your homework for you although we will try to point
you in the right direction. But you need to show that you are
at least trying to figure it out for yourself.

Also, in general, it helps if you tell us what version of Python
you use on which OS and what tutorial, if any, you are following.

Then be as specific as possible in your question so that we can
give you a specific answer.

As it stands I'd say the answer to your question is:

Python can output on stdout, to named files, to a GUI or to a network.
The output can be in the form of text strings or bytes.
Which of those, if any, counts as 'display' is up to you.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] i need help with the following question

2013-08-26 Thread bob gailer

On 8/26/2013 4:29 AM, isaac Eric wrote:

describe different ways of displaying output using python!

I am glad you are asking for help. We encourage that.

I agree with the other responses.

Your question is clear to you, but not to us. We could play the guessing 
game and eventually discover what you want - but that is not efficient.


Better is for you to read the article on how to ask questions, then 
re-send your question.


--
Bob Gailer
919-636-4239
Chapel Hill NC

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] i need help with the following question

2013-08-26 Thread Chris Down
On 2013-08-26 01:29, isaac Eric wrote:
> describe different ways of displaying output using python!

Please, read this: http://www.catb.org/esr/faqs/smart-questions.html


pgpmEMqlTiuCa.pgp
Description: PGP signature
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] i need help with the following question

2013-08-26 Thread Don Jennings

On Aug 26, 2013, at 4:29 AM, isaac Eric wrote:

> describe different ways of displaying output using python!

Well, that's not really a question now, is it? I would be happy to help, but 
which part of the task is confusing for you?

Take care,
Don

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] i need help with the following question

2013-08-26 Thread isaac Eric
describe different ways of displaying output using python!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor