Saturday, August 14, 2021

Python Integers, Floats.

 Python Integers, Floats

Different data types we will encounter in Python

Numeric 

Numeric variables take values which are numbers like 9, 3.14, 0, Inf

String 

String variables are used to storing textual information

Boolean 

Boolean variables have two modes either True or False. A definite judge of statements!

Datetime  

These variables are used to store Date&time values such as 2020-08-01 12:23:54

Example for integers and floats:

Basic arithmetic operations

>>1+2 
>>3-2
>>1*2
>>2**3
>>2/3
>>2//3
>>2%6  etc

About numbers

  • A lot many different types of numbers are supported in Python like integers (int type), real numbers (float type), complex numbers. We will mostly use integer and floating-point numbers.
  • Integers are just whole numbers, positive or negative. For example, 2 and -2 are examples of integers.
  • Floating-point numbers in Python are notable because they have a decimal point in them, or use an exponential (E) to define the number. For example, 2.0 and -2.1 are examples of floating-point numbers. 4E2 (4 times 10 to the power of 2) is also an example of a floating-point number in Python.
  • In computing, floating-point arithmetic is arithmetic using the formulaic representation of real numbers as an approximation to support a trade-off between range and precision. You can always control the number of digits coming after the decimal, hence they are called floating-point numbers

The table below summarises the two numeric data types, Integers, and Floats:

ExamplesNumber "Type"
1,2,-5,1000Integers
1.2,-0.5,2e2,3E2Floating-point numbers


No comments:

Post a Comment

Python - Conditional statements ,if condition in python

 Python - if - Conditional statements What is the if condition in python? Decision-making is the anticipation of conditions occurring while ...