Python Practical Assignment 5.1

Display the Addition, Subtraction, Multiplication & Division of 20 and 50 Using Two Variables

Introduction

In Python, we can store numbers in variables and perform arithmetic operations like addition, subtraction, multiplication, and division.


Logic to Write the Code

  1. Start the program.
  2. Assign the value 20 to variable x.
  3. Assign the value 50 to variable y.
  4. Perform addition, subtraction, multiplication, and division.
  5. Display the results using the print() function.
  6. End the program.

Source Code (Beginner Friendly)

# Python program to perform arithmetic operations using two variables

# Assigning values
x = 20
y = 50

# Performing operations
print("Addition:", x + y)
print("Subtraction:", x - y)
print("Multiplication:", x * y)
print("Division:", x / y)

Sample Output

Addition: 70
Subtraction: -30
Multiplication: 1000
Division: 0.4

Viva Questions with Answers

1. Which operator is used for addition in Python?

The + operator is used for addition.

2. What is the result of 20 – 50?

The result is -30.

3. What is the symbol used for division?

The / symbol is used for division.

4. Does division always return an integer in Python?

No, division returns a float value.

5. Can variables store numeric values?

Yes, variables can store integers and decimal numbers.


Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top