Re: [Tutor] Compare function!

2013-10-14 Thread Alan Gauld

On 14/10/13 15:41, Sammy Cornet wrote:


. In which I´m want to get the user to prompt for the values of a and b.


So where is the code where you prompt the user and read input.
All we can see is a single function?



For some reason I can´t run it. The follwing is what I have written on
  my script:

def comparefunc (a, b):
 a = 3
 b = 4


The above assignments make your parameters useless since you have 
overwritten them
This function effectively compares 3 and 4 only. As such the result will 
always return -1.


Having func as part of the name is usually considered a bad idea.
We can see its a function by the way we use it. The only time
having func in the name is useful is when you are passing it
as a parameter to another function or storing it in another
variable. But I suspect that's several learning steps away
from you just now.


 if a < b:
   return 1
 elif a == b:
   return 0
 elif a < b:
   return -1
 print "return"


This all looks OK except putting prints inside a function like this is 
usually only good as a debugging aid. You probably want to lose that 
once you have it working correctly.



And, this is what I get for my output:
 >>>  RESTART



That may be because you define the function but don't
seem to call it at any point.

You need to remove the two assignments for a and b
Then implement the get input calls to get the values
from the user then call the function and finally print
the result.

Something like this:

a = int(raw_input('gimme an a '))
b = int(raw_input('gimme a b '))

result = camparefunc(a,b)

print result


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

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


Re: [Tutor] Fwd: we need assistance in my school

2013-10-14 Thread brian arb
This looks like a very fun way to teach programming at an early age
http://scratch.mit.edu/


On Mon, Oct 14, 2013 at 6:54 AM, Okechukwu Nkaronye wrote:

> -- Forwarded message --
> From: Okechukwu Nkaronye 
> Date: Fri, 11 Oct 2013 13:04:10 +
> Subject: we need assistance in my school
> To: sanomat@formin.fi, off...@ise.edu.ee, supp...@edline.com,
> cont...@thebaudieves.org, cont...@thebaudieres.org
>
> Hi my name is okechukwu . I teaches computer at a low grade of 8, 9, 10, 12
> years ages .
>
> Please I would be pleased if you could assist us in helping our children to
> get to know programming skills
>
> I am not very vast in programming and know little in programming.
>
>
>
> We dim it fit the create a forum for our younger ones to start early to
> learn computer programming .
>
>
>
> Much Anticipations
>
> Mr. Okechukwu Nkaronye
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fw: Fwd: we need assistance in my school

2013-10-14 Thread Alan Gauld

On 14/10/13 15:16, bharath ks wrote:

this is interesting .. i would like to contribute and i am living in germany


Where you live shouldn't be an issue.

Join the SIG by getting involved. The links are all
on the SIG web pages.


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

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


[Tutor] Compare function!

2013-10-14 Thread Sammy Cornet
Hello!I´m using Idle (Python 2.7,5 version). I´m trying to  write a program of 
compare function that returns 1 if a > b , 0 if a == b , and -1
if a < b . In which I´m want to get the user to prompt for the values of a and 
b. For some reason I can´t run it. The follwing is what I have written on  my 
script:
def comparefunc (a, b):a = 3b = 4if a < b:   return 1elif a 
== b:  return 0elif a < b:  return -1print "return"
And, this is what I get for my output:
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on 
win32Type "copyright", "credits" or "license()" for more information.>>> 
 RESTART >>> 
>>>___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Fw: Fwd: we need assistance in my school

2013-10-14 Thread bharath ks
this is interesting .. i would like to contribute and i am living in germany

 
Thanks & BR,
Bharath Shetty



On Monday, 14 October 2013 3:49 PM, Alan Gauld  
wrote:
 
On 14/10/13 11:54, Okechukwu Nkaronye wrote:

> Hi my name is okechukwu . I teaches computer at a low grade of 8, 9, 10, 12
> years ages .
>
> Please I would be pleased if you could assist us in helping our children to
> get to know programming skills
>
> I am not very vast in programming and know little in programming.

There is a Python education Special Interest Group(SIG) that you could 
join. It has a mailing list and focuses on issues around teaching Python.

http://www.python.org/community/sigs/current/edu-sig/

This list is more about providing hands on advice and help to those 
learning Python rather than those teaching it.

HTH,

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


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


Re: [Tutor] Cannot understand object initiation

2013-10-14 Thread Chris “Kwpolska” Warrick
On Mon, Oct 14, 2013 at 3:27 PM, Kush Goyal  wrote:
> Also, db is an sqlalchemy engine and db.Model is a class.
>
> db.Model is I think a sqlalchemy declarative base class which has all
> the needed methods and classes for database handling.
>
> So, did I get the above things right?

Not quite.  db.Model is basically a representation of a database
record.  Read this:
http://docs.sqlalchemy.org/en/rel_0_8/orm/tutorial.html

Note that the above document uses the name `Base` (declarative base)
to describe what Flask-SQLAlchemy calls `db.Model`.

-- 
Chris “Kwpolska” Warrick 
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: we need assistance in my school

2013-10-14 Thread Alan Gauld

On 14/10/13 11:54, Okechukwu Nkaronye wrote:


Hi my name is okechukwu . I teaches computer at a low grade of 8, 9, 10, 12
years ages .

Please I would be pleased if you could assist us in helping our children to
get to know programming skills

I am not very vast in programming and know little in programming.


There is a Python education Special Interest Group(SIG) that you could 
join. It has a mailing list and focuses on issues around teaching Python.


http://www.python.org/community/sigs/current/edu-sig/

This list is more about providing hands on advice and help to those 
learning Python rather than those teaching it.


HTH,

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

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


Re: [Tutor] Cannot understand object initiation

2013-10-14 Thread ALAN GAULD


I tried experimenting with classes and objects on python interpretor
>and learned that in python functions, classes, method, objects and
>modules all can be passed around and returned.That's correct, they are all 
>objects in Python


From what I understood from your answers:
>
>user = User.query.filter_by ( username = self.username.data ).first()
>
>returns a reference to an instance of class User. So user is an object
>of type User class.Not necessarily. first() can return any kind of object. It 
>just seems likely 
that in this case it will be a User. But it depends entirely on how the 
first() method of whatever object User.query.filter_by() is implemented.

Also, db is an sqlalchemy engine and db.Model is a class.
>
>db.Model is I think a sqlalchemy declarative base class which has all
>the needed methods and classes for database handling.
>
>Possibly but you'll need someone who knows SQLAlchemy better than 
me to answer definitively

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


[Tutor] Fwd: we need assistance in my school

2013-10-14 Thread Okechukwu Nkaronye
-- Forwarded message --
From: Okechukwu Nkaronye 
Date: Fri, 11 Oct 2013 13:04:10 +
Subject: we need assistance in my school
To: sanomat@formin.fi, off...@ise.edu.ee, supp...@edline.com,
cont...@thebaudieves.org, cont...@thebaudieres.org

Hi my name is okechukwu . I teaches computer at a low grade of 8, 9, 10, 12
years ages .

Please I would be pleased if you could assist us in helping our children to
get to know programming skills

I am not very vast in programming and know little in programming.



We dim it fit the create a forum for our younger ones to start early to
learn computer programming .



Much Anticipations

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


Re: [Tutor] Cannot understand object initiation

2013-10-14 Thread Kush Goyal
Hi,

Thanks a lot Bob and Allan for the help.

I tried experimenting with classes and objects on python interpretor
and learned that in python functions, classes, method, objects and
modules all can be passed around and returned.

>From what I understood from your answers:

user = User.query.filter_by ( username = self.username.data ).first()

returns a reference to an instance of class User. So user is an object
of type User class.

Also, db is an sqlalchemy engine and db.Model is a class.

db.Model is I think a sqlalchemy declarative base class which has all
the needed methods and classes for database handling.

So, did I get the above things right?

Thanks!

Kush


On Sat, Oct 12, 2013 at 10:17 PM, bob gailer  wrote:
> On 10/12/2013 11:01 AM, Kush Goyal wrote:
>>
>> [[snip]
>>
>> "user = User.query.filter_by ( username = self.username.data ).first()"
>>
>> now this I do not understand.
>>
>> Can a object be create by using a method of a class instead of the
>> class consturctor? I
>
> Without seeing the code you reference (User module) I can hazard a guess:
>
> This code is not creating an object - it is returning a reference to an
> existing object.
>
> The key to the object is username, and first() returns the first instance
> should there be more than one,
>
> User is some objectimported from myapplication.models.
> query is a callable object that is an attribute of User.
> filter_by is a callable object that is an attribute of query.
> first is a callable object that is an attribute of filter_by.
> Nothing in the above suggests object creation.
>
> HTH
>
> --
> Bob Gailer
> 919-636-4239
> Chapel Hill NC
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor