¡@

Home 

python Programming Glossary: num

Base 62 conversion in Python

http://stackoverflow.com/questions/1119722/base-62-conversion-in-python

def base62_encode num alphabet ALPHABET Encode a number in Base X `num` The number.. def base62_encode num alphabet ALPHABET Encode a number in Base X `num` The number to encode `alphabet` The alphabet.. num alphabet ALPHABET Encode a number in Base X `num` The number to encode `alphabet` The alphabet to use for encoding..

Fastest way to list all primes below N in python

http://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python

a couple of Project Euler's questions. def get_primes n numbers set range n 1 1 primes while numbers p numbers.pop primes.append.. def get_primes n numbers set range n 1 1 primes while numbers p numbers.pop primes.append p numbers.difference_update.. n numbers set range n 1 1 primes while numbers p numbers.pop primes.append p numbers.difference_update set range..

convert integer to a string in a given numeric base in python

http://stackoverflow.com/questions/2267362/convert-integer-to-a-string-in-a-given-numeric-base-in-python

integer to a string in a given numeric base in python Python allows easy creation of an integer.. string from an integer. i.e. I want some function int2base num base such that int int2base X BASE BASE X the function name.. X the function name argument order is unimportant For any number X and base BASE that int will accept. This is an easy function..

How slow is Python's string concatenation vs. str.join?

http://stackoverflow.com/questions/3055477/how-slow-is-pythons-string-concatenation-vs-str-join

String Concatenation Method 1 def method1 out_str '' for num in xrange loop_count out_str `num` return out_str Method 4 def.. method1 out_str '' for num in xrange loop_count out_str `num` return out_str Method 4 def method4 str_list for num in xrange.. `num` return out_str Method 4 def method4 str_list for num in xrange loop_count str_list.append `num` return ''.join str_list..

Python: simple list merging based on intersections

http://stackoverflow.com/questions/9110837/python-simple-list-merging-based-on-intersections

efficient way to do this on large data elements are just numbers Is tree structure something to think about I do the job.. large_list_sizes else size random.choice small_list_sizes nums set c for j in xrange size x random.choice list nums lst.append.. nums set c for j in xrange size x random.choice list nums lst.append x nums.remove x random.shuffle lst lists.append..