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

 

Operator in Java

Data types and variable in Java

Find product of two numbers using recursion in Java

Python operator

Cpp program to sum two numbers
C program to the sum of two numbers
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

Explanation of one dimensional array (Data structure)

Explanation of one dimensional array In this post, we will discuss the concept of "Explanation…

2 days ago

Python program to calculate the sum of odd and even numbers in a list

Python program to calculate the sum of odd and even numbers in a list In…

5 days ago

Python code to Calculate sum of odd and even in a list

Python code to Calculate sum of odd and even in a list In this tutorial,…

1 week ago

How to find reverse number using method in Java

How to find reverse number using method In this article, we will discuss the concept…

2 weeks ago

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

1 month ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

2 months ago