0% found this document useful (0 votes)
10 views2 pages

Python Program for Adding Numbers

The document contains a Python program that demonstrates basic arithmetic operations, including adding two predefined numbers and adding two numbers based on user input. It also includes a simple program to check if a number is odd or even. The code snippets illustrate fundamental programming concepts such as input handling and conditional statements.

Uploaded by

Arunmozhivarman
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Python Program for Adding Numbers

The document contains a Python program that demonstrates basic arithmetic operations, including adding two predefined numbers and adding two numbers based on user input. It also includes a simple program to check if a number is odd or even. The code snippets illustrate fundamental programming concepts such as input handling and conditional statements.

Uploaded by

Arunmozhivarman
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

# This program adds two numbers

num1 = 1.5

num2 = 6.3

# Add two numbers

sum = num1 + num2

# Display the sum

print(sum)

2. print("Hello welcome")

3.

#Add Two Numbers With User Input

# Store input numbers

num1 = input('Enter first number: ')

num2 = input('Enter second number: ')

# Add two numbers

sum = float(num1) + float(num2)

# Display the sum

print(num1, num2, sum)

4.

print(10 + 5)

6. # Python program to check if the input number is odd or even.

# A number is even if division by 2 gives a remainder of 0.

# If the remainder is 1, it is an odd number.

num = int(input("Enter a number: "))


if (num % 2) == 0:

print("odd")

else:

print("even")

You might also like