#check if a number is positive or not.
number = int(input('Enter a number: '))
if number > 0:
print('Positive number')
else:
print('Not a positive number')
output:
Enter a number: 10
Positive number
###
##
Write a program to calculate the electricity bill(accept no of unit from user) according to the
following criteria.
Unit price
First 100 units no charge
Next 100 units Rs 5 per unit
After 200 units Rs 10 per unit
amount=0
unit=int(input("enter the unit"))
if unit<=100:
amount=0
print("amount to pay :", amount)
if unit<=200:
amount=(unit-100)*5
print("amount to pay :", amount)
if unit>200:
amount=500+(unit-200)*10
print("amount to pay :", amount)
output
enter the unit210
amount to pay : 600
enter the unit110
amount to pay : 50
enter the unit80
amount to pay : 0
### Write a program to accept percentage from the user and display the grade according to the
following criteria:
Marks Grade
> 90 A
>80 and <= 90 B
>= 60 and <= 80 C
below 60 D
Answer
per = int(input("Enter marks"))
if per>90:
print("Grade is A")
elif per>80 and per <=90:
print("Grade is B")
elif per>=60 and per<=80:
print("Grade is C")
elif per<60:
print("Grade is D")
output:
Enter marks85
Grade is B
Enter marks100
Grade is A
Enter marks50
Grade is D
Enter marks65
Grade is C
0r
per = int(input("Enter marks"))
if per>90:
print("Grade is A")
elif per>80 and per <=90:
print("Grade is B")
elif per>=60 and per<=80:
print("Grade is C")
else:
print("Grade is D")