Variable,Constant and Literals Declaration in Python

87
Variable:-  it is an identifier that is used to contain values in the program. variable value and type can be changed in the program at run time.

Python variable datatype will be managed by the assigned value. Python variable type and memory allocation depend on assigned data .we can provide multiple data types for a single variable in the python program.

Python variable is a loosely coupled type declaration so that we can change variable datatype in the program.

The syntax for Variable Declaration in Python:-
identifier=value  #single value 
identifier1,identifier2,...= value1,value2,..   #multiple variable, multiple value
a=10
a,b,c = 10,20,30
a,b=10,20
print(a+b)
Example of variable:-
a,b = input("enter first number"),input("enter second number")
print(a+b)   #  "10"+"20"  "1020"
print(int(a)+int(b))  # 10+20
print(int(a+b))    #  1020  int
print(int(a)+float(b))   

the naming convention of variable:-

variable name always will be started by alphabets, without using space, keyword.
the variable identifier will be declared in the lower case according to the python naming convention.

Constant:-

it is a special identifier in the Python program whose values can not be changed dynamically.
Python provides a
list of the constant that is called a tuple.

tuple variable value can not be modified  in the program and outside from the program

identifier = (value1,value2,value3,..)

const = (3.14,2.2,"http://www.shivaconceptsolution.com")

Literals:-  It is the value of variable and constant for example if we assign 
a=2   # 2 is the integer  type literals
b = 3.14 # 3.14 is the float type literals
print("hello")  # hello is the string type literals
Example of Literals:-
print(10+20)    #10,20 is the integer type literals
print("hello"+"how r u")   # hello, how r u is the string type literals
WAP to reverse a five-digit number without using a loop?
num=45123
a = num%10  #3
num=num//10 #4512
b=num%10  #2
num=num//10 #451
c=num%10 #1
num=num//10 #45
d=num%10 #5
e=num/10   #4
num1 = a*10000 + b*1000+c*100+d*10+e*1
print(num1)
ASSIGNMENT:-

1) 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

Solution of this program:-

name = input("Enter name")

basic = float(input("Enter basic salary"))

ta = float(input("Enter ta "))

da = float(input("Enter da"))

comm = float(input("Enter comm"))

pf = float(input("Enter pf"))

hra = float(input("Enter HRA"))

lv = float(input("Enter number of leave in days"))

ctc= basic+ta+da+comm+hra+pf

print("CTC of employee is {0}".format(ctc))

tsal = basic+ta+da+comm+hra

lvded = (tsal/30)*(lv)

gsal = tsal-lvded-pf

print("Gross Salary is {0}".format(gsal))

print("Leave deduction is {0} and PF deduction is {1}".format(lvded,pf))

f = open("salaryslip.doc","w")

f.write("   CTC is "+ str(12*ctc))

f.write("\n Name is "+name)

f.write("\n Gross Salary is {0}".format(gsal))

f.write("\n Leave deduction is {0} and PF deduction is {1}".format(lvded,pf))

f.close()

 2)  WAP to calculate electricity bill where unit price, total consumption, the extra load will be entered by the users?

Solution:-

up= float(input("enter price"))

cons= float(input("enter consumption"))

load = float(input("enter unit for extra load"))

bill = up*cons+ 2*(up*load)

print("Total bill is "+str(bill))

print("Total consumption without load"+str(up*cons))

print("Total consumption with extra load"+str(2*(up*load)))  

3 WAP to calculate Simple Interest where rate and time will be constant and 
the principal will be an integer?

4 WAP to calculate the area of a triangle, circle, and rectangle in the same program where the value of pi, the base of the triangle, and the height of the rectangle will be constant.
5)  WAP to convert temperature from  Celsius to Fahrenheit?

Tags

إرسال تعليق

87تعليقات

POST Answer of Questions and ASK to Doubt

  1. num=54231
    a=num%10
    num=num//10
    b=num%10
    num=num//10
    c=num%10
    num=num//10
    d=num%10
    num=num//1=
    e=num%10
    num2=a*10000+b*1000+c*100+d*10+e*1
    print(num2)

    ردحذف
  2. area of circle
    r=2
    const=(3.14)
    area=(const*r*r)
    print(area)

    ردحذف
  3. area of hexagon
    a=2
    const=(3*1.732//2)
    print(area)

    ردحذف
  4. factorial of a number
    n=5
    fact=(5*4*3*2*1)
    print(fact)

    ردحذف
  5. calculate compund interst
    p=1000
    r=4
    n=5
    t=4
    c=(p*(1+r//n)*n*t)
    print(c)

    ردحذف
  6. WAP to calculate Simple Interest where rate and time will be constant and
    the principal will be an integer?
    p=1000
    r=2
    t=5
    const=(r,t)
    si=(p*r*t)
    print(si)

    ردحذف
  7. WAP to calculate the area of a triangle, circle, and rectangle in the same program where the value of pi, the base of the triangle, and the height of the rectangle will be constant
    area of traingle the base of traingle is constant
    b,h=10,20
    const=(b)
    area=(const*h)//2
    print(area)
    area of circle where pi is const
    r=2
    const=(3.14)
    area=(const*r*r)
    print(area)
    area of rectangle where hight is const
    b,h=20,30
    const=(h)
    area=(b*const)
    print(area)

    ردحذف
  8. Solution of Temperature converter
    c=45
    f = (9*c+160)/5
    print(f)

    ردحذف
  9. #PYTHON(6 To 7 PM Batch)
    #For the Calculation of area of a triangle, circle, and rectangle in the same program

    a= int(input("For AREA of Triangle Press 1:\nFor AREA of Rectangle Press 2:\nFor AREA of Circle Press 3:\t"))
    if a==1:
    print("\nBASE = 20")
    h=int(input("Enter Height:\t"))
    b=20
    print("AREA of Triangle :\t",(b*h)/2)
    elif a==2:
    print("\nLENGTH= 20")
    w=int(input("Enter WIDTH:\t"))
    l=20
    print("AREA of Rectangle:\t",(w*l))
    elif a==3:
    print("\nπ=3.14")
    pi=3.14
    r=int(input("Enter the Radius:\t"))
    print("AREA of Circle:\t",(pi*r*r))
    else:
    print("Entered wrong Option")

    ردحذف
  10. # PYTHON( 6 To 7 PM BATCH)
    # Program to convert temperature from Celsius to Fahrenheit or Vice Versa

    z = input("Press C or c to know temprature in Celsius :\t""\nPress F or f to know Temprature in Fahrenheit:\t")

    if z == 'c'or z=='C':

    f = int(input("Enter Temprature in Fahrenheit:\t" ))
    print("Temprature in(°F):\t",f,"°F")
    print("Temprature in(°C):\t",(f-32)*5/9,"°C")

    elif z=='f' or z=='F':
    c = int(input("Enter Temprature in Celsius:\t" ))
    print("Temprature in(°C):\t",c,"°C")
    print("Temprature in(°F):\t",(c*9/5)+32,"°F")

    else:
    print("\nEntered Wrong Option")

    ردحذف
  11. Adarsh dixit
    principal = int(input('enter principal amount:'))
    ratei = float(input('enter rate of intrest:'))
    numy = float(input('enter num of years:'))

    simpleinterest = (principal * ratei * numy)/100

    print('simple interest: {0}'.format(simpleinterest))

    ردحذف
  12. Adarsh dixit
    sno=int(input('enter service number'))
    cname=input('enter cust name')
    ore=int(input('enter old reading'))
    nre=int(input('enter new reading'))
    units=nre-ore
    if units<=100:
    amount=units*0.90
    surcharges=25
    elif units>100 and units<=300:
    amount=units*1.50
    surcharges=35
    elif units>300 and units<=500:
    amount=units*2.75
    surcharges=45
    elif units>500:
    amount=units*4.50
    surcharges=100
    netamount=amount+surcharges
    print('electrical info is:')
    print('meter number=',sno)
    print('name of cust=',cname)
    print('old reading=',ore)
    print('new reading=',nre)
    print('total numbers of units=',units)
    print('net payable amount=',netamount)

    ردحذف
  13. c=int(input('enter a celsius'))
    f = (9*c+160)/5
    print(f)

    ردحذف
  14. # PYTHON (6 To 7 PM BATCH)
    # Program to Calculate and Display Salary Slip of an employee.

    c = input("Company name :-")
    e = str(input("Employee name :-"))
    eid = input("Employee ID. :-")
    b = int(input("Basic Salary :-"))
    co = int(input("Medical Allowance :-"))
    d = int(input("Dearness Allowance :-"))
    t = int(input("Other Allowance :-"))
    h = int(input("HRA :-"))
    o = int(input("Over Time :-"))
    pf = int(input("PF :-"))
    esi = int(input("ESI :-"))
    tax = int(input("Professional Tax :-"))
    gross = b + co + d + t + h + o
    ded = pf + esi + tax
    net = (gross - ded)
    print("Company name :-\t", c)
    print()
    print("Employee name :-\t", e)
    print()
    print("Employee ID. :-\t", eid)
    print()
    print("Gross Earnings (A) :-\t", gross)
    print()
    print("Gross Deductions (B) :-\t", ded)
    print()
    print("Net Salary Payable (A-B) :-\t", net)
    print()

    st = str(net)
    sd = ["Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"];
    print("Net Salary Payable(in words):-\t", end='')
    for i in st:

    if i == "0":
    print(sd[0], "", end='')
    elif i == "1":
    print(sd[1], "", end='')

    elif i == "2":
    print(sd[2], "", end='')
    elif i == "3":
    print(sd[3], "", end='')
    elif i == "4":
    print(sd[4], "", end='')
    elif i == "5":
    print(sd[5], "", end='')
    elif i == "6":
    print(sd[6], "", end='')
    elif i == "7":
    print(sd[7], "", end='')
    elif i == "8":
    print(sd[8], "", end='')
    elif i == "9":
    print(sd[9], "", end='')
    else:
    print("SomeThing Went Wrong")
    print("Only")

    ردحذف
  15. conversion of temperature from Celsius to Fahrenheit:-
    c=float(input("Enter the temperature in Celsius:"))
    f=float((c*(9/5))+32)
    print("The conversion from Celsius to Fahrenheit is:",f,"F")

    ردحذف
  16. WAP to calculate Simple Interest where rate and time will be constant and
    the principal will be an integer?\


    CONST = (2.5,4.5)
    p=450000
    si = (p*CONST[0]*CONST[1])/100
    print(si)

    ردحذف
  17. a=int(input("enter purchasing amount"))
    u=int(input("enter given amount"))
    b=500
    c=50
    d=100
    e=10
    f=5
    g=2
    h=1
    n=u-a #1000-125=875
    print("return amount",n)
    r=n//b #875//500=1
    s=n%b #875%500=375
    t=s//d #375//100=3
    n=s%d #375%100=75
    w=n//c #75//50=1
    x=n%c #75%50=25
    y=x//e #25//10=2
    z=x%e #25%10=5
    i=z//f #5//5=1
    j=z%f
    k=j//g
    l=j%g
    m=l//h
    print("500--",r,",100--",t,"50--",w,"10--",y,"5--",i,"2--",k,"1--",m)

    ردحذف
  18. a=int(input("enter a number"))
    b=365
    c=30
    e=7
    y=a//b #200//365=0
    a=a%b #200%365=0
    m=a//c #200//30=6
    n=a%c #200%30=20
    w=n//e #20//7=2
    d=n%e #20%7=6
    print("year=",y,"month=",m,"week=",w,"days=",d)

    ردحذف
  19. Ques 1.
    esalary= 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 : "))

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

    oneday= esalary/30
    cutamt= leave*oneday

    final=("The final total amout after Leave : " ,tot-cutamt)
    print(final)

    Ques.2
    up=float(input("Enter the unit price : "))

    tc=float(input("Enter the consumption : "))

    el=float(input("Enter the Extra load : "))

    bill= up*tc+2*(up*el)
    print("Total bill is : ", str(bill))


    Ques.3
    C = (4.9,8.6)
    p=450000
    si = (p*C[0]*C[1])/100
    print(si)


    Ques.5
    c=float(input("Enter the Celsius: "))
    f=(c*9/5)+32
    print(f)

    f=float(input("Enter the Fahrenheit: "))
    c= (f-32)*5/9
    print(c)




    ردحذف
  20. Program to calculate AREA of Triangle,RECT and CIRCLE?

    CONST = (3.14,200,50)
    r = 5
    height=20
    width=300
    areaOfCircle = CONST[0]*r*r
    areaOfTriangle = (CONST[1]*height)/2
    areaOfRectangle = width*CONST[2]
    print("Area of Cirlce is",areaOfCircle)
    print("Area of Triangle is",areaOfTriangle)
    print("Area of Rectangle is ",areaOfRectangle)

    ردحذف
  21. CONS=(3.14,20,25)
    r,h,b=5,10,15
    at=(CONS[1]*20)/2
    print("area of traingle=",at)
    ac=(CONS[0]*r*r)
    print("area of circle=",ac)
    ar=(CONS[2]*b)
    print("area of rectangle",ar)

    ردحذف
  22. #NIKHIL SINGH CHOUHAN


    a=int(input("salary"))
    b=int(input("ta"))
    c=int(input("da"))
    d=int(input("comm"))
    e=int(input("pf"))
    f=int(input("hrd"))
    g=int(input("leave"))
    t=(a+b+c+d+e+f)
    perday=t/30
    k=g*perday
    i=(t-k-e)
    print("basic salary",t,"\nleave deduction amount=",k,"\nsalary after deduction=",i)

    ردحذف
  23. #Aditya Gaur
    salary=12000
    leave=3
    ta=400
    da=200
    comm=500
    pf=500
    hra= 300
    salaryperday=salary/30
    deduction=salaryperday*leave # leave calculation
    csalary=(salary + ta +da + comm + hra -pf -deduction ) #calculate salary
    print("Total salary :",csalary)

    ردحذف
  24. #aditya gaur
    p= int(input("Enter the amount: "))
    r= 2.5
    t= 1
    sinterest = (p * r * t) / 100
    print("Simple Interest is: ",sinterest)

    ردحذف
  25. '''calculating simple interest:
    Simple Interest= P x R x T ÷ 100
    where P = Principal, R = Rate of Interest and T = Time Period of the Loan
    '''
    p=int(input("Enter the Principal amt "))
    r=5
    t=12
    s=(p*r*t)/100
    a=p+s
    print("interest ",s)
    print("Total amount is ",a)

    ردحذف
  26. '''
    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=enter the user
    '''
    basic=12000
    ta=400
    hra=300
    pf=500
    da=200
    leave=int(input("Enter total leave day "))
    gross=basic+hra+da+ta
    days=(gross/30)*leave
    netpay=gross-days
    salary=netpay-pf
    print("This month Your salary is ",salary)

    ردحذف
  27. #simple intarest
    p=40000
    r=5
    t=3
    si=p*r*t/100
    a=si+p
    print(si)
    print(a)

    ردحذف
  28. #reverse number
    num=12345
    x=num%10
    num=num//10
    y=num%10
    num=num//10
    z=num%10
    num=num//10
    a=num%10
    num=num//10
    b=num%10
    print(x,y,z,a,b)
    print(x*10000+y*1000+z*100+a*10+b*1)

    ردحذف
  29. #user input reverse
    num=int(input("inter 5 digit number"))
    x=num%10
    num=num//10
    y=num%10
    num=num//10
    z=num%10
    num=num//10
    a=num%10
    num=num//10
    b=num%10
    print(x,y,z,a,b)
    print(x*10000+y*1000+z*100+a*10+b*1)

    ردحذف
  30. #WAP to calculate the area of a triangle, circle, and rectangle ?
    h=15
    b=20
    l=30
    r=10
    pi=3.14
    p=int(input("press 1 for triangle and press 2 for circle and press 3 for rectangle :- "))
    triangle=(h*b)/2
    circle=pi*r*r
    rectangle=l*b
    if p==1:
    print("Area of triangle ",triangle)

    if p==2:
    print("Area of circle ",circle)

    if p==3:
    print("Area of rectangle ",rectangle)

    ردحذف
  31. WAP to calculate the area of a triangle, circle, and rectangle ?

    CONST=(3.14,12,15)
    h=int(input("enter the height of traingle"))
    r=int(input("enter the radius of circle"))
    b=int(input("enter the base of rectangle"))
    t=(1/2)*CONST[1]*h
    c=CONST[0]*r*r
    re=CONST[2]*b
    print("Area of traingle" , t)
    print("Area of circle" , "c=%.2f" % (c))
    print("Area of rectangle" , re)

    ردحذف
  32. WAP to convert temperature from Celsius to Fahrenheit?

    c= float(input ("enter the celcius value"))
    f= (1.5*c+32)
    print ("Fahrenheit is", f)

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

    basic=float(input("enter the basic salary of employee"))
    ta=float(input("enter the ta of employee"))
    da=float(input("enter the da of employee"))
    comm=float(input("enter the comm of employee"))
    pf=float(input("enter the pf of employee"))
    hra=float(input("enter the hra of employee"))
    leave=float(input("enter the leave of employee"))

    gsal=basic+ta+da+comm+pf+hra
    tsal=basic+ta+da+comm+hra-pf
    nsal=gsal-((tsal/30)*leave)

    print("gross salary of employee" +str(gsal))
    print("net salary of employee" +str(nsal))

    ردحذف
  34. WAP to calculate Simple Interest where rate and time will be constant and
    the principal will be an integer?
    const= (2,5)
    p=600000
    si=(p*const[0]*const[1])/100
    print(si)

    ردحذف
  35. #WAP to calculate the area of a triangle, circle, and rectangle in the same program where the value of pi, the base of the triangle, and the height of the rectangle will be constant.

    const=(3.14,3,2)
    heightT=3
    breadthR=2
    radiusC=1
    triangleArea=(const[1]*heightT)/2
    circleArea=const[0]*radiusC*radiusC
    rectangleArea=const[2]*breadthR
    print("Area of Triangle=",triangleArea)
    print("Area of Circle=",circleArea)
    print("Area of Rectangle=",rectangleArea)

    ردحذف
  36. WAP to convert temperature from Celsius to Fahrenheit?

    int(input("Enter the Celcius Value="))
    fahrenheit=(1.8*celcius+32)
    print("Fahrenheit is",fahrenheit)

    ردحذف
  37. #SHREYA SINGH

    #WAP to calculate Simple Interest where rate and time will be constant and
    the principal will be an integer?

    const= (2,5)
    p=600000
    si=(p*const[0]*const[1])/100
    print(si)

    #WAP to calculate the area of a triangle, circle, and rectangle in the same program where the value of pi, the base of the triangle, and the height of the rectangle will be constant.

    const=(3.14,3,2)
    heightT=3
    breadthR=2
    radiusC=1
    triangleArea=(const[1]*heightT)/2
    circleArea=const[0]*radiusC*radiusC
    rectangleArea=const[2]*breadthR
    print("Area of Triangle=",triangleArea)
    print("Area of Circle=",circleArea)
    print("Area of Rectangle=",rectangleArea)

    #WAP to convert temperature from Celsius to Fahrenheit?

    int(input("Enter the Celcius Value="))
    fahrenheit=(1.8*celcius+32)
    print("Fahrenheit is",fahrenheit)

    ردحذف
  38. '''WAP to calculate Simple Interest where rate and time will be constant and
    the principal will be an integer?'''
    r,t=5,10
    p=int(input("enter principal :="))
    si=p*r*t/100
    print(si+p)

    ردحذف
  39. '''WAP to calculate the area of a triangle, circle, and rectangle in the same program where the value of pi, the base of the triangle, and the height of the rectangle will be constant.'''
    base=(5)
    height=(6)
    pi=3.14
    h=int(input("enter height of triangle:="))
    print("base is:-",base)
    area=base*h/2
    print("area of triangle is:-",area)
    r=int(input("enter radius of circle:="))
    area1=pi*r*r
    print("area of circle is:-",area1)
    w=int(input("enter width of rectangle:="))
    print("heigth is:-",height)
    area2=w*height
    print("area of ractangle:-",area2)

    ردحذف
  40. '''WAP to convert temperature from Celsius to Fahrenheit?'''
    t=int(input("enter temperature in celsius:-"))
    temp=t*9/5+32
    print("celsius to fahrenheit:-",temp)

    ردحذف
  41. WAP to reverse a five-digit number without using a loop?


    num=int(input("Enter the five digit no : "))
    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
    print("the reves five digit is ; " ,a,b,c,d,e)

    ردحذف
  42. SONAM SINGH
    WAP to calculate the total salary of an employee where basic,ta,da,comm,pf,hra leave will be entered by the users?
    esalary=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=(esalary+ta+da+comm-pf+hra)
    print("total salary without leave",total)
    oneday=esalary/30
    cutamt=leave*oneday
    final=("the final total amount after leave",total-cutamt)
    print(final)

    ردحذف
  43. SONAM SINGH
    WAP to convert temperature from celsius to fahrenheit
    a=float(input("enter the celceuis value"))
    b=(1.5*a+32)
    print("farhenheit" ,b)

    ردحذف
  44. SONAM SINGH
    WAP TO calculate the area of tringle,area of rectangle,area of circle in the same program where the value of pi,the base of triangle,height of rectangle will be constant
    constant =(15,30,3.14)
    height=20
    base=10
    r=5
    areaoftraingle=(constant[0]*height)/2
    print("areaoftraingle",areaoftraingle)
    areaofrectangle=(constant[1]*base)
    print("areaofreactangle",areaofrectangle)
    areaofcircle=(constant[2]*r*r)
    print("areaofcircle",areaofcircle)

    ردحذف
  45. # temperature conversion
    # by Mayank Sonwani
    body_temp=float(input("enter temperature in C: "))
    F=float(body_temp*9/5) +32
    print("Value in F is :",F)

    body_temp=float(input("enter temperature in F: "))
    C=float((body_temp-32)*5/9)
    print("Value in C is :",C)

    ردحذف
  46. # Raj kushwah

    Celsius to Fahrenheit

    Celsius=38
    Fahrenheit=(9/5)*Celsius+32
    print(Fahrenheit)

    output= 100.4 Fahrenheit

    ردحذف
  47. #four digit reverse number.

    num=5678
    a=num%10
    num=num//10
    b=num%10
    num=num//10
    c=num%10
    num=num//10
    d=num%10
    num=num//10
    num=a*1000+b*100+c*10+d*1
    print(num)

    ردحذف
  48. #reverse 4 digit number

    num=2345
    a=num%10
    num=num//10
    b=num%10
    num=num//10
    c=num%10
    num=num//10
    d=num%10
    num=num//10
    num=a*1000+b*100+c*10+d*1
    print(num)

    ردحذف
  49. #Area of triangle,circle & rectangle.

    #area of triangle where b,h is constant
    b,h=25,35
    CONST=[b,h]
    areaoftriangle=(CONST[0]*CONST[1]/2)
    print(areaoftriangle)

    #area of circle where pi is constant
    r=35
    pi=3.14
    CONST=pi
    areaofcircle=(CONST*r*r)
    print(areaofcircle)

    #area of rectangle where breath is constant
    l=20
    b=15
    CONST=b
    areaofrectangle=(CONST*l*b)
    print(areaofrectangle)

    ردحذف
  50. #wap to calculate electricity bil where umit price,total consumption,the extra load will be entered by the users?
    #sonam singh
    unit=float(input("enter the umit price"))
    consumption=float(input("enter the consumption"))
    load=float(input("enter the extra load"))
    bill=(unit*consumption)+load
    print("total billis%.2f"%bill)

    ردحذف
  51. #WAP TO calculate simple interest where rate and time will be constant.
    P=float(input("enter the amoumt value")
    CONST=(5.6,3.4)
    SI=(P*CONST[0]*CONST[1])/100
    print("SI is%.2f"%SI)

    ردحذف
  52. #wap to swap two numbers without using a third variable
    a=int(input("enter the value of a;"))
    b=int(input("enter the value of b;"))
    print("before swapping")
    print("value of a;"a"and b;"b")
    a,b=b,a
    print("after swapping")
    print("value of a;"a"and b;"b")

    ردحذف
  53. # wap to calculate the total salary of an enployee where basic,ta,da comm, pf,hrs,leave will be entered by the user?
    #basic = 12000(basic salary )
    #ta=400(trevelling allowance)
    #da=200(dearness allowance)
    #comm=500(coneyance allowance)
    #pf=500(prvident fund)
    #hra=300(House rent allowance)
    #leave=3(leave)
    basic=12000
    ta=400
    da=200
    comm=500
    pf=500
    hra=3
    leave=int(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)

    ردحذف
  54. #electric bill
    unit=float(input("enter the unit price"))
    consuption=float(input("enter the consuption"))
    load=float(input("enter extea load"))
    bill= (unit*consuption)+load
    print("%.2f"%bill)

    ردحذف
  55. """calculating Si unit where ,rate and time is constant and principle
    will be in intger form"""
    p=int(input("enter the value of p(principal)"))
    CONST=(2,2)
    si=(p*CONST[0]*CONST[1])/100#simple intrest formula
    print("the the value od si is",si)

    ردحذف
  56. #wap to calculate area of triangle,circle and rectangle in the same program whare the value of pi,the base of triangle ,and the hight of the rectangle is constant.
    #area of triangle = 1/2*b*h
    #area of circle= 3.14*r**2
    #area of rectangle= wl

    CONST=(3.14,7,10)
    hot=input("enter the hight of triagle")#hight of triangle
    roc=input("enter the radius of circle")#radius of circle
    wor=input("enter the width of rectangle")#width of rectangle
    lor=input("enter the value of length of rectangle")#length of r
    t=(1/2*CONST[1]*3)
    c=(CONST[0]*8)**(2)
    r=(7*5)
    print("the area of triangle is",t)
    print("the area of circle is ",c)
    print("the area of rectangle is",r)

    ردحذف
  57. #WAP to Reverse Five Digit Number?
    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*10000+b*1000+c*100+d*10+e*1
    print("the reverse value is",rev)

    ردحذف
  58. # wap to calculate the total salary of an enployee where basic,ta,da comm, pf,hrs,leave will be entered by the user?
    #basic = 12000(basic salary )
    #ta=400(trevelling allowance)
    #da=200(dearness allowance)
    #comm=500(coneyance allowance)
    #pf=500(prvident fund)
    #hra=300(House rent allowance)
    #leave=3(leave)
    basic=12000
    ta=400
    da=200
    comm=500
    pf=500
    hra=3
    leave=int(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)

    ردحذف
  59. #electric bill
    unit=float(input("enter the unit price"))
    consuption=float(input("enter the consuption"))
    load=float(input("enter extea load"))
    bill= (unit*consuption)+load
    print("%.2f"%bill)

    ردحذف
  60. #wap to calculate area of triangle,circle and rectangle in the same program whare the value of pi,the base of triangle ,and the hight of the rectangle is constant.
    #area of triangle = 1/2*b*h
    #area of circle= 3.14*r**2
    #area of rectangle= wl

    CONST=(3.14,7,10)
    hot=input("enter the hight of triagle")#hight of triangle
    roc=input("enter the radius of circle")#radius of circle
    wor=input("enter the width of rectangle")#width of rectangle
    lor=input("enter the value of length of rectangle")#length of r
    t=(1/2*CONST[1]*3)
    c=(CONST[0]*8)**(2)
    r=(7*5)
    print("the area of triangle is",t)
    print("the area of circle is ",c)
    print("the area of rectangle is",r)

    ردحذف
  61. """calculating Si unit where ,rate and time is constant and principle
    will be in intger form"""
    p=int(input("enter the value of p(principal)"))
    CONST=(2,2)
    si=(p*CONST[0]*CONST[1])/100#simple intrest formula
    print("the the value od si is",si)

    ردحذف
  62. #celcius to fahrenhet
    # f=(c*9/5)+(32)

    c=float(input("enter the temp. in c"))
    f=(c*9/5)+(32)
    print("the temp.in fahrenhiet to celcius is",c,f)

    ردحذف
  63. # reverse five number
    num=54321
    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)

    ردحذف
  64. # simple interest constant ratr and time
    p=120000
    r=12
    t=9
    CONST=(r,t)
    si=p*r*t
    print(si)

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

    ردحذف
  66. unit_price=float(input("Enter the unit price"))

    total_consumption=float(input("Enter the consumption"))

    extra_load=float(input("Enter the Extra load"))

    bill= unit_price*total_consumption+2*(unit_price*extra_load)
    print("Total bill is", str(bill))

    ردحذف
  67. principle=int(input("enter the principle"))
    rate=3
    time=4
    constant=(rate,time)
    simple_interest=(principle*rate*time)
    print(simple_interest)

    ردحذف
  68. base=6
    height=int(input("enter the height"))
    constant=(base)
    area=(constant*height)/2
    print(area)

    print("area of circle where pi is constant")
    radius=int(input("enter the radius"))
    pi=3.14
    constant=(pi)
    area=(constant*radius*radius)
    print(area)

    print("area of rectangle where height is constant")
    base=int(input("enter the base"))
    height=25
    constant=(height)
    area=(base*constant)
    print(area)

    ردحذف
  69. print("celsius to fahrenheit")
    celsius=float(input("enter the temperature in celsius"))
    fahrenheit=(celsius*9/5)+32
    print(fahrenheit)

    print("fahrenheit to celsius")
    fahrenheit=float(input("enter the temperature in fahrenheit"))
    celsius=(fahrenheit-32)*5/9
    print(celsius)

    ردحذف
  70. # area of circle pi is constant.
    r=float(input("enter value of radious"))
    CONST=3.14
    circle=(CONST*r*r)
    print(circle)

    ردحذف
  71. # area of triangle constant base .
    height=float(input("enter height"))
    CONST=5
    triangle=(CONST*height)
    print(triangle)

    ردحذف
  72. #area of circle where pi is const
    r=2
    pi=3.14
    cons=pi
    circle=cons*r*r
    print(circle)
    #area of traingle the base of traingle is constant
    h=10
    b=20
    cons=b
    traingle=(cons*h)//2
    print(traingle)
    #area of rectangle where hight is const
    b=20
    h=10
    cons=h
    rectangle=cons*b
    print(rectangle)

    ردحذف
  73. #tmperetur from celsius to fhrenhit?
    cel=30
    fhr=(9*cel+160)//5
    print(fhr)

    #fhrnhiet to celsius?
    fhr=86
    cel=(5*fhr-160)//9
    print(cel)

    ردحذف
  74. #to print the salary

    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)

    ردحذف
  75. Pooja Chundawat(vijaynagar branch)

    print("calcualte the total salary of employee")
    basic=int(input("Enter the basic 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=basic+ta+da+comm-pf+hra
    print("Total salary without leave=",total)
    day=basic/30
    cut=leave*day
    print("Salary with leave=",total-cut)

    ردحذف
  76. print("calcualte the total salary of employee")
    basic=int(input("Enter the basic 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=basic+ta+da+comm-pf+hra
    print("Total salary without leave=",total)
    day=basic/30
    cut=leave*day
    print("Salary with leave=",total-cut)

    ردحذف
  77. print("Calacualte Simple Interest")
    principal=int(input("Enter the Principal amount="))
    rate=(12)
    time=(2)
    Simple_Interest=(principal*rate*time)/100
    print("Simple Interest = ",Simple_Interest)

    ردحذف
  78. print("calculate the area of rectangle,circle,triangle")
    length=(12)
    breath=(10)
    a_rectangle=length*breath
    print("area of rectangle=",a_rectangle)
    pi=(3.14)
    radius=(5)
    a_circle=pi*radius*radius
    print("area of circle=",a_circle)
    base=(40)
    height=(20)
    a_triangle=1/2*base*height
    print("area of triangle",a_triangle)

    ردحذف
  79. # Python Program to convert temperature in celsius to fahrenheit


    celsius = (37.5)

    # calculate fahrenheit
    fahrenheit = (celsius * 1.8) + 32
    print('%0.1f degree Celsius is equal to %0.1f degree Fahrenheit' %(celsius,fahrenheit))

    ردحذف
  80. # 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
    nl=3
    tsal=basic+ta+da+comm+hra
    leave=tsal/30
    ctc=basic+ta+da+comm+pf+hra
    grossal=tsal-pf-(nl-1)*leave

    print("total salary is",tsal)
    print("leave deduction days,nl-1" and "amount is",(nl-1)*leave)
    print("package is",12*ctc)
    print("pf diduction is",pf)
    print("ta is",ta,"/n da is" ,da,"/n comm is",comm,"/n hra is",hra)
    print("grossal is",grossal)
    print("number of leave",nl)

    ردحذف
  81. # wap to reverse a five digit number without using a loop
    num=12345
    r1=num%10#5
    num1=num//10#1234
    r2=num1%10#4
    num2=num1//10#123
    r3=num2%10#3
    num3=num2//10#12
    r4=num3%10#2
    num4=num3//10#1
    r5=num4%10#1
    result=r1*10000+r2*1000+r3*100+r4*10+r5*1
    print(result)

    ردحذف
  82. #wap to calculate simple intrest where rate and time will be constant and the principal will be an integer?
    p=15693
    CONST=(6.5,4)
    si=(p*CONST[0]*CONST[1])//100
    #print(si)
    print("si is %2f" %si)

    ردحذف
  83. #wap tp calculate electricity bill where unit price,total consuption,the extra load will be entered by the users?
    up=float(input("enter unit price"))
    cons=float(input("enter consuption"))
    bill=up*cons
    print(bill)
    load=float(input("enter extra load"))
    totalbill=bill+2*(up*load)
    print("total bill"+str(totalbill))
    print("total consuption without load" +str(up*cons))
    print("total consuption with extra load"+str(2*(up*load)))

    ردحذف
  84. #convert temperature from Celsius to Fahrenheit
    celsius= float(input("Enter temerature in celsius="))
    fahrn= 33.8*celsius
    print(celsius,'Celsius is equal to ',fahrn,'Fahrenheit')

    ردحذف
  85. #WAP to calculate the area of a triangle, circle,
    #and rectangle in the same program where the value of pi,
    #the base of the triangle, and the height of the rectangle will be constant.

    PI= (3.14)
    BASETRIANGLE= (10)
    HEIGHTRECTANGLE= (6)
    heighttriangle=int(input("Enter Height of triangle= "))
    breadthrec,radiuscircle = int(input("Enter base of rectangle= ")),int(input("Radius of circle= "))
    trianglearea=1/2*(BASETRIANGLE*heighttriangle)
    areacircle= PI*radiuscircle**2
    recarea= HEIGHTRECTANGLE*breadthrec
    print('Area of triangle:',trianglearea)
    print('Area of circle:',areacircle)
    print('Area of rectangle:',recarea)

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