Posts

Showing posts from November, 2022

Python program to Add two numbers

  Python Program to Add Two Numbers: In this program, you will learn to add two numbers and display them using the print() function. To understand this example, you should have knowledge of the following Python programming topics: python input and output python data types python operators In the program below, we've used the  +  operator to add two numbers. # This program adds two numbers num1 = 1.5 num2 = 6.3 # Add two numbers sum = num1 + num2 # Display the sum print('The sum of {0} and {1} is {2}'.format(num1, num2, sum)) Output the sum of 1.5 and 6.3 is:7.8 Using Function: def sum():     x = 12     y = 15     a= x + y      print(a) sum() Arguments and parameters: def sum(a,b):    print(a + b) sum(12,15)