×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python program to find greatest integer using floor() method

An example of floor() method in Python: Here, we are going to learn how to find the greatest integer using floor() method in Python? By Anuj Singh Last updated : January 04, 2024

Problem statement

Input a float number, write a Python program to find greatest integer.

Greatest integer function

The greatest integer function is a function (real numbers function) to itself that is defined as follows: it sends any real number to the largest integer that is less than or equal to it.

The greatest integer function of floor method example 0 is denoted by floor method example 1.

The greatest integer function is related to the fractional part (sometimes denoted floor method example 2) of the number as follows: for any floor method example 3 , we have: floor method example 4

More about greatest integer function: floor() and ceiling functions | wikipedia

Python program to find greatest integer using floor() method

# Python code to find greatest integer 
# (Use of floor() method)

import math #importing class

num = float(input("Enter any float number: "))
print("math.floor(num): ", math.floor(num))

num = float(input("Enter another float number: "))
print("math.floor(num): ", math.floor(num))

Output

The output of the above example is:

Enter any float number: 56.892
math.floor(num):  56
Enter another float number: -34.567
math.floor(num):  -35

To understand the above program, you should have the basic knowledge of the following Python topics:

Python Basic Programs »

Advertisement
Advertisement

Related Programs

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.