0% found this document useful (0 votes)
3 views1 page

Arithmetic Operators Program

The document demonstrates the use of arithmetic and assignment operators in Python. It includes user input for two numbers and performs various arithmetic operations such as addition, subtraction, multiplication, and division, displaying the results. Additionally, it showcases assignment operators with a variable, illustrating how to modify its value through different operations.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Arithmetic Operators Program

The document demonstrates the use of arithmetic and assignment operators in Python. It includes user input for two numbers and performs various arithmetic operations such as addition, subtraction, multiplication, and division, displaying the results. Additionally, it showcases assignment operators with a variable, illustrating how to modify its value through different operations.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Program: Demonstration of Arithmetic and

Assignment Operators
# The input() function returns a string
# So we use the int() function to convert the strings to integers

num1 = int(input("Enter first number: "))


num2 = int(input("Enter second number: "))

# Perform arithmetic operations


addition = num1 + num2
subtraction = num1 - num2
multiplication = num1 * num2
division = num1 / num2
modulus = num1 % num2
exponentiation = num1 ** num2
floor_division = num1 // num2

# Display the results


print(num1, "+", num2, "=", addition)
print(num1, "-", num2, "=", subtraction)
print(num1, "*", num2, "=", multiplication)
print(num1, "/", num2, "=", division)
print(num1, "%", num2, "=", modulus)
print(num1, "**", num2, "=", exponentiation)
print(num1, "//", num2, "=", floor_division)

# Assignment Operators Demonstration

x = 15
print("Assignment:", x)

x += 3
print("Addition Assignment:", x)

x -= 2
print("Subtraction Assignment:", x)

x *= 4
print("Multiplication Assignment:", x)

x /= 2
print("Division Assignment:", x)

x %= 3
print("Modulus Assignment:", x)

x //= 2
print("Floor Division Assignment:", x)

x **= 3
print("Exponentiation Assignment:", x)

You might also like