top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

how to calculate reputation in python

0 votes

I am "confused"..We set the initial value to 0, +1 for up-vote and -1 for down-vote! nice.

I have a list of bool values True, False (True for up vote, False for down-vote).. submitted by users. [True, False, False, True....], Now to calculate the total reputation
should I take True = +1, False=0 [or] True = +1, False=-1 ?? for adding all. I am missing something here.. and thats clear.. anyone please help me on it?

posted Jul 2, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

2 Answers

+1 vote
Best answer

It depends what you want to do.

I suggest This aint so simple, but it's the correct way to sort by "approval". In fact, it's bloody confusing.

To assume that only the "sum" approval counts, I'd not suggest {True: 1, False: 0}. The problem is that a "downvote" then becomes pointless. So probably go with False as -1.

So you'd want:
sum((1 if vote else -1) for vote in votes)

answer Jul 2, 2013 by anonymous
+1 vote

You're using False to represent a down-vote and you want down-votes to count as -1, so you would count a False value as -1.

Now why don't you just use 1 and -1 to represent the votes instead of True and False? Then you won't need to worry about this conversion step.

answer Jul 2, 2013 by anonymous
Similar Questions
+2 votes

Above code is simulating single click on button but not press Key Hold but I want to hold the until key up event is called
eg: for key 'a' down it have to simulate key continous set until keyUp is called but not like "a"

Please specify any python API to simulate continues keyDown until it receives keyUp event

+2 votes

I would like to download a file. If the connection is OK, I can download the file with:

import urllib.request
urllib.request.urlretrieve(remote_file, local_file)

Sometimes when I am connected on week wireless (not mine) network I get WinError 10054 exception (windows 7). When it happens, I would like to resume download instead of doing everything from very beginning.

How to do that? I read about Range header and chunks, but this server doesn't have any headers.
What options do I have with this particular file?

Useful Links with Similar Problem
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.