Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c
Find product of two floating point numbers in Python

Find product of two floating point numbers in Python

Posted on March 11, 2021March 22, 2021

Table of Contents

  • Find product of two floating point numbers in Python
    • Code to calculate product of two floats
      • Code to calculate product of two floating point numbers
      • Code to calculate product of two floating point numbers – input from user
      • Code to calculate product of two floating point numbers – using function

Find product of two floating point numbers in Python

In this article, we will discuss the concept of Find product of two floating point numbers in Python

In this post, we are going to learn how to write a program to calculate product of two floating point numbers using different methods in Python program.

Code to calculate product of two floats

Code to calculate product of two floating point numbers

In this program, we will calculate product of two floating point numbers using variable declaration and initialization in Python language

Program 1

num1=2.5
#variable declaration and initialization for num1
num2=5.4
#variable declaration and initialization for num2
product=num1 * num2
#perform multiplication operation
print("The product of given numbers is: ",product);
#display product

When the above code is executed, it produces the following result

The product of given numbers is:  13.5

 

Code to calculate product of two floating point numbers – input from user

In this program, we will calculate product of two floating point numbers using takes input from the user in Python language

Program 2

num1=float(input("Enter the first number: "))
num2=float(input("Enter the second number: "))
#Takes input from the user for num1 , num2

multiply=num1*num2
    #calculate product of two numbers

print("The product is: ",multiply)
#display the output

When the above code is executed, it produces the following result

Enter the first number: 2.5
Enter the second number: 5.6
The product is:  14.0

 

Code to calculate product of two floating point numbers – using function

In this program, we will calculate product of two floating point numbers using function in Python language

Program 3

#Python program to multiply two floating point numbers using function
def mul_Float(a,b):
    #function definition for multiply two numbers
    multiply=a*b
    #calculate multiplication of two numbers
    return multiply;
   #return value to main

num1=float(input("Enter the first number: "))
num2=float(input("Enter the second number: "))
#variable declaration and initialization

print("The product is: ",mul_Float(num1,num2))
#Call the function and display output

When the above code is executed, it produces the following result

Enter the first number: 2.4
Enter the second number: 3.4
The product is: 8.16

 

Suggested post

Data type in Python language

Operator in Python language

 

Similar post

Java code to product of two numbers

C code to product of two numbers

C++ code to product of two numbers

Python code to product of two numbers

 

Java code to Calculate product of two floating point numbers

C code to Calculate product of two floating point numbers

C++ code to Calculate product of two floating point numbers

Python code to Calculate product of two floating point numbers

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes