experiment 2 python
experiment 2 python
Problem: Write python programs to understand Operators, expressions, and Input Output Statements.
Problem Statement:
1. Calculating Gross Salary of an Employee*:
Write a Python program to calculate the gross salary of an employee.
The program should prompt the user for the basic salary (BS) and then compute the dearness allowance (DA)
as 70% of BS, the travel allowance (TA) as 30% of BS, and the house rent allowance (HRA) as 10% of BS.
Finally, it should calculate the gross salary as the sum of BS, DA, TA, and HRA and display the result.
program code:
HRA = (Basic/100)*30
DA = (Basic/100)*70
TA = (Basic/100)*15
Output:
. 2. Exploring Basic Arithmetic Operations in Python*:
Write a Python program to explore basic arithmetic operations.
The program should prompt the user to enter two numbers and then perform addition, subtraction,
multiplication, division, and modulus operations on those numbers. The results of each operation should be
displayed to the user.
Program code:
x = int(input("Enter a value:"))
y = int(input("Enter a value:"))
a = x+y
print("Addition is:",a)
b = x-y
print("subtraction is:",b)
c = x*y
print("multiplication is :",c)
d = x/y
print("division is:",d)
e = x%y
print("modulus is:",e)
output:
Conclusion: Understood the programs demonstrating the use of operators, expressions, and input-output
statements in Python.