User Profile
Collapse
-
But the problem is that they return 1, not a floating point. -
But which would be the correct form?
Because neither
Code:num=(m+1)/float(m)
Code:num=(m+1)/(m*1.0)
Leave a comment:
-
Strange issue with normal operations
Hello, I was writing a very simple code and I noticed something was failing. I detected the problematic part but I CANNOT find wheres the error.
The code is:
Code:def pri(max): for m in range(1,max): num=(m+1)/m if num==1: print 'ERROR' else: print 'OK'
Code:ERROR ERROR ERROR ERROR ERROR
-
-
Gonzalo Gonza started a topic I get "expected primary-expression before '<<' token" error don't know whyin CI get "expected primary-expression before '<<' token" error don't know why
I get this error don't know why
Here's the code:
Code:double z=dt/dd; double y=(ut-z*ud)/uu; double x=(ct-(z*cd)-(y*cu))/cc; cout<<"x="<<x<<"\n"<<<<"y="<<y<<"\n"<<"z="<<z<<"\n";
-
Keylogger in Python
Hello, I was wondering about events and that kind of things, so I decided to do a program that would listen to my keystrokes.
The (core) code is the following:
Code:while 1: keyAscii = 0 for i in range(32, 256): key_log = win32api.GetAsyncKeyState(i) if key_log == -32767: print i key_end = 81 keylog_file.write(chr(i)) if i == key_end: keylog_file.close()
-
And how it would be?
Code:import os file = open("os.environ['SYSTEMDRIVE']\\Windows\\system32\\asdfasdf.txt","w")
Leave a comment:
-
How to use Environment Variables to set location of file in Python?
Hello there,
I want to create a txt in system32, but I want to do that using an environment variable.
I want to use an environment variable instead of this:
Code:file = open("C:\\Windows\\system32\\asdfasdf.txt","w")
So, which would be the correct form?
Thank you -
ooooooohh
Thank you VERY much, I owe you one, that code is a piece of gold.
Thank youLeave a comment:
-
Also I proved your algorithm and its speed equation is t=1,0*10^-84 x^51,4 and mine was t=7,8*10^-26 x^16,23, so mine is faster.Leave a comment:
-
Thank you, but I forgot a part of the code. In the end it says:
Code:return a
Leave a comment:
-
Function to determinate whether a number is prime or not
Hello, I made a function to define whether a number n is prime or not. But I have two problems that will be described, but first let's go to the function:
Code:def esprimo(n): m=str(n) if n<=1: a=False elif n==2: a=True elif int(m[-1])==(2 or 4 or 6 or 8 or 0 or 5): a=False elif n%3==0: if n!=3: a=False else: a=True elif n%7==0: if
-
I think that you can embed a piece of batch, that would be netstat -a
The code will be something like this:
Code:from os import system os.system('netstat -a') #And if you want to write it in a txt you can do: s=open('hellothere.txt', 'w') s.write(os.system('netstat -a')) s.close()
Leave a comment:
-
TypeError: 'file' object is not subscriptable python
When I execute this code (if the number finishes in 2 returns true, else none)
Code:def asdf(n): n=str(m) elif m[-1]==2: return True
I get the following Error:
Code:Traceback (most recent call last): File "C:\***\***.py", line 3, in asdf elif int(m[-1])==2: TypeError: 'file' object is not subscriptable
I also tried
Code:elif i
-
Thank you, but I forgot to say that this funcion will recieve huge numbers, and the method with the module would be very inefficient.Leave a comment:
-
Multiple conditions in a single IF
I want to know whether a number is a multiple of 2 and/or 5
But Python doesn't let me put lots of things after the '=='
Here's my code:
Code:def asdf(n): n=str(m) if n==2: a=True elif n==5: a=True elif m[-1:]==2 or 4 or 6 or 8 or 0 or 5: a=True
Code:elif m[-1:]==2, 4, 6, 8, 0, 5:
I wish...
No activity results to display
Show More
Leave a comment: