#4j:Coding in Python{TENSION FINDER}

#tension
print('Input tension to find tension.')
j=str(input('Enter please: '))
w=str(input('Input yes if only 1 load is in water or no: '))
if w=='yes':
    a1=int(input("Input 1 if you want gravity 10m/s**2 and Input 2 if you want gravity 9.8m/s**2"))
    if a1==1:
        vo=eval(input("Enter volume of object: "))
        do=eval(input("Enter density of object: "))
        dl=eval(input("Enter density of liquid: "))
        g=10
        t=(((vo)*g)*(dl-do))
        print("Tension is ",t," N")
    if a1==2:
        vo=eval(input("Enter volume of object: "))
        do=eval(input("Enter density of object: "))
        dl=eval(input("Enter density of liquid: "))
        g=9.8
        t=(((vo)*g)*(dl-do))
        print("Tension is ",t," N")
else:
    print('Input 1 when loads are parallel to surface.')
    q=int(input('Enter choice please: '))
    if q==1:
        q1=int(input('Enter number of loads: '))
        if q1==2:
            print("Only for 2 loads")
            f=float(input('Enter main force applied (if given): '))
            m2=float(input('Enter mass of load which is directly pulled by force: '))
            m1=float(input('Enter mass of next load: '))
            t=((m1*f)/(m2+m1))
            a=(t/(m1))
            print(t,' N')
            print('Acceleration produced is ',a)
        if q1==3:
            print("Only for 3 loads")
            f=float(input('Enter main force applied (if given): '))
            m3=float(input('Enter mass of load which is directly pulled by force'))
            m2=float(input('Enter mass of next load: '))
            m1=float(input('Enter mass of next load: '))
            t1=((m1*f)/(m3+m2+m1))
            a=(t1/(m1))
            t2=((m2*a)+t1)
            print('There are two tensions one between ',m1,' kg and ',m2,' kg which is ',t1,' N')
            print('The other between ',m2,' kg load and ',m3,' kg load which is ',t2,' N')
            print('Acceleration produced is ',a,' m/s**2')
        if q1==4:
            print('Only for 4 loads')
            f=float(input('Enter main force applied (if given): '))
            m4=float(input('Enter mass of load which is directly pulled by force'))
            m3=float(input('Enter mass of next load: '))
            m2=float(input('Enter mass of next load: '))
            m1=float(input('Enter mass of next load: '))
            t1=((m1*f)/(m4+m3+m2+m1))
            a=(t1/(m1))
            t2=((m2*a)+t1)
            t3=((m3*a)+t2)
            print('There are two tensions one between ',m1,' kg and ',m2,' kg which is ',t1,' N')
            print('The other between ',m2,' kg load and ',m3,' kg load which is ',t2,' N')
            print('And the other between ',m3,' kg load and ',m4,' kg load which is ',t3,' N')
            print('Acceleration produced is ',a,' m/s**2')
        if q1==5:
            print('Only for 5 loads')
            f=float(input('Enter main force applied (if given): '))
            m5=float(input('Enter mass of load which is directlly pulled by force'))
            m4=float(input('Enter mass of next load: '))
            m3=float(input('Enter mass of next load: '))
            m2=float(input('Enter mass of next load: '))
            m1=float(input('Enter mass of next load: '))
            t1=((m1*f)/(m4+m3+m2+m1))
            a=(t1/(m1))
            t2=((m2*a)+t1)
            t3=((m3*a)+t2)
            t4=((m4*a)+t3)
            print('There are two tensions one between ',m1,' kg and ',m2,' kg which is ',t1,' N')
            print('The other between ',m2,' kg load and ',m3,' kg load which is ',t2,' N')
            print('The other between ',m3,' kg load and ',m4,' kg load which is ',t3,' N')
            print('And the other between ',m4,' kg load and ',m5,' kg load which is ',t4,' N')
            print('Acceleration produced is ',a,' m/s**2')
        else:
            ('Hey decrease/increase the load')





Download CODES here.

Comments