How to Make Python Acknowledge Decimals

When you create a numeric variable in Python, depending on the type of variable you choose, it may or may not save decimal values when you assign them to the variable. If you chose an "Integer" variable, it discards any decimal portion of the number because it is incapable of saving that information. Instead, choose a variable like a "Double" or "Float" if you want Python to acknowledge and save the decimal portions of numbers to your variable.

Instructions

    • 1

      Open your Python application and find the portion of your program where you want to create a new variable that contains decimal places.

    • 2

      Create a new Double variable called "myDoubleVariable" by typing "new Double $myDoubleVariable = 49.873;" on a new line.

    • 3

      Create a new Float variable called "myFloatVariable" by typing "new Float $myFloatVariable = 37.281;" on a new line.

Related Searches:

Comments

Related Ads

Featured