Introduction

Setup

Operators

variable

String

Number

Dtype & Comment

Lists

Tuples

Sets

Dictionaries

if else statement

For Loop

While Loop

iterator & iterable

Pre-Built functions

Function

Decorators

generators

Types of errors

Exceptions Handling

OOP

Regular expression

Create module

OS module

Date module

Random module

Math

Statistics module

Exercise 1

Exercise 2

Exercise 3

Learn Data Structure & Algorithm

Learn Numpy

Learn Pandas

Learn Matplotlib

Learn Seaborn

Learn Statistics

Learn Math

Learn MATLAB

Learn Machine learning

Learn Github

Learn OpenCV

Learn Deep Learning

Learn MySQL

Learn MongoDB

Learn Web scraping

Learn Excel

Learn Power BI

Learn Tableau

Learn Docker

Learn Hadoop

python number

Types of numeric values in python

There are three types of numeric values in python:

  • int
  • float
  • complex
  • Example:
    x=100
    y=100.001
    z=100yt

    Here data type of x variable value is integer(int).
    y variable value data type is float.
    z variable value data type is complex.

    How to convert into numeric form in python?

    In python to convert into numeric form int(), float() functions are used. To convert into integer, use int() function and for float use float() function. You can't convert complex number into other form.

    Example:
    Input
    x=5.0
    y=3
    z=int(x)
    v=float(y)
    print(type(z))
    print(type(v))
    Output
    <class "int">
    <class "float">

    Here we have a float value in the x variable and an integer value in the y variable, int function is used on x and float function is used on the y variable. After using the function now the value of x becomes an integer number and y becomes a float number. Now if we check the type of those values then we will see the value of x is an integer and the value of y is float.

    split() function

    In the split function, a separator is used. The default separator is space but we can use different separators according to our needs like comma, colon, quotation, slash, etc. The split function separates number or string by the given separator and return all distinct values as a list.

    Example:
    Input
    b = 11,22,22
    c = 11/22/22
    d = 11 22 22
    print(b.split(",")
    print(c.split("/")
    print(d.split()
    Output
    [11,22,22]
    [11,22,22]
    [11,22,22]

    CodersAim is created for learning and training a self learner to become a professional from beginner. While using CodersAim, you agree to have read and accepted our terms of use, privacy policy, Contact Us

    © Copyright All rights reserved www.CodersAim.com. Developed by CodersAim.