1. Identification and solving of simple real life or scientific or technical problems, and developing flow charts for the same.

 

1. Identification and solving of simple real life or scientific or technical problems, and developing flow charts for the same. 

Write a program to calculate the electricity bill, we must understand electricity charges and rates.

/*

1 - 100 unit - 1.5/=

101-200 unit - 2.5/=

201-300 unit - 4/=

300 - 350 unit - 5/=

above 300 - fixed charge 1500/=

for example

*/

This program can explain as follows

  • Declare total unit consumed by the customer using the variable unit.
  • If the unit consumed less or equal to 100 units, calculates the total amount of consumed =units*1.5
  • If the unit consumed between 100 to 200 units, calculates the total amount of consumed=(100*1.5)+(unit-100)*2.5)
  • If  unit consumed between 200 to 300 units ,calculates total amount ofconsumed=(100*1.5)+(200-100)*2.5+(units-200)*4
  • If unit consumed between 300-350 units ,calculates total amount of consumed=(100*1.5)+(200-100)*2.5+(300-200)*4+(units-350)*5
  • If the unit consumed above 350 units, fixed charge – 1500/=

 

  • additional charges

if units<=100 – 25.00

if 100< units and units<=200 – 50.00

if 200 < units and units<=300 – 75.00

if 300<units and units<=350 – 100.00

if units above 350 – No additional charges

#program for calculating electricity bill in Python

units=int(input("please enter the number of units you consumed in a month"))

if(units<=100):

payAmount=units*1.5

fixedcharge=25.00

elif(units<=200):

payAmount=(100*1.5)+(units-100)*2.5

fixedcharge=50.00

elif(units<=300):

payAmount=(100*1.5)+(200-100)*2.5+(units-200)*4

fixedcharge=75.00

elif(units<=350):

payAmount=(100*1.5)+(200-100)*2.5+(300-200)*4+(units-300)*5

fixedcharge=100.00

else:

payAmount=0

fixedcharge=1500.00

Total=payAmount+fixedcharge;

print("\nElecticity bill=%.2f" %Total)

1)                 Electricity bill calculation – with  and operator


#program for calculating electricity bill in Python using and operator

units=int(input("Number of unit consumed: "))

if(units>0 and units<=100):

payAmount=units*1.5

fixedcharge=25.00

elif(units>100 and units<=200):

payAmount=(100*1.5)+(units-100)*2.5

fixedcharge=50.00

elif(units>200 and units<=300):

payAmount=(100*1.5)+(200-100)*2.5+(units-200)*4

fixedcharge=50.00

elif(units>300):

payAmount=2500;#fixed rate

fixedcharge=75.00

else:

payAmount=0;

Total= payAmount+fixedcharge

print("\nElecticity bill pay=%.2f: " %Total);

 

 

 

2)               sin x = x - x3/3! + x5/5! - x7/7! + x9/9! ........

x = int(input("Enter the value of x: "))
n = int(input("Enter the value of n: "))
sign = -1
fact = i =1
sum = 0
while i<=n:
    p = 1
    fact = 1
    for j in range(1,i+1):
        p = p*x
        fact = fact*j
    sign = -1*sign
    sum = sum + sign* p/fact
    i = i+2
print("sin(",x,") =",sum)

 

 

Using function in python

# Import Module

import math

 

# Create sine function

def sin( x, n):

    sine = 0

    for i in range(n):

        sign = (-1)**i

        pi = 22/7

        y = x*(pi/180)

        sine += ((y**(2.0*i+1))/math.factorial(2*i+1))*sign

    return sine

 

# driver nodes

# Enter value in degree in x

x = 10

 

# Enter number of terms

n = 90

 

# call sine function

print(round(sin(x,n),2))

 

 

 

 

 

3)         Compute Electrical Current in Three Phase AC Circuit

 

#pg 200
#calculate the line current, power factor and power supplied
#  Given data
from math import cos,acos,sqrt
R = 20.;#  in ohm
X_L = 15.;#  in ohm
V_L = 400.;#  in V
f = 50.;#  in Hz
#calculations
V_Ph = V_L/sqrt(3);#  in V
Z_Ph = sqrt( (R**2) + (X_L**2) );#  in ohm
I_Ph = V_Ph/Z_Ph;#  in A
I_L = I_Ph;#  in A
print "The line current in A is",round(I_L,2)
# pf = cos(phi) = R_Ph/Z_Ph;
R_Ph = R;#  in ohm
phi= acos(R_Ph/Z_Ph);
#  Power factor
pf= cos(phi);#  in radians
print "The power factor is : ",pf,"degrees lag."
P = sqrt(3)*V_L*I_L*cos(phi);#  in W
print "The power supplied in W is",P
 
 
The line current in A is 9.24
The power factor is :  0.8 degrees lag.
The power supplied in W is 5120.0
 
 
4) Weight of a steel Bar 
 
steel bar weight formula D²L/162 

 

 

Comments

Popular posts from this blog

12. Developing a game activity using Pygame like bouncing ball, car race etc.

G3151-Problem Solving and Python Programming (2021 Regulations Anna University,Chennai)