# Java, .NET, PHP, PYTHON, ANGULAR, .NET, ML, Data Scince, Testing, CI Tutorials in Easy Languages.

## Input and Output Operation in Python, How to take input from the user's in Python, How to display output in Python

1)  input():-

### var = float(input("message"))  #it will take input for float type

2)  print():-

It is used to display output data using a single statement and multiple statements both.

print("statement1")     #Single Statement

print("statement1","statement2")  #Multiple Statements

print("statement1"+"statement2")  #Concatenation with two Strings

print("statement1" + str(10))  #str() is used to convert int ,float to String

print("result is ",12.3444567891)  #print float value

print("result is %.2f" %  12.3444567891) #print formatted float value

print("{0},{1}".format(2,3))  # {0} and {1} is called placeholder in print()

A basic example of str() in:-

`s="hello"y=10print(s+str(y))a=10b=20.34print(a+b)`

## WAP to calculate the salary of the employee where basic, ta, da, comm, pf, noofleave will be entered by the user?WAP to calculate compound interest?    *WAP to reverse the five-digit number where the first and last digit will be in the same positionWAP to swap two numbers without using a third variableWAP to calculate square and cube of any entered number?

If you have any doubt in programming or join online classes then you can contact us by comment .

1. #Programm for calculate the salary of the employee where basic, ta, da, comm, pf, noofleave will be entered by the user.

'''Get Basic Salary of Employee,
DA = 25% of Basic,
HRA = 15% of Basic,
PF = 12% of Basic,
TA = 7.50% of Basic,
Net Pay = Basic + DA + HRA + TA,
Gross Pay = Net Pay - PF. '''

name=str(input("Enter the name of employee: "))
basic=float(input("Enter the basic salary: "))
da=float(basic*25)/100
hra=float(basic*15)/100
pf=float(basic*12)/100
ta=float(basic*7.50)/100
netpay=float(basic+da+hra+ta)
grosspay=float(netpay-pf)

print("\n\n")
print("Salary Detail")
print("\n")

print(" NAME OF EMPLOYEE : ",name)
print(" BASIC SALARY : ",basic)
print(" DEARNESS ALLOW. : ",da)
print(" HOUSE RENT ALLOW.: ",hra)
print(" TRAVEL ALLOW. : ",ta)
print("\n")
print(" NET SALARY PAY : ",netpay)
print(" PROVIDENT FUND : ",pf)
print(" GROSS PAYMENT : ",grosspay)

2. #reverse the five-digit number where first and last digit will be in the same position
num=12345
print("Actual number is",num)
a=num%10 #5
num=num//10 #1234
b=num%10 #4
num=num//10 #123
c=num%10 #3
num=num//10 #12
d=num%10 #2
e=num//10 #1
num1= e*10000+b*1000+c*100+d*10+a*1
print("Reverse of number is",num1)

3. #complex number with a complex number
num1 = 2+3j
num2 = 4+5j
num = num1+num2
print(num1)
print(num2)
print(num)

4. #program to calculate compound interest
#formula : p * (pow((1 + r / 100), t))

p=float(input("Enter the principal amount :"))
t=float(input("Enter the number of year :"))
r=float(input("Enter the rate of intrest :"))

#compund interest
ci=p*(pow((1+r/100),t))

print("Compound Interest %.2f" % ci)

5. #Program to calculate simple interest

p,r,t=12000,2.2,3.5
si=(p*r*t)/100
print("result is p={0} , r={1} , t={2} ,si={3} ".format(p,r,t,si))
#print("result is %.2f" % si)

6. # Python program to calculate square of a number and cube of a number
# Method 3 (using math.pow () method)

# importing math library
import math

# input a number
number = int (input ("Enter an integer number: "))

# calculate square
square = int(math.pow (number, 2))
cube = int (math.pow (number, 3))

# print
print ("Square of {0} is {1} ".format (number, square))
print ("Cube of {0} is {1} ".format (number, cube))

7. #swap two numbers without using third variable
x=int(input("Enter the value of X : "))
y=int(input("Enter the value of Y : "))

print ("Before swapping: ")
print("Value of X : ", x, " and Y : ", y)

# code to swap 'x' and 'y'
x, y = y, x

print ("After swapping: ")
print("Value of x : ", x, " and y : ", y)

8. #convert temperature from Celsius to Fahrenheit?
# formula --> fahrenheit = (celsius * 1.8) + 32

celsius=float(input(" Temperature in Celsius : "))
fahrenheit=(celsius*1.8)+32
print("{0} degree Celsius is equal to {1} degree Fahrenheit".format (celsius,fahrenheit))

9. ##perform multiplication of a complex number using complex datatype?
num1=complex(input('Enter first complex number: '))
num2=complex(input('Enter second complex number: '))
cal=num1*num2
print('"Multiplication of complex number is "', cal)

10. #print data in the single quote and double quote

print("\nPrint with double quote")

print ('"Welcome in SCS"')

print("\nPrint with single quote")
print ("'Welcome in Python'")

11. basic = float(input("enter basic"))
ta = float(input("enter ta"))
da = float(input("enter da"))
comm = float(input("enter commision"))
pf = float(input("enter pf "))
nl = float(input("enter number of leave"))
tsal = basic+ta+da+comm
deduction = ((tsal)/30) *nl
gsal = tsal-deduction-pf
print("CTC",tsal)
print("Gross salary",gsal)
print("Total pf ",pf," Leave deduction is ",nl)