Skip to content

Shailaja3/Python-Program-to-Add-Two-Numbers

 
 

Repository files navigation

Python-Program-to-Add-Two-Numbers

This repository contains a simple Python program that adds two numbers together. It serves as a basic example for beginners learning Python programming. Feel free to explore the code, contribute improvements, or use it as a reference for similar tasks.

It seems like you've provided code examples demonstrating how to add two numbers in Python using pre-defined variables and user input. Additionally, you've included comments explaining the code snippets. If you're looking to add this to a README.md file in a GitHub repository, you can format it for clarity and readability using markdown syntax. Here's how you could structure it:

Python Program to Add Two Numbers

1. Pre-defined Variables

#1. Pre-defined Variables
num1 = 11  # Here we define the variables in the program
num2 = 99

# Adding using pre-defined variables
print("The sum of two numbers is ", num1 + num2)
Output:

The sum of two numbers is 110

# Pre-defined Variables with variable 'sum'
num1 = 11
num2 = 99
sum = num1 + num2  # If we created a variable named as 'sum'
print("The sum of two numbers is ", sum)
Output:

The sum of two numbers is 110


#2. User-input
num1 = float(input("Enter the number: "))  # We use float because the user can add decimal values, If we give int means integer values then the user can't add decimal values
num2 = float(input("Enter the number: "))

# Adding using user-input
sum = num1 + num2
print("The sum of two numbers is ", sum)
Output:
Enter the number: 11
Enter the number: 77

The sum of two numbers is 88.0

About

This repository contains a simple Python program that adds two numbers together. It serves as a basic example for beginners learning Python programming. Feel free to explore the code, contribute improvements, or use it as a reference for similar tasks.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Jupyter Notebook 100.0%