Re: [Tutor] calling printf() in a C language DLL using ctypes.CDLL

2018-05-08 Thread eryk sun
On Wed, May 9, 2018 at 1:30 AM, Brad M wrote: > > If you want to know where your program went when something went wrong or > when it triggers a if condition, how do you do it? Look into use the logging module [1] and debuggers [2], either dedicated like Winpdb or in an IDE such as PyCharm. [1]:

Re: [Tutor] calling printf() in a C language DLL using ctypes.CDLL

2018-05-08 Thread eryk sun
On Tue, May 8, 2018 at 9:39 AM, Brad M wrote: > > I compile this by typing this in the command line: > cl /LD /I C:\python\include helloworld.c C:\python\libs\python36.lib You're not using Python's C API, so you only need `cl /LD helloworld.c`. > However, this doesn't print anything on the pytho

Re: [Tutor] Return keys with unique values from a dict

2018-05-08 Thread Mats Wichmann
On 05/08/2018 04:33 PM, Glen wrote: > Hello, > > I had a task to define a function that would take a dict input and return > only the keys with unique values into a list. > > Here is my code, which was awarded full marks, but I am pretty unhappy with > it. I feel like I did a band-aid job after m

[Tutor] Return keys with unique values from a dict

2018-05-08 Thread Glen
Hello, I had a task to define a function that would take a dict input and return only the keys with unique values into a list. Here is my code, which was awarded full marks, but I am pretty unhappy with it. I feel like I did a band-aid job after my first submission did pass mall the unit tests. I

Re: [Tutor] guess my number game

2018-05-08 Thread Alan Gauld via Tutor
The first block of code is full of errors and couldn't work so I have no idea what you were really doing! The second block should kind of work. From your description I'd guess you have an indentation error such that most of the code that should be inside the loop is being bypassed. Are you sur

Re: [Tutor] How to separate UI code from program logic?

2018-05-08 Thread Alan Gauld via Tutor
Bob, On 8 May 2018, at 19:56, boB Stepp < >Judging from the lack of responses, I guess I must have been on track >on the other questions. On The basics yes. There were a few picky details I would normally have mentioned but I'm on vacation and replying inline via gmail on my tablet is just too

Re: [Tutor] calling printf() in a C language DLL using ctypes.CDLL

2018-05-08 Thread Alan Gauld via Tutor
I'm guessing at the answer here because I'm on vacation with no access to a pc of any kind let alone Windows. But are you running python inside an ide? If so you might find you get the expected result if you use a command prompt, since printf usually sends output to stdout. This is another exam

[Tutor] calling printf() in a C language DLL using ctypes.CDLL

2018-05-08 Thread Brad M
Hi all: I am trying out some c based module in a .dll file on windows. // helloworld.c #include __declspec(dllexport) void helloworld() { printf("Hello Everyone!!!"); } I compile this by typing this in the command line: cl /LD /I C:\python\include helloworld.c C:\python\libs\python36.lib

Re: [Tutor] How to separate UI code from program logic?

2018-05-08 Thread boB Stepp
On Mon, May 7, 2018 at 12:26 AM, boB Stepp wrote: > def get_collatz_number(integer): > """Returns the Collatz sequence number corresponding to integer. integer > must be > 0, or the sequence will not converge to 1.""" > > if integer % 2 == 0: > return integer // 2 > else:

Re: [Tutor] guess my number game

2018-05-08 Thread Mats Wichmann
On 05/08/2018 06:04 AM, Jan Erik Moström wrote: > >> Here is the code with the while loop >> import random >> n = (random.randint(0,100)) >> g = int(input('Guess my number, 0 to 100, you have 10 chances')) you should get your students into good programming habits right away. Here you are taking d

Re: [Tutor] guess my number game

2018-05-08 Thread Jan Erik Moström
Here is the code with the while loop import random n = (random.randint(0,100)) g = int(input('Guess my number, 0 to 100, you have 10 chances')) c = 0 while (c < 10): g = int(input('Guess my number, 0 to 100, you have 10 chances')) c = c + 1 if (g >= n): print('Lower!') el

[Tutor] guess my number game

2018-05-08 Thread Kerri Murphy
My students are creating a guess my number game. They are trying to take this type of code (the flow of it), and turn it into a code using a while loop. Here is the first code n = int(input('Guess my number: '))if (n <= 172 and n >= 174): print('Correct')elif (n >= 174): a = int(input('Go