On Wed, Dec 14, 2011 at 6:03 PM, <[email protected]> wrote:
> Send Tutor mailing list submissions to
> [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
> [email protected]
>
> You can reach the person managing the list at
> [email protected]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
>
>
> Today's Topics:
>
> 1. Re: Tuple: Am I Understanding This Correctly? (Alan Gauld)
> 2. ctype exceptions.ValueError for function call
> (Santhirakumaran, Gokul)
> 3. while loops (rog capp)
> 4. Re: while loops (Steven D'Aprano)
> 5. Re: while loops (Dave Angel)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 14 Dec 2011 18:25:33 +0000
> From: Alan Gauld <[email protected]>
> To: [email protected]
> Subject: Re: [Tutor] Tuple: Am I Understanding This Correctly?
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 14/12/11 15:48, Homme, James wrote:
>> Am I explaining how this works correctly?
>
> You are not really explaining *how* it works, just saying what it does.
> What you are doing is sensible iff you have many places where the tuple
> is useful. In the specific case I'd personally just create the tuple at
> the point of use:
>
>> finish = (user_name, prompt)
>> likes = raw_input("Do you like me %s?\n%s" % finish)
>
> likes = raw_input("Do you like me %s?\n%s" % (user_name, prompt))
>
> Since it saves the reader referring back to the definition
> of finish (which is an odd nanme for user/prompt data IMHO).
>
>> # Use the tuple repeatedly when asking other questions.
>
> But, if you are using the tuple repeatedly then it starts
> to make sense.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 14 Dec 2011 21:15:38 +0000
> From: "Santhirakumaran, Gokul"
> <[email protected]>
> To: "'[email protected]'" <[email protected]>
> Subject: [Tutor] ctype exceptions.ValueError for function call
> Message-ID:
> <[email protected]>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi,
>
> I'm trying to use a SDK(dll file) with python ctypes to take measurement from
> a spectrometer. I some how got the deceive connected and took the measurement
> , but when I try to call one of its calculation function I'm getting the
> "exceptions.ValueError: Procedure probably called with not enough arguments
> (8 bytes missing)" error.
>
> I believe I have called the function with proper arguments and data types. I
> would really appreciate some help.
>
> The Function:
>
> mydll =
> ctypes.windll.LoadLibrary("D:\\WILD2\\tools\\WildVerification\\lib\\jeti_core.dll")
> device = ctypes.c_int()
> dvError = mydll.JETI_OpenDevice(0,ctypes.byref(device))
>
> X_value = ctypes.c_float()
> Y_value = ctypes.c_float()
> Z_value = ctypes.c_float()
>
> dvError =
> mydll.JETI_CalcXYZ(device,ctypes.byref(X_value),ctypes.byref(Y_value),ctypes.byref(Z_value))
>
> Function Documentation:
>
> 3.112 JETI_CalcXYZ
> This function returns the calculated tristimulus XYZ.
> 3.112.1 Prototype
> DWORD JETI_CalcXYZ (DWORD dwDevice, FLOAT *fX, FLOAT *fY, FLOAT *fZ)
> 3.112.2 Parameters
> Input
> Name Type Description
> Call
> dwDevice DWORD Handle to a device as
> By value
> returned by
> JETI_OpenDevice
>
> fX FLOAT* pointer to a variable
> By reference
> where the tristimulus X
> will be stored
>
> fY FLOAT * pointer to a variable
> By reference
> where the tristimulus Y
> will be stored
>
> fZ FLOAT * pointer to a variable
> By reference
> where the tristimulus Z
> will be stored
>
> -
> Gokul Santhirakumaran
> Electrical Engineer(Co-op)
>
> CHRISTIE
> 809 Wellington St. N.
> Kitchener, ON, Canada N2G 4Y7
> PH: +1 519-744-8005 x7313
> www.christiedigital.com<http://www.christiedigital.com>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> <http://mail.python.org/pipermail/tutor/attachments/20111214/7b01e759/attachment-0001.html>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 14 Dec 2011 17:41:24 -0500
> From: rog capp <[email protected]>
> To: [email protected]
> Subject: [Tutor] while loops
> Message-ID:
> <CAKP55S=jes4fcocy7hxi_dng2ywsf2mkeqz_9qzztf63edh...@mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> # Guess my number
> #
> # The computer picks a random number between 1 and 100
> # The player tries to guess it and the computer lets
> # the player know if the guess is to high, to low
> # or right on the money
>
> import random
>
> print("\tWelcome to 'Guess My Number'!")
> print("I'm thinking of a number between 1 and 100.")
> print("Try to guess it in as few attempts as possible.\n")
>
> # set the initial values
> the_number = random.randint(1,100)
> guess = int(input("Take a guess: "))
> tries = 1
>
> # Guessing loop
> while guess != the_number:
>
> if guess > the_number:
> print("Lowere...")
> else:
> print("Higher...")
>
> guess = int(input("Take a guess: "))
> tries += 1
>
> print("good job")
>
> input("\n\nPress the enter key to exit.")
>
>
>
> This is a program from "Python for the absulute beginner(which I am).
> End of the chapter is a challenge that asks me to limit the number of
> guesses the player gets.
> If he/she fails to guess the number after a certain number of attempts
> then it displays a message
> about his failure.It needs to be a while loop cause it the topic I'm
> at.Can anyone give me some help
> on where to put the loop.When i put it in with the "if
> guess>the_number" loop, the program either
> prints higher or lower continuously(continuous loop I imagine) or it
> gives me the answer whether its
> right or wrong after a couple guesses.Any help will be appreciated.
>
>
> ------------------------------
>
> Message: 4
> Date: Thu, 15 Dec 2011 09:55:43 +1100
> From: Steven D'Aprano <[email protected]>
> To: [email protected]
> Subject: Re: [Tutor] while loops
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> rog capp wrote:
> [...]
>> # Guessing loop
>> while guess != the_number:
>> if guess > the_number:
>> print("Lowere...")
>> else:
>> print("Higher...")
>> guess = int(input("Take a guess: "))
>> tries += 1
>>
>> print("good job")
>> input("\n\nPress the enter key to exit.")
>>
>>
>>
>> This is a program from "Python for the absulute beginner(which I am).
>> End of the chapter is a challenge that asks me to limit the number of
>> guesses the player gets.
>> If he/she fails to guess the number after a certain number of attempts
>> then it displays a message
>> about his failure.It needs to be a while loop cause it the topic I'm
>> at.Can anyone give me some help
>
> You need a counter to count how many guesses are made. You already have a
> variable counting the number of tries, so you are half-way there.
>
> The loop condition currently is:
>
> while guess != the_number
>
> or in English:
>
> "while the guess is not equal to the number: loop"
>
> Still in English, you want to change the condition to:
>
> "while the guess is not equal to the number and the number of
> tries is less than the maximum number of tries: loop"
>
> Translate that loop condition from English to Python, and you've got it.
>
> Then, once you have the loop fixed, the final change needed is to change the
> message printed at the end, outside the loop. Currently it unconditionally
> prints "good job". You need to change that to only print "good job" if the
> guess is equal to the number, otherwise print something else.
>
>
>
> --
> Steven
>
>
> ------------------------------
>
> Message: 5
> Date: Wed, 14 Dec 2011 18:03:51 -0500
> From: Dave Angel <[email protected]>
> To: rog capp <[email protected]>
> Cc: [email protected]
> Subject: Re: [Tutor] while loops
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 12/14/2011 05:41 PM, rog capp wrote:
>> # Guess my number
>> #
>> # The computer picks a random number between 1 and 100
>> # The player tries to guess it and the computer lets
>> # the player know if the guess is to high, to low
>> # or right on the money
>>
>> import random
>>
>> print("\tWelcome to 'Guess My Number'!")
>> print("I'm thinking of a number between 1 and 100.")
>> print("Try to guess it in as few attempts as possible.\n")
>>
>> # set the initial values
>> the_number = random.randint(1,100)
>> guess = int(input("Take a guess: "))
>> tries = 1
>>
>> # Guessing loop
>> while guess != the_number:
>>
>> if guess> the_number:
>> print("Lowere...")
>> else:
>> print("Higher...")
>>
>> guess = int(input("Take a guess: "))
>> tries += 1
>>
>> print("good job")
>>
>> input("\n\nPress the enter key to exit.")
>>
>>
>>
>> This is a program from "Python for the absulute beginner(which I am).
>> End of the chapter is a challenge that asks me to limit the number of
>> guesses the player gets.
>> If he/she fails to guess the number after a certain number of attempts
>> then it displays a message
>> about his failure.It needs to be a while loop cause it the topic I'm
>> at.Can anyone give me some help
>> on where to put the loop.When i put it in with the "if
>> guess>the_number" loop, the program either
>> prints higher or lower continuously(continuous loop I imagine) or it
>> gives me the answer whether its
>> right or wrong after a couple guesses.Any help will be appreciated.
>> _
> You already have a while-loop. So add another condition to it:
> while guess != answer and tries< 10:
>
> then outside the loop, write an if-test conditional on whether guess ==
> number
>
> If so, tell him good job, if not, tell him he took too many tries.
>
> --
>
> DaveA
>
>
>
> ------------------------------
>
> _______________________________________________
> Tutor maillist - [email protected]
> http://mail.python.org/mailman/listinfo/tutor
>
>
> End of Tutor Digest, Vol 94, Issue 53
> *************************************
while guess != the_number and tries < 5:
if guess > the_number:
print("Lower...")
else:
print("Higher...")
guess = int(input("Take a guess: "))
tries += 1
if guess == the_number:
print("good job the number was, " , the_number)
print("it took you" , tries," tries.")
else:
print("Sorry you took to many tries")
THANKS Steve and Dave got it working now.
roGca
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor