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

80
Python provides input() and print() to take input and display output into the program.

Python provides a predefined function to take input from the keyboard and display output into the monitor.

1)  input():-  
It is used to take input from the keyboard using a String pattern (a combination of char), we can pass the display message as a parameter into input(). that is used to reduce the extra code as compared to C and CPP programming language.
var = input("message")     #var is the variable name which will assign input data into string pattern

we can convert input data into other datatype such as int, float using the type conversion method.

to convert into an integer then it provides int(), to convert into float it provides float().
input() takes one parameter to display the message in a String format and it also returns data into String form.
var = input("message")
Example of input() to take input for integer data
a = int(input("Enter number"))
Example of input() to take input for float data
b = float(input("Enter float value"))
Example of input() to take input for String data
c = input("Eter string value"))
int():-   It is used to convert numeric String type data or float type data to an integer.

Syntax:-

var  = int(input("message"))   #it will take integer type input

int() is used to convert numeric string type data to the integer type.

Float():- float() is used to convert numeric string type data to float type.

Syntax:-

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

Str():-  It is used to convert integer type data to String type, but no need to use it under input() because of the Input method linked with str() by default.
2)  print():-    
It is used to display output data using a single statement and multiple statements.
this method can accept the single parameter and multiple parameters both.
for multiple parameters, we will use a comma separator.
print("hello")
print("hello",12,"hi","welcome")
...................................................................

print() using format specifier
a=12.345
b=23.56
print("a=%d and b=%d " % 100,200)   %d int, %f float, %s string
print() using comma separator 
print(statement1, statement2)
print() using format() to print multiple statements under Single Statement.
print("a={0} and b={1}".format(a,b))  # it uses placeholder
print() to write an expression
print() using String concatenation.
note:-  all variables or literals or constant must be String for String Concatenation.
print("a="+str(a)) 
print("a="+str(a) + "b="+str(b))
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=10
print(s+str(y))
a=10
b=20.34
print(a+b)
Another example to uses multiple print
a=12.345
b=23.56
print("a=%d and b=%d " % (a,b))
print("a=%f and b=%f" % (a,b))
print("a=%.2f and b=%.2f" % (a,b))
print("a=",a,"b=",b)
print(a,b)
print("a={0} and b={1}".format(a,b))  # it uses placeholder
print(a+b)
print(a+b,a*b,a/b,a%b)
print("a="+str(a) + " b= "+str(b))  #str() to convert int,float to String 
Program assignment:-

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

Tags

إرسال تعليق

80تعليقات

POST Answer of Questions and ASK to Doubt

  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
    #Reverse Program Answer?
    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)

    ردحذف
    الردود
    1. Please help me how can use j, If I am using another character that getting error

      حذف
  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)

    ردحذف
  12. #1a=[1,2,3,4,5]
    #1print(a[::-1])
    #2num1=2+3j
    #2num2=3+4j
    #2num=num1+num2
    #2print(num)
    ##num2=5+4j
    #a=2+5
    #b=(3+4)

    #a=12345%10
    #num=12345//10
    #b=1234%10
    #num=1234//10
    #c=123%10
    #num=123//10
    #d=12%10
    #num=12//10
    #e=1
    #num=a*10000+b*1000+c*100+d*10+e
    #print(num)
    #num=12345

    ردحذف
  13. Program to reverse the five-digit number where the first and last digit remains in same position--->

    num=12345
    a=num%10
    num=num//10
    b=num%10
    num=num//10
    c=num%10
    num=num//10
    d=num%10
    e=num//10
    rev=a*1+d*10+c*100+b*1000+e*10000
    print("rev of a number",rev)

    ردحذف
  14. Program to calculate square and cube of any entered number-->

    a=input("enter the value of a")
    square=int(a)*int(a)
    print("square of a=",square)
    cube=int(a)*int(a)*int(a)
    print(cube of a=",cube)

    ردحذف
  15. WAP to calculate the salary of the employee where basic, ta, da, comm, pf, noofleave will be entered by the user?WAP to calculate the salary of the employee where basic, ta, da, comm, pf, noofleave will be entered by the user?
    name=str("enter the employee name")
    basic=float(input("enter salary"))
    da=float(basic*10)/100
    hra=float(basic*25)
    pf=float(basic*5)
    ta=float(basic*6.5)
    netpay=float(basic+da+hra+ta)
    grosspay=float(netpay-pf)
    print("\n\n")
    print("name of employee",name)
    print("basic salary",basic)
    print("dear allowness",da)
    print("hra",hra)
    print("provident fund",pf)
    print("travell allowness",ta)
    print("\n")
    print("netpay",netpay)
    print("providentfund",pf)
    print("gross salary",grosspay)

    ردحذف
  16. wap to calculate simple intrest
    p=int(input("enter principal"))
    r=float(input("enter rate"))
    t=int(input("enter time"))
    si=float(p*r*t)/100
    print("simple interst",si)

    ردحذف
  17. wap to revesre 5-digit number where 1st and last digit will be on same position
    num=int(input("enter 5-digit number")
    a=num%10
    num=num//10
    b=num%10
    num=num//10
    c=num%10
    num=num//10
    d=num%10
    e=num//10
    num1=e*10000+d*1000+c*100+b*10+a*1
    print(nim1)

    ردحذف
  18. wap square and cube of a number
    a=int(input("value of a"))
    square=int(a*a)
    print(square)

    b=int(input("value of b"))
    cube=int(b*b*b)
    print(b)

    ردحذف
  19. wap to swap two number without using third variable
    a=int(input("value of a"))
    b=int(input("value of b"))
    print("before swap")
    a,b=b,a
    print("after swap")
    print("a=",a,"b=",b)

    ردحذف
  20. p=25000
    R=2
    t=2
    n=12
    r =R/100
    A = p*((1+(r/n))**(n*t))
    print(A)

    ردحذف
  21. Program to calculate compound interest-->
    p=int(input("enter the value of p"))
    R=int(input("enter the value of R"))
    t=int(input("enter the value of t"))
    n=int(input("enter the value of n"))
    r=R/100
    ci=p*((1+(r/n))**(n*t)-1)
    print(ci)

    ردحذف
  22. Programm to calculate the salary/ta/da/deduction of the employee where basic salary, no of leave will be entered by the user.

    name=str(input("enter name of employee"))
    basic = float(input("enter basic salary"))
    ta = float(basic*5)//100
    da = float(basic*6)//100
    comm = float(basic*3)//100
    pf = float(basic*12)//100
    nl = float(input("enter number of leave"))
    sal = basic+ta+da+comm
    deduct = ((sal)//30) *nl
    gsal = sal-deduct-pf
    print("CTC",sal)
    print("Gross salary",gsal)
    print("Total pf ",pf," Leave deduction= ",deduct)

    ردحذف
  23. # PYTHON (6 to 7 PM BATCH)
    #Program for swaping two numbers without using a third variable
    a = int(input("Enter The Value for A :\t"))
    b = int(input("Enter The Value for B :\t"))
    print("Value of A:\t",a,":\n""Value of B:\t",b)
    print("After swaping two numbers:\tA={0}\tB={1}".format(b,a))


    ردحذف
  24. PARAG JAISWAL
    """WAP to calculate the salary of the employee where basic, ta, da, comm, pf, noofleave will be entered by the user?"""
    basic_salary = int(input("Enter your basic salary = "))
    ta = int(input("Enter your ta = "))
    da = int(input("Enter your da = "))
    comm = int(input("Enter your comm = "))
    pf = int(input("Enter your pf amount = "))
    no_of_leave = int(input("Enter your no. leave = "))

    leave_amount = no_of_leave * ((basic_salary + ta + da +comm +pf)/30)
    net_salary =basic_salary + ta + da + comm + pf - leave_amount
    print("Your net salary = ",net_salary)


    ردحذف
  25. Parag Jaiswal
    #WAP to calculate compound interest?

    p = int(input("Enter principal amount = "))
    r = int(input("Enter rate of interest = "))
    t = int(input("Enter time period = "))

    total_value = p * ((1 + (r/100)) ** t)

    print("Total Amount = %.2f"%total_value)
    print("Compund Interest = %.2f"% (total_value - p))

    ردحذف
  26. Parag Jaiswal
    #WAP to reverse the five-digit number where the first and last digit will be in the same position

    num =12345
    e =num % 10 #1
    num = num // 10 # 5432
    b = num % 10 #2
    num = num // 10 #543
    c = num % 10 #3
    num = num // 10 #54
    d = num % 10 # 4
    a = num //10 # 5
    rev = a * 10000 + b * 1000 + c * 100 + d * 10 + e * 1
    print (rev)

    ردحذف
  27. Parag Jaiswal
    3WAP to swap two numbers without using a third variable
    a = 5
    b =9

    a,b=b,a

    print(a,b)

    ردحذف
  28. Parag Jaiswal
    #WAP to calculate square and cube of any entered number?
    num =int(input("Enter number = "))
    square = pow(num , 2)
    cube = num ** 3
    print("Square and cube of ", num, "is", square ,"&",cube)

    ردحذف
  29. Adarsh dixit
    '''WAP to calculate the total salary of an employee where basic, ta, da, comm, pf,hra, leave will be entered by the users?'''
    basic_salary = int(input("enter ur basic salary: "))
    ta = int(input("enter ur ta: "))
    da = int(input("enter ur da: "))
    comm = int(input("enter ur comm: "))
    pf = int(input("enter ur pf amount: "))
    num_of_leave = int(input("enter ur num of leave: "))

    leave_amount = num_of_leave*((basic_salary+ta+da+comm+pf)/30)
    net_salary =basic_salary + ta + da + comm + pf - leave_amount
    print("ur net salary=",net_salary)

    ردحذف
  30. Adarsh dixit
    #WAP to swap two numbers without using a third variable

    a = 5
    b = 6

    print("before swaping: ")
    print("value of a : ",a,"value of b : ",b)

    a,b = b,a

    print("after swaping")
    print("value of a : ",a,"value of b : ",b)

    ردحذف
  31. To calculate compound interest:-
    (p,r,n,t)=(12000,4.3,3,2)
    print(p)
    print(r)
    print(n)
    print(t)
    A=p*(1+(r/n))**(n*t)
    print(A)

    ردحذف
  32. reversed the five-digit number where the first and last digit will be in the same position:-
    x=12345
    print("Given Number:", x)
    a=x%10
    x=x//10
    b=x%10
    x=x//10
    c=x%10
    x=x//10
    d=x%10
    e=x//10
    y=e*10000+b*1000+c*100+d*10+a*1
    print("Reverse of the middle part of the given number:", y)

    ردحذف
  33. #MOhit Chouhan
    1.
    empsal=int(input("Enter the salary : " ))
    ta=int(input("Enter the TA : " ))
    da=int(input("Enter the DA : " ))
    comm=int(input("Enter the comm : " ))
    pf=int(input("Enter the pf : "))
    lea=int(input("Enter the leave : "))

    total=(empsal+ta+da+comm-pf)
    print("salary before leave : ", total)
    b=empsal/30
    w=b*lea

    final=(total-w)
    print("Final salary : ", final)

    2.
    p=int(input("Enter the principal:"))
    r=int(input("Enter the Rate: "))
    t=int(input("Enter the Time : "))

    ci= (p*(1+(r/100))**t)

    print("your compunt intrest is : " ,ci-p)

    3.
    a=int(input("Enter the five digit number : ")) #12345
    r=a%10 #5
    b=a//10 #1234
    s=b%10 #4
    c=b//10 #123
    t=c%10 #3
    d=c//10 #12
    u=d%10 #2
    e=d//10 #1
    print((str(e)+str(s)+str(t)+str(u)+str(r)))

    4.
    a=int(input("Enter the 1st Value plz: "))
    b=int(input("Enter the 2nd Value plz : "))

    print("Before swapping : ", a ,b )
    a,b=b,a
    print("after swapping : ", a ,b)

    5.
    a=int(input("Enter the value : "))
    v= a*a
    print("The Squre of your value is : ", v)
    w= a*a*a
    print("The cube of your value is : ", w)




    ردحذف
  34. # WAP to calculate the total salary of an employee where basic, ta, da, comm, pf,hra, leave will be entered by the users?

    '''basic:- 12000
    ta= 400
    da=200
    comm=500
    pf =-500
    hra = 300
    leave=3'''

    ta=int(input("enter ta : "))
    da=int(input("enter da : "))
    comm=int(input("enter comm : "))
    pf=int(input("enter pf : "))
    hra=int(input("enter hra : "))
    sal=int(input("enter basic salary : "))
    lve=int(input("enter leave's : "))

    c=(ta+da+comm+hra-pf)
    onedy=sal/30
    tslry=((30-lve)*onedy)
    final=tslry+c;
    print("actual salary=",final)

    ردحذف
  35. #WAP to calculate compound interest?

    p=int(input("put p : "))
    r=float(input("put r : "))
    t=float(input("put t : "))

    ci=p*(pow((1+r/100),t));
    print("%.2f"%ci)

    ردحذف
  36. n=int(input("Enter the 5'digites number : "))
    a=n%10 #5
    n=n//10 #1234
    b=n%10 #4
    n=n//10 #123
    c=n%10 #3
    n=n//10 #12
    d=n%10 #2
    n=n//10 #1
    e=n%10 #1
    n=n//10 #0
    z=( ( ( ( ( ( ( (e*10)+b)*10)+c)*10)+d)*10)+a)
    print(z)

    ردحذف
  37. # WAP to swap two numbers without using a third variable (two ways foe without using third variable in python)

    '''a,b=int(input("a:")),int(input("b:"))
    a,b=b,a
    print("a:",a,"b:",b)'''


    a,b=int(input("a:")),int(input("b:"))
    a=a+b
    b=a-b
    a=a-b
    print("a:",a,"b:",b)

    ردحذف
  38. # WAP to swap two numbers without using a third variable (two ways foe without using third variable in python)

    '''a,b=int(input("a:")),int(input("b:"))
    a,b=b,a
    print("a:",a,"b:",b)'''


    a,b=int(input("a:")),int(input("b:"))
    a=a+b
    b=a-b
    a=a-b
    print("a:",a,"b:",b)

    ردحذف
  39. #WAP to calculate square and cube of any entered number?

    no=int(input("Enter a number : "))
    square=
    cube=no*no*no
    square=pow(no,2) # no*no;
    cube=pow(no,3) # no*no*no; square*no;
    print("Square is",square)
    print("Cube is",cube)

    ردحذف
  40. WAP to reverse a five-digit number without using a loop?
    num=12345
    print(num)
    a=num%10
    num=num//10
    b=num%10
    num=num//10
    c=num%10
    num=num//10
    d=num%10
    e=num//10
    num1=a*10000+b*1000+c*100+d*10+e*1
    print(num1)

    ردحذف
  41. Salary Calculation

    ba= int(input("Enter basic salary"))
    ta= int(input("enter ta"))
    da= int(input("enter da"))
    com= int(input("enter com"))
    pf= int(input("input pf"))
    nl= int(input("input nl"))
    sal= ba-ta+da+com-pf+nl
    print("your salary is", sal)

    ردحذف
  42. compound interest

    p=100000
    r=5
    n=100
    nt=4
    a=p*((1+(r/n))**nt)
    print(a)
    ci= a-p
    print(ci)

    ردحذف
  43. swap two digit no.

    x= int(input("enter value x"))
    y= int(input("enter value y"))
    x,y= y,x
    print("x:",x)
    print("y:",y)

    ردحذف
  44. square and cube

    a= 2
    s= 2**2
    c= 2**3
    print(s,c)

    ردحذف
  45. #3 wap to reversed the five-digit number where the first and last digit will be in the same position:-
    num=52341
    a=num%10 #1
    num=num//10 #
    b=num%10 #2
    num=num//10 #
    c=num%10 #0
    num=num//10 #
    d=num%10 #0
    num=num//10 #
    e=num%10 #1
    num1=(e*10000+b*1000+c*100+d*10+a*1)
    print(num1)

    ردحذف
  46. Salary Calculator Program Solution:-
    basic = float(input("Enter basic salary of employee"))
    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"))

    gsal = basic+ta+da+comm+pf

    tsal = basic+ta+da+comm-pf

    nsal = gsal-((tsal/30)*nl)

    print("Gross salary of employee is "+str(gsal)) # str() is used to convert float type data to string type
    print("NET salary of employee is %.2f" % nsal)

    ردحذف
  47. num=int(input("Enter a 5 digit number"))
    a=num%10
    num=num//10
    b=num%10
    num=num//10
    c=num%10
    num=num//10
    d=num%10
    num=num//10
    e=num%10
    num=num//10
    num2=e*10000+b*1000+c*100+d*10+a*1
    print(num2)

    ردحذف
  48. P=int(input("enter principle amount"))
    R=float(input("enter interest rate"))
    T=float(input("enter time period"))
    CI=P*(1+R/100)**T
    print("ci is",CI)

    ردحذف
  49. num=int(input("enter a number"))
    square=num**2
    cube=num**3
    print("{0} square is {1} and cube is {2}".format(num,square,cube))

    ردحذف
  50. num=int(input("enter a number"))
    square=num**2
    cube=num**3
    print("{0} square is {1} and cube is {2}".format(num,square,cube))

    ردحذف
  51. num=12345
    a=num%10
    num=num//10
    b=num%10
    num=num//10
    c=num%10
    num=num//10
    d=num%10
    e=num//10

    num1=e*10000+b*1000+c*100+d*10+a*1

    print(num1)

    ردحذف
  52. 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)

    X,Y = Y,X

    print ("After swapping: ")
    print("Value of X : ", X, " and Y : ", Y)

    ردحذف
  53. '''WAP to calculate compound interest?'''
    p,r,t=int(input("enter principal:-")),float(input("enter rate:-")),int(input("enter time:-"))
    ci=p*((1+r/100)**t) #p*(pow((1+r/100),t))
    print(ci)

    ردحذف
  54. '''WAP to reverse the five-digit number where the first and last digit will be in the same position'''
    n=int(input("enter five digit number:-"))
    a=n%10
    n=n//10
    b=n%10
    n=n//10
    c=n%10
    n=n//10
    d=n%10
    n=n//10
    e=n%10
    n=n//10
    print(e,b,c,d,a)

    ردحذف
  55. '''WAP to calculate square and cube of any entered number?'''
    n=int(input("enter any number:-"))
    print("square is:-",n*n,"\nqube is:-",n*n*n)

    ردحذف
  56. SONAM SINGH
    "WAP to reverse the five digit number where the first and last digit number will be in the same position "
    num=12345
    print=("enter the real value ,num")
    a=num%10#5

    num=num//10
    b=num%10
    num=num//10
    c=num%10
    num=num//10
    d=num%10
    num=num//10
    e=num//10
    num1=(e*10000+d*1000=c*100+b*10+a*1)
    print("enter the reverse value")

    ردحذف
  57. SONAM SINGH
    WAP TO SIMPLE INTEREST
    p=int(input("enter the principal value"))
    r=int(input("enter the rate value"))
    t=int(input("enterthe time value"))
    si=int(p*r*t)/100
    print("simple interst",si)

    ردحذف
  58. SONAM SINGH
    WAP to calculate the compound interest
    p = int(input("Enter principal value "))
    r = int(input("Enter rate of interest" ))
    t = int(input("Enter time period "))

    total_value = p * ((1 + (r/100)) ** t)

    print("Total Amount = %.2f"%total_value)
    ci=(total_value-p)
    print(ci)

    ردحذف
  59. SONAM SINGH
    WAP to calculate the compound interest
    p = int(input("Enter principal value "))
    r = int(input("Enter rate of interest" ))
    t = int(input("Enter time period "))

    total_value = p * ((1 + (r/100)) ** t)

    print("Total Amount = %.2f"%total_value)
    ci=(total_value-p)
    print(ci)

    ردحذف
  60. #WAP to calculate the salary of the employee where basic, ta, da, comm, pf, leave will be entered by the user?

    basic=30000
    ta=300
    da=200
    comm=500
    pf=500
    hra=300
    leave=10
    total=basic+ta+da+comm-pf+hra
    salary=total-(total/30)*leave
    print("total salary is",salary)
    output=20533.33

    ردحذف
  61. # wap to calculate the total salary of an enployee where basic,ta,da comm, pf,hrs,leave will be entered by the user?
    #basic(basic salary )
    #ta(trevelling allowance)
    #da(dearness allowance)
    #comm(coneyance allowance)
    #pf(prvident fund)
    #hra(House rent allowance)
    #leav(leave)
    basic=float(input("enter the basic salary"))
    ta=float(input("enter the trevelling allowance"))
    da=float(input("enter the dearmess allowance"))
    comm=float(input("enter the coneyance allowance"))
    pf=float(input("enter the provident fund"))
    hra=float(input("enter the home rent allowance"))
    leave=float(input("enter the leave"))
    tot=(basic+ta+da+comm-pf+hra)
    print("total salary with out leave is",tot)
    aday=(basic/30)
    totcut=(leave*aday)
    tot1=(tot-totcut)
    print("total salary of employee with leave is",tot1)

    ردحذف
  62. # wap to calculate the total salary of an enployee where basic,ta,da comm, pf,hrs,leave will be entered by the user?
    #basic(basic salary )
    #ta(trevelling allowance)
    #da(dearness allowance)
    #comm(coneyance allowance)
    #pf(prvident fund)
    #hra(House rent allowance)
    #leav(leave)
    basic=float(input("enter the basic salary"))
    ta=float(input("enter the trevelling allowance"))
    da=float(input("enter the dearmess allowance"))
    comm=float(input("enter the coneyance allowance"))
    pf=float(input("enter the provident fund"))
    hra=float(input("enter the home rent allowance"))
    leave=float(input("enter the leave"))
    tot=(basic+ta+da+comm-pf+hra)
    print("total salary with out leave is",tot)
    aday=(basic/30)
    totcut=(leave*aday)
    tot1=(tot-totcut)
    print("total salary of employee with leave is",tot1)

    ردحذف
  63. # compound intrest program

    p= float(input(" enter the value of p "))
    r= float(input(" enter the value of r "))
    t= float(input(" enter the value of t "))
    n=12
    R=r/100

    A=(p*(1+R/n)**(n*t))
    print(" the compund interst is ",A,A-p)

    ردحذف
  64. #WAP to Reverse Five Digit Number where first and last digit is same.
    num=int(input("enter five digit no."))
    a=num%10
    num=num//10
    b=num%10
    num=num//10
    c=num%10
    num=num//10
    d=num%10
    e=num//10
    rev=a*1+b*1000+c*100+d*10+e*10000
    print("the reverse value is",rev)

    ردحذف
  65. #program of swiping without third virable
    a=input(" enter the first value")
    b=input(" enter second value")
    a,b = b,a
    print(" the value of a is",a , "the value of b is ",b)

    ردحذف
  66. #WAP to calculate Square and Cube of any assigned number.
    a=int(input("enter number for square and cube"))
    square=(a*a)
    print("the assigned square is",square)
    cube=(a*a*a)
    print("the Assigned cube is", cube)

    ردحذف
  67. #WAP to calculate the salary of the employee where basic, ta, da, comm, pf, no. of leave will be entered by the user
    salary= int(input("Enter the Salary"))
    ta= int(input("Enter the ta"))
    da= int(input("Enter the da"))
    comm= int(input("Enter the comm"))
    pf= int(input("Enter the pf"))
    hra= int(input("Enter the hra"))
    leave = int(input("Enter the leave"))

    total=(salary + ta +da + comm -pf + hra)
    print("Total salary without leave :",total)

    single_day= salary/30
    cut=leave*single_day

    final=("The total amount after Leave", total-cut)
    print(final)

    ردحذف
  68. #WAP to calculate compound interest
    p= float(input(" enter the p "))
    r= float(input(" enter the r "))
    t= float(input(" enter the t "))
    n=6
    R=r/100

    total_amount =(p*(1+R/n)**(n*t))
    print(" the total amount is ", total_amount)
    ci=total_amount-p
    print("the compound interest is", ci)

    ردحذف
  69. #to print reversed 5 digit number without changing first and last digit
    x=int(input("enter five digit number to reverse"))
    a=x%10
    x=x//10
    b=x%10
    x=x//10
    c=x%10
    x=x//10
    d=x%10
    e=x//10
    reverse=a*1+b*1000+c*100+d*10+e*10000
    print("the reverse value is",reverse)

    ردحذف
  70. #swapping of two unknown numbers without third variable
    x=int(input("enter first number"))
    y=int(input("enter second number"))
    x=x+y
    y=x-y
    x=x-y
    print(x,y)

    ردحذف
  71. #WAP to calculate square and cube of any entered number
    a=int(input("enter a number to find square"))
    square=(a*a)
    print("the square is", square)

    a=int(input("enter a number to find cube"))
    cube=(a*a*a)
    print("the cube is", cube)

    ردحذف
  72. #simple interest where rate and time is constant
    principle=int(input("enter the principle"))
    rate=3
    time=4
    constant=(rate,time)
    simple_interest=(principle*rate*time)/100
    print(simple_interest)

    ردحذف
  73. name=input("Enter employee name:")

    basic=float(input("Enter basic:"))
    ta=float(input("Enter Travelling Allowance:"))
    da=float(input("Enter Dearness Allowance:"))
    comm=float(input("Enter commisson:"))
    hra=float(input("enter house rent allowance:"))
    leave=float(input("enter leave:"))
    pf=float(input("enter providant fund:"))
    netpay=(basic+ta+da+hra+comm)
    deduction=(netpay/30)*leave
    grosspay=(netpay-pf-deduction)

    print("SALARY SLIP")
    print("==============================================")

    print("basic:",basic)
    print("Travelling Allowance:",ta)
    print("Dearness Allowance:",da)
    print("commisson:",comm)
    print("House rent Allowance:",hra)
    print("No of Leave:",leave)
    print("Providant fund:",pf)
    print("===============================================")

    print("Total salary:",netpay)
    print("gross payment:",grosspay)

    ردحذف
  74. #reverse five digit number where first and last digit in same position
    a=int(input("Enter only five digit:"))
    print(a)
    n1=a%10 #5
    a=a//10 #1234
    n2=a%10 #4
    a=a//10 #123
    n3=a%10 #3
    a=a//10 #12
    n4=a%10 #2
    a=a//10 #1
    res=(a*10000+n2*1000+n3*100+n4*10+n1)
    print(res)

    ردحذف
  75. # wap to reverse five digit number where first and last digit will be on same position?
    num=int(input("enter any five digit number"))
    r1=num%10
    num1=num//10
    r2=num1%10
    num2=num1//10
    r3=num2%10
    num3=num2//10
    r4=num3%10
    num4=num3//10
    r5=num4%10
    result=r1*1+r2*1000+r3*100+r4*10+r5*10000
    print(result)

    ردحذف
  76. #wap to calculate compound intrest?
    p=2000
    r=3.5
    t=2
    n=3
    A=p*((1+(r/n))**(n*t))
    print("compound intrest",A)

    ردحذف
  77. #square and cube of the number?

    #square of the input number
    a=int(input("enter any number"))
    s=a*a
    print("square is",s)

    # cube of the input number
    x=int(input("enter any number"))
    c=x*x*x
    print("cube is",c)

    ردحذف
  78. #wap to swap without using third variable?
    a=20
    b=30
    a=a+b
    b=a-b
    a=a-b
    print(a,b)

    ردحذف
  79. basic=int(input("Please Enter Basic Salary"))
    ta=int(input("Please Enter TA"))
    da=int(input("Please Enter DA"))
    com=int(input("Please Enter Comm"))
    pf=int(input("Please Enter Pf"))
    leave=int(input("Please Enter NO of Leave Employee"))
    pd=30-leave
    sal=basic+ta+da+com
    csal=(sal/30)*pd
    tsal=int(csal-pf)
    print("No of Paid Days> ",pd)
    print("Gross Salary> ",sal,"Rs.")
    print("Deduction in Salary PF> ",pf,"Rs")
    print("In Hand Salary> ",tsal,"Rs")

    ردحذف
إرسال تعليق