- On
- By
- 0 Comment
- Categories: addition, Calculations
Python program to sum of two numbers
Python program to the sum of two numbers
In this tutorial, we will discuss the Python program to the sum of two numbers
In this topic, we will learn how to add two numbers in Python programming language
Sum of two integer numbers
#find sum of two integer numbers f_no=35 #variable declaration s_no=55 sum=f_no + s_no;#Adding the two numbers print("The sum of numbers", sum) #display the results on the screen
When the above code is compiled and executed, it produces the following results
The sum of numbers 90
Sum of two floating point numbers
#assingning the two float values val_1=34.56; val_2=45.67; #find sum of two values sum=float(val_1)+float(val_2) #Display the result of sum print("The sum of numbers is: ",sum)
When the above code is compiled and executed, it produces the following results
The sum of numbers is: 80.23
Sum of two numbers get input from the user
#get input from user for num_1, num_2 num_1=float(input("Enter the first number: ")) num_2=float(input("Enter the second number: ")) #find sum of given numbers sum=num_1 + num_2 #Display the result on the screen print("The sum of two numbers: ",sum)
When the above code is compiled and executed, it produces the following results
Enter the first number: 12.34 Enter the second number: 23.45 The sum of two numbers: 35.79
In the above program, the user is entered two floating point value for find sum.
we use the pre-defined function input() for getting value from the user. but, these function returns a output as the string. So, we can convert it using the float() function to display floating point values
Similar post
C++ program to multiply two numbers using function
Java program to multiply two numbers using method
Python program to multiply two numbers using function
C# program to multiply two numbers using function
PHP program to multiply two numbers using function
C program to multiply two numbers
C++ program to multiply two numbers
Java program to multiply two numbers
Python program to multiply two numbers
C# program to multiply two numbers
PHP program to multiply two numbers
JavaScript program to multiply two numbers
Calculate the total of array elements in Java
Calculate the total of array elements in C
Calculate the total of array elements in C++
Java program to calculate sum of array elements
C program to calculate sum of array elements
Java Program to calculate average of array
C Program to calculate average of array
Java Program to calculate average of odd and even numbers in an array
Java Program to calculate average of odd and even numbers
C Program to calculate average of odd and even numbers in an array
C Program to calculate average of odd and even numbers
C++ Program to calculate average of odd and even numbers in an array
C++ Program to calculate average of odd and even numbers
Data types and variable in Java