Hello, @PythonGuy, and welcome to Python Foundation Discourse!
If you had posted your code here, we could offer more effective help. If you do post code, please make sure it is formatted correctly.
Some examples of types of numbers that can be used in Python programs are integers and real numbers. Examples of integers, correctly expressed for Python, include:
Examples of real numbers include:
The following would not be accepted as integers by Python, because they each have a leading
The above would each raise a
When writing a program, it is important to consider what types of data you are using. A count of some kind of object, such as a number of slices of pizza, would be appropriately expressed as an integer, such as
3. However, if you were to specify the name of something, such as a programming language, you would most likely use a string, of which the following are examples:
Note that the strings are contained in either double or single quotes.
Some entities that are commonly referred to as numbers are not actually numbers. At a bank or on an electronic device, you may be asked for a pin number. Most likely, that pin number should be thought of as a string, rather than as a number, even though it might consist entirely of digits. In many situations, valid pin numbers could begin with a
0. Therefore, if your Python program contains a pin number, you should very likely enclose it in quotes. The following would be valid:
pin_number = "0276"
However, this would raise a
pin_number = 0276
We hope you enjoy the discussions here. You may be interested in reading the following pages, which offer helpful information about this forum: