# number « integer « Python Data Type Q&A

Home
Python Data Type Q&A
 1 array 2 date 3 dictionary 4 Format 5 integer 6 List 7 numpy 8 regex 9 string 10 tuple
 Python Data Type Q&A » integer » number

### 1. Python: Convert list of ints to one number?    stackoverflow.com

I have a list of integers that I would like to convert to one number like:

``````numList = [1,2,3]
num = magic(numList)

print num, type(num)
>>> 123, <type 'int'>
``````
What is the best way to implement ...

### 2. Is there a way to Convert Number words to Integers? Python    stackoverflow.com

I need to convert 'one' into '1' 'two' into '2' and so on. Is there a way to do this a library or a class or anything?

### 3. Convert a number to a list of integers    stackoverflow.com

How do I write the `magic` function below?

``````>>> num = 123
>>> lst = magic(num)
>>>
>>> print lst, type(lst)
[1, 2, 3], <type 'list'>
``````

### 4. How to convert strings numbers to integers in a list?    stackoverflow.com

I have a list say:

``````['batting average', '306', 'ERA', '1710']
``````
How can I convert the intended numbers without touching the strings? Thank you for the help.

### 5. Python: List to ints to a single number?    stackoverflow.com

Say i have a several list if ints:

``````x =  [['48', '5', '0'], ['77', '56', '0'],
['23', '76', '34', '0']]
``````
I want this list to be converted to a single number, but the ...

### 6. Python: List of lists of integers to absolute value to single number    stackoverflow.com

If i had a list of list of integers say:

[['12' '-4' '66' '0'], ['23' '4' '-5' '0'], ['23' '77' '89' '-1' '0']]
I wanted to convert the numbers to ...

### 7. Reading a triangle of numbers into a 2d array of ints in Python    stackoverflow.com

I want to read a triangle of integer values from a file into a 2D array of ints using Python. The numbers would look like this: 75 95 64 17 47 82 18 35 87 ...

### 8. Python parse comma-separated number into int    stackoverflow.com

Possible Duplicate:
How do I use Python to convert a string to a number if it has commas in it as thousands separators?
How would I ...

### 9. What's the relationship between numbers.Integral and int in builtins module in Python 3    stackoverflow.com

I am a newbie for Python, I am a little confuse of the relationship between numbers.Integral and int in builtins module. Then my questions are:

1. What the relationship between numbers.Integral and int? Is ...

### 10. Is there a good python library that can turn numbers into their respective "symbols"?    stackoverflow.com

0 = 0 1 = 1 ... 9 = 9 10 = a 11 = b ... 35 = z 36 = A 37 = B ... 60 ...

### 11. Check if a number is int or float    stackoverflow.com

Here's how I did it:

``````inNumber = somenumber
inNumberint = int(inNumber)
if inNumber == inNumberint:
print "this number is an int"
else:
print "this number is a float"
``````
Something like ...

### 12. Moving the point downwards in a floating point number    stackoverflow.com

First off all, thanks for the attention, I'm new to this site ^^ so excuse me if I do something wrong... I have a huge problem with my Python code... I'm new ...

### 13. Python - Converting a Number to a Letter without an if statement    stackoverflow.com

I am making a program for my own purposes (a naming program) that completely generates a random name. The problem is I cannot assign a number to a letter, so as ...

### 14. Parsing numbers of integer and real type in string    stackoverflow.com

I have got a list of strings of the following format:

``````[ "%AB0.1.100", "%TB4.1.15" ]
``````
How i can parse this strings, that a i'd like to take for 1st element of list "0.1" ...

### 15. How to test with Python if str variable contains number (int,float) or non-numeric str    stackoverflow.com

If a Python string variable has had either an integer, floating point number or a non-numeric string placed in it, is there a way to easily test the "type" of that ...

### 16. Display number int in Python    stackoverflow.com

How to display numbers integer in python ? For example:

``````number1 = raw_input('Write one number:  ')
number2 = raw_input('Write other number: ')
result =  number1 + number2
print "The sum of the numbers is: ...``````

### 17. Computing persistence number of an integer    stackoverflow.com

I am trying to make a code that does the following:

Multiplying the digits of an integer and continuing the process gives the surprising result that the sequence ...

### 18. join produced number convert to int    stackoverflow.com

Example:

``````import re
rx = re.compile("{0-9}")
Var1 =bla bla bla 54467
Var2= rx.findall(Var1)
number = ''.join(Var2)
``````
My question is how to convert the number variable to int, i try to do so with int() but i get ...

### 19. How do you check whether a number is divisible by another number (Python)?    stackoverflow.com

I need to test whether each number from 1 to 1000 is a multiple of 3 or a multiple of 5. The way I thought I'd do this would be to ...

### 20. Difference between int and numbers.Integral in Python    stackoverflow.com

I'm trying to get a deeper understanding in Python's data model and I don't fully understand the following code:

``````>>> x = 1

>>> isinstance(x,int)
True

>>> isinstance(x,numbers.Integral)
True

>>> inspect.getmro(int)
(<type 'int'>, <type 'object'>)

>>> inspect.getmro(numbers.Integral)
(<class 'numbers.Integral'>, <class ...``````

### 21. How to use Python to ensure a string is only numbers and then convert it to an integer    stackoverflow.com

If i have a string like this: `asdf5493` I need the last four digits and i get it by doing this:

``````strVar[-4:]
``````
Is it possible to then see if they are all numbers?

### 24. Adding all even integers between 1 and a number    python-forum.org

Hello, First of all I was tasked to write a program that adds all the numbers between 1 and a number using a while loop, and I came up with the following code: n=float(input("Enter a number greater than 1: ")) count=1 while count

### 25. About integers and floating numbers.(resolved)    python-forum.org

Right! From what I understand python will never be able to display the value 1.82 as a data type that can be used for calculating stuff(or arithmetic operations if i understand the pro lingo right)? A bit of a let down, but ah well, I guess i can just stick to integers for the arithmetics and write a few stringformatting functions ...