[Solved] Python what does abs do? I have tried looking at different pages for help, however i cannot understand the jargon [closed]

>>> help(abs) Help on built-in function abs in module __builtin__: abs(…) abs(number) -> number Return the absolute value of the argument. Also the documentation If the number passed to the function is negative, it returns the positive. If it is positive, it returns it unchanged. Think of it as removing the – negative sign. >>> … Read more

[Solved] Generate random numer in python?

You’ve got two syntax errors, a spacing error, and you’re using a keyword which doesn’t exist. if gameA>0.4 #<– end this with a colon profitA=profitA+1 #<– needs more indent end #<– what is end? All of that is repeated in gameB. In addition: profitA and profitB aren’t defined in testA and testB. testA is the … Read more

[Solved] Want to read sequential lines in a file and do some mathematical calculation [closed]

Even though 5 persons down voted my question, I found my on way to solve the problem. Here is the code which I used. It is written in Python. enter codefrom numpy import * from math import * import operator f = open(‘Data_Genergy_26.txt’, ‘r’) lines = f.readlines() # initialize some variable to be lists: r … Read more

[Solved] Executing several commands at once [closed]

You should show what you have written, or we have no way of knowing what might be a “better way” You should probably take a look at Parallel::ForkManager. Using that module your program could look something like this There’s a lot missing from this code, most importantly use strict and use warnings ‘all’, and the … Read more

[Solved] AttributeError: ‘NoneType’ object has no attribute ‘find_all’ (Many of the other questions asked weren’t applicable)

It means you try to call find_all on the value None. That could be row.tbody for example, perhaps because there is no <tbody> in the actual HTML. Keep in mind that the <tbody> element is implied. It’ll be visible in your browser’s DOM inspector, but that doesn’t mean it is actually present in the HTML … Read more

[Solved] What is wrong with my translator? (Python) [closed]

I assume you want something like: def answer(plaintext): words = {“a”:’100000′,”b”:’110000′,”c”:’100100′,”d”:’100110′,”e”:’100010′,”f”:’110100′,”g”:’110110′,”h”:’110010′,”i”:’010100′,”j”:’010110′,”k”:’101000′,”l”:’111000′,”m”:’101100′,”n”:’101110′,”o”:’101010′,”p”:’111100′,”q”:’111110′,”r”:’111010′,”s”:’011100′,”t”:’011110′,”u”:’101001′,”v”:’111001′,”w”:’010111′,”x”:’010111′,”y”:’101011′,”z”:’101011′} inputList = plaintext.split(‘,’) for word in inputList: print words[word] text = “j,o,s,e” answer(text) You had a bunch of typos in your dict, pay attention to the traceback, it tells you exactly what’s wrong. You also never actually called the function you defined. You probably … Read more

[Solved] Python create list combination

You haven’t specified in what order the keys of the dictionary should be processed in the output. If one assumes reverse sorting order, you can do this trivially with itertools.product(): from itertools import product combinations = product(*([‘{0}{1}’.format(v, i) for i in range(dictElement[v])] for v in sorted(dictElement, reverse=True)) Demo: >>> from itertools import product >>> dictElement … Read more

[Solved] Simple Client Manager Soft – C# with Visual Studio or Java with Eclipse? [closed]

This is perhaps not the best question to ask on SO as it’s bound to get opinions rather than answers, with this in mind, I will give you my opinionated answer. As your first real life application, it’s probably best you go with something you’re somewhat familiar with, either that or find a solution with … Read more