[Tutor] (no subject)

2017-08-03 Thread Howard Lawrence
hi ! i am newbie to coding love it but need help with problems which i
searched but poor results this is the error: typeError unorderable types:
int()https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (regarding unorderable types

2017-08-04 Thread Howard Lawrence
Thank you for the clarification.
as a newbie at mailing list and coding
I try to be more specific,their is more to come

On Aug 3, 2017 10:09 PM, "Cameron Simpson"  wrote:

Hi, and welcome to the tutor list.

Please try to provide a useful subject line in future posts (not "help",
perhaps something like "I don't understand this TypeError message").

Anyway, to your question:

On 03Aug2017 13:27, Howard Lawrence <1019sh...@gmail.com> wrote:

> hi ! i am newbie to coding love it but need help with problems which i
> searched but poor results this is the error: typeError unorderable types:
> int()

Please always include the entire error message with a text cut/paste; it
usually contains lots of useful information.

The error above means that you have a "int" and a "str", and are trying to
compare them. That is not supported.

the code in short
>

Please always incode the full code, ideally something stripped down to the
smallest program you can run which still produces the error. Often problems
come from something which is omitted in a "from memory" description of the
code, rather than the raw code itself.

number=random.randint(1,20)
> guess=input()
> guess=int(guess)
> but when reach the line that says
> if guess
> i get the error ! help
>

As remarked, you can't compare an int and a str; it is not meaningful.

Your code above _should_ have an int in the value of "guess". However, I
suspect your code actually may look like this:

 number=random.randint(1,20)
 guess=input()
 guess_value=int(guess)
 if guess (formerly c...@zip.com.au)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] unorderable types

2017-08-05 Thread Howard Lawrence
Typing the : print("type (guess_value)=", type (guess_value))
print("type (number)=",type(number)

type (guess_value)= 
type (number)= 

==
the code runs again then prints
type guess_value =< class int>
type number=

=
Now Traceback kicks in
if guess_value < number:
TypeError : unorderable types: int() < str()

Ran the code from Cmd prompt
Got TypeError not supported between
Instance of 'int' and 'str'
=
It's seems up till
If guess_value < number:
 guess_value is a integer
 also number which the computer generated
 =
Still scratching my head-:(
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] unorderable types

2017-08-05 Thread Howard Lawrence
# this is a guess number game.
import random

guessesTaken = 0

print('hello! What is your name?')
myName = input()

number = random.randint(1, 20)
print('Well, ' + myName + ', i am thinking of a number between 1 and 20')

while guessesTaken < 6:
print('take a guess.')
guess = input()
guess_value = int(guess)

guessesTaken = guessesTaken + 1

print("type(guess_value)=",type(guess_value))
print("type(number)=",type(number))

if guess_value < number:
print('your guess is too low.')

if guess_value > number:
print('your guess is too high.')

if guess_value == number:
break

if guess_value == number:
   guessesTaken = str(guessesTaken)
   print ('good job, ' + myName + '! you guessed my number in ' +
guessesTaken + ' guesses!')

if guess_value != number:
number = str(number)
print ('nope. the number i was thinking of was ' + number)

# this is a guess number game.
import random

guessesTaken = 0

print('hello! What is your name?')
myName = input()

number = random.randint(1, 20)
print('Well, ' + myName + ', i am thinking of a number between 1 and 20')

while guessesTaken < 6:
print('take a guess.')
guess = input()
guess_value = int(guess)

guessesTaken = guessesTaken + 1

print("type(guess_value)=",type(guess_value))
print("type(number)=",type(number))

if guess_value < number:
print('your guess is too low.')

if guess_value > number:
print('your guess is too high.')

if guess_value == number:
break

if guess_value == number:
   guessesTaken = str(guessesTaken)
   print ('good job, ' + myName + '! you guessed my number in ' +
guessesTaken + ' guesses!')

if guess_value != number:
number = str(number)
print ('nope. the number i was thinking of was ' + number)

# this is a guess number game.
import random

guessesTaken = 0

print('hello! What is your name?')
myName = input()

number = random.randint(1, 20)
print('Well, ' + myName + ', i am thinking of a number between 1 and 20')

while guessesTaken < 6:
print('take a guess.')
guess = input()
guess_value = int(guess)

guessesTaken = guessesTaken + 1

print("type(guess_value)=",type(guess_value))
print("type(number)=",type(number))

if guess_value < number:
print('your guess is too low.')

if guess_value > number:
print('your guess is too high.')

if guess_value == number:
break

if guess_value == number:
   guessesTaken = str(guessesTaken)
   print ('good job, ' + myName + '! you guessed my number in ' +
guessesTaken + ' guesses!')

if guess_value != number:
number = str(number)
print ('nope. the number i was thinking of was ' + number)

# this is a guess number game.
import random

guessesTaken = 0

print('hello! What is your name?')
myName = input()

number = random.randint(1, 20)
print('Well, ' + myName + ', i am thinking of a number between 1 and 20')

while guessesTaken < 6:
print('take a guess.')
guess = input()
guess_value = int(guess)

guessesTaken = guessesTaken + 1

print("type(guess_value)=",type(guess_value))
print("type(number)=",type(number))

if guess_value < number:
print('your guess is too low.')

if guess_value > number:
print('your guess is too high.')

if guess_value == number:
break

if guess_value == number:
   guessesTaken = str(guessesTaken)
   print ('good job, ' + myName + '! you guessed my number in ' +
guessesTaken + ' guesses!')

if guess_value != number:
number = str(number)
print ('nope. the number i was thinking of was ' + number)

# this is a guess number game.
import random

guessesTaken = 0

print('hello! What is your name?')
myName = input()

number = random.randint(1, 20)
print('Well, ' + myName + ', i am thinking of a number between 1 and 20')

while guessesTaken < 6:
print('take a guess.')
guess = input()
guess_value = int(guess)

guessesTaken = guessesTaken + 1

print("type(guess_value)=",type(guess_value))
print("type(number)=",type(number))

if guess_value < number:
print('your guess is too low.')

if guess_value > number:
print('your guess is too high.')

if guess_value == number:
break

if guess_value == number:
   guessesTaken = str(guessesTaken)
   print ('good job, ' + myName + '! you guessed my number in ' +
guessesTaken + ' guesses!')

if guess_value != number:
number = str(number)
print ('nope. the number i was thinking of was ' + number)

=
dont understand the error TypeError unorderable types 'int()' <' str()'
run the code from cmd prompt also error
inserted a print function before the first "if" statement
which return type (guess_value) = 
type(number) = 
==

Re: [Tutor] Tutor Digest, Vol 162, Issue 19

2017-08-06 Thread Howard Lawrence
On Aug 6, 2017 11:00 AM,  wrote:

Send Tutor mailing list submissions to
tutor@python.org

To subscribe or unsubscribe via the World Wide Web, visit
https://mail.python.org/mailman/listinfo/tutor
or, via email, send a message with subject or body 'help' to
tutor-requ...@python.org

You can reach the person managing the list at
tutor-ow...@python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tutor digest..."

Today's Topics:

   1. Re: unorderable types (Cameron Simpson)


-- Forwarded message --
From: Cameron Simpson 
To: tutor@python.org
Cc:
Bcc:
Date: Sun, 6 Aug 2017 17:40:02 +1000
Subject: Re: [Tutor] unorderable types
On 06Aug2017 07:19, Alan Gauld  wrote:

> On 05/08/17 19:28, Howard Lawrence wrote:
>
>> if guess_value != number:
>> number = str(number)
>> print ('nope. the number i was thinking of was ' + number)
>>
>
> There is the problem, you convert number to a str before printing
> it. so next iteration of the loop your if test fails.
>
> You don't need the conversion in this case because print does it
> automatically.
>

I should point out that print doesn't magicly let you "+" a str and an int.
You would need to write:

 print ('nope. the number i was thinking of was ', number)

You can see that that doesn't use "+". The print function calls str() on
each of its arguments, then writes the result to the output. str() on the
string returns itself, and str(number) returns the number in text form.

You can see then that you don't need str(number) yourself, and therefore do
not need to store it in a variable.

Also, while you can bind a value of any type to any variable, as you have
here by binding an int to "number" and then later a str to "number", it is
not a great idea. A particular variable should usually always hold the same
type of value; this storing of different types of values in the same
variable contributed to your problem.

Cheers,
Cameron Simpson  (formerly c...@zip.com.au)

Thanks for everything,it's running

 saw where storing two different types in the same variable!
   Digesting your pointers !


___
Tutor maillist  -  Tutor@python.org
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


[Tutor] (no subject)

2017-08-16 Thread Howard Lawrence
class Address:
def _init_(self,Hs,St,Town,Zip):
  self.HsNunber=Hs
  self.Street=St
  self.Town=Town
  self.Zip=Zip
Addr=Address (7, ' high st', 'anytown', ' 123 456')


Traceback (most recent call last):
File "", line 1, in< module>
Addr = Address (7, 'High St', 'anytown', '123 456')
TypeError: object () takes no parameters

 how to fix this and where I went wrong

 This happened to me in other coding
But I skipped it,but it keeps returning!
This is from a tutorial
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Object takes no parameters

2017-08-16 Thread Howard Lawrence
class Human:
 def _init_(self, n, o)
  self.name = n
  self.occupation = o

 def do_work(self):
 if self.occupation== 'tennis player':
print(self.name, 'plays tennis')

 elif self.occupation == 'actor':
print(self.name, 'shoots film')

 def speaks(self):
 print(self.name, 'how are you')

tom = Human('tom cruise', 'actor')
tom.do_work()
tom.speak()

Traceback most recent call last
File "c:\users\shaun\python\python35\human_class.py"line 16 in module
tom =Human('tom cruise', 'actor')
TypeError: object() takes no parameters

how to fix this?why it happens?
this happens whenever i try to do
class,this is from a tutorial
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Digest, Vol 162, Issue 42

2017-08-17 Thread Howard Lawrence
On Aug 17, 2017 3:17 AM,  wrote:

Send Tutor mailing list submissions to
tutor@python.org

To subscribe or unsubscribe via the World Wide Web, visit
https://mail.python.org/mailman/listinfo/tutor
or, via email, send a message with subject or body 'help' to
tutor-requ...@python.org

You can reach the person managing the list at
tutor-ow...@python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tutor digest..."

Today's Topics:

   1. Object takes no parameters (Howard Lawrence)
   2. Re: (no subject) (Zachary Ware)
   3. Re: Object takes no parameters (Alan Gauld)
   4. Re: (no subject) (Alan Gauld)
   5. Re: "Path tree" (Abdur-Rahmaan Janhangeer)
   6. Re: "Path tree" (Michael C)


------ Forwarded message --
From: Howard Lawrence <1019sh...@gmail.com>
To: tutor@python.org
Cc:
Bcc:
Date: Wed, 16 Aug 2017 17:08:47 -0700
Subject: [Tutor] Object takes no parameters
class Human:
 def _init_(self, n, o)
  self.name = n
  self.occupation = o

 def do_work(self):
 if self.occupation== 'tennis player':
print(self.name, 'plays tennis')

 elif self.occupation == 'actor':
print(self.name, 'shoots film')

 def speaks(self):
 print(self.name, 'how are you')

tom = Human('tom cruise', 'actor')
tom.do_work()
tom.speak()

Traceback most recent call last
File "c:\users\shaun\python\python35\human_class.py"line 16 in module
tom =Human('tom cruise', 'actor')
TypeError: object() takes no parameters

how to fix this?why it happens?
this happens whenever i try to do
class,this is from a tutorial



-- Forwarded message --
From: Zachary Ware 
To: tutor 
Cc: Howard Lawrence <1019sh...@gmail.com>
Bcc:
Date: Wed, 16 Aug 2017 20:02:23 -0500
Subject: Re: [Tutor] (no subject)
Hi Howard,

On Wed, Aug 16, 2017 at 5:36 PM, Howard Lawrence <1019sh...@gmail.com>
wrote:
> class Address:
> def _init_(self,Hs,St,Town,Zip):

Your issue is in this line, it should be `__init__` rather than
`_init_` (that is, two underscores before and after "init").

Hope this helps,
--
Zach



-- Forwarded message --
From: Alan Gauld 
To: tutor@python.org
Cc:
Bcc:
Date: Thu, 17 Aug 2017 02:11:43 +0100
Subject: Re: [Tutor] Object takes no parameters
On 17/08/17 01:08, Howard Lawrence wrote:
> class Human:
>  def _init_(self, n, o)
>   self.name = n
>   self.occupation = o
>

>
> tom = Human('tom cruise', 'actor')
>
> Traceback most recent call last
> File "c:\users\shaun\python\python35\human_class.py"line 16 in module
> tom =Human('tom cruise', 'actor')
> TypeError: object() takes no parameters
>
> how to fix this?why it happens?

If you look closely at your tutorial you will find that init()
has two underscores before and after the name:

def __init__()

rather than

def _init_()

The reason for your error is that all classes inherit from object.
So when you call Human() the interpreter looks for an __init__()
method and, not finding one(because yours only has one undercore),
it looks at the one defined in object. But the object init()
takes no parameters and so there is a mismatch between your
call to Human() and the object.__init__() definition.
Hence the error message.

To fix it use two underscores.

All of the "magic" methods used by Python have these double
underscores and  hence are often referred to as "dunder" methods.
You should avoid defining any new methods (ie new names) with
double underscores yourself, in case Python introduces  a
similar method in a future version.

HTH
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos





-- Forwarded message --
From: Alan Gauld 
To: tutor@python.org
Cc:
Bcc:
Date: Thu, 17 Aug 2017 02:16:19 +0100
Subject: Re: [Tutor] (no subject)
On 16/08/17 23:36, Howard Lawrence wrote:
> class Address:
> def _init_(self,Hs,St,Town,Zip):
>   self.HsNunber=Hs
>   self.Street=St
>   self.Town=Town
>   self.Zip=Zip
> Addr=Address (7, ' high st', 'anytown', ' 123 456')

That looks suspiciously like my tutorial ;-)

The answer is to use two underscores around init():

def __init__(...)

not

def _init_(...)

This is explained in more detail in a box at the end
of the data topic:

http://www.alan-g.me.uk/l2p/tutdata.htm

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

Re: [Tutor] (no subject)

2017-08-17 Thread Howard Lawrence
Yes, it does.

On Aug 16, 2017 8:02 PM, "Zachary Ware" 
wrote:

Hi Howard,

On Wed, Aug 16, 2017 at 5:36 PM, Howard Lawrence <1019sh...@gmail.com>
wrote:
> class Address:
> def _init_(self,Hs,St,Town,Zip):

Your issue is in this line, it should be `__init__` rather than
`_init_` (that is, two underscores before and after "init").

Hope this helps,
--
Zach


Thanks it worked! Stick around, more to come
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] calling function

2017-11-27 Thread Howard Lawrence
import turtle
# this part draws a square
def square():

my_turtle = turtle.Turtle()
my_turtle.forward(100)
my_turtle.left(90)
my_turtle.forward(100)
my_turtle.left(90)
my_turtle.forward(100)
my_turtle.left(90)
my_turtle.forward(100)
square()

my_turtle.forward(100)

# this is a second square
square()

   # my_turtle.forward(100)
   # my_turtle.left(90)
   # my_turtle.forward(100)
   # my_turtle.left(90)
   # my_turtle.forward(100)
   # my_turtle.left(90)
   # my_turtle.forward(100)



what is wrong with this, and how to fix it
the code is suppose to make two box but only make one
using python 3.5 idle on windows 7
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor