Python Practice › Basic Programs › Program 3
Multiply two numbers
Write a Python program to multiply two numbers.
Input
a = 12, b = 7.5
Output
Product: 90.0
Approach
- Multiply the numbers with
*. - Print the product.
Solution
a = 12b = 7.5 product = a * bprint("Product:", product)Output
Product: 90.0
Line by line
Lines 1-2
One value is an int and the other a float.
Line 4
Multiplying an int by a float gives a float, so the result prints as 90.0.
Learn the concept
New to this topic? Read the lesson, then come back.