Computer Science, asked by apjefrina123, 3 days ago

1. Write a program to print electricity bill based on the consumption. • Consumption less than 200 units = No of units * 5 • Consumption between 200 and 500 = No of units * 10 • Consumption more than 500 = No of units*15 in python

Answers

Answered by Equestriadash
17

Co‎de:

\tt u\ =\ float(in put("Enter\ the\ number\ of\ units\ consumed:\ "))\\print()\\if\ u\ <\ 200:\\{\ \ \ \ \ }b\ =\ u*5\\elif\ u\ >\ 200\ and\ u\ <\ 500:\\{\ \ \ \ \ }b\ =\ u*10\\elif\ u\ >\ 500:\\{\ \ \ \ \ }b\ =\ u*15\\print("* * *Electricity\ Bill* * *")\\print(b,\ "is\ the\ amount\ to\ be\ paid.")

Explanation:

The input is retrieved using the \tt in put() fu‎nction, which is designed for the same, in a float datatype [decimals] and is stored in the variable u. The number of units is checked using conditional statements, which are used to check for a given condition and proceed accordingly. If a condition is fulfilled, the succeeding statement is then interpreted and the final amount is printed.

Answered by purveshKolhe
14

\huge{\green{\underbrace{\overbrace{\mathfrak{\red{answer::}}}}}}

units = int(input())

if units < 200:

  print(units * 5)

elif units > 200 and units < 500:

  print(units * 10)

else:

  print(units * 15)

-------------------------------

\huge{\bf{\underline{\orange{Logic-}}}}

  • Variable x contains the input.
  • We checked the number of units according to given conditions and designed a if...elif...else framework
  • And we finished it.

-------------------------------

Note :- Only enter numbers as units in the input.

-------------------------------

\underline{\huge{\orange{\bf{Sample\:I/O-}}}}

215

>>> 2150

125

>>> 625

532

>>> 7980

_____________________

Hope it helps...

_____________________

Similar questions