Sunday, July 14, 2019

An electricity board charges according to the following rates:

For the first 100 units -   40 paisa per unit.
For the next 200 units -   50 paisa per unit.
beyond 300 units -  60 paisa per unit.
All users are charged meter charges also, which are Rs. 50/-

unit = float(input("Enter  Unit = "))
rs = 0.00
if (unit<100):
rs = (unit * 0.40)
elif(unit <= 300 and unit > 100):
rs = 40+((unit-100)*0.50);
elif(unit>300):
rs=140+((unit-300)*0.60);
rs = rs + 50
print("total bill = " + str(rs))

WAP to input the salary of a person and calculate the hra and da according to the following conditions:

conditions:

  • Salary HRA DA
  • 5000-10000 10%       5%
  • 10001-15000 15%       8%


salary = float(input("Enter Salary = "))
print('-'*20)
if (salary >= 5000  and salary <=10000):
print("HRA = " + str((salary * 10)/100))
print("DA = " + str((salary * 5)/100))
elif(salary >= 10001  and salary <=15000):
print("HRA = " + str((salary * 15)/100))
print("DA = " + str((salary * 8)/100))
else:
print(" invalid salary ")

WAP to input the name and age of a person and display “CHILD”,“TEENAGER” or "ADULT" according to the age.

age = int(input("Enter age = "))
print('-'*20)
if (age >= 1  and age <= 12 ):
print(str(age) + " is a CHILD ")
elif(age >=13 and age <=19 ):
print(str(age) + " is a TEENAGER")
else:
print(str(age) + " is a ADULT")

WAP to input a number and check that number is divisible by 7 or not.

number = int(input("Enter Number = "))
print('-'*20)
if(number % 7 == 0):
print(str(number) + " is divisible by 7")
else:
print(str(number) + " is not divisible by 7")

WAP to input a number and check whether it is even or odd.

number = int(input("Enter number = "))
print('-'*20)
if (number % 2 == 0):
print(str(number)+ " is even number.")
else:
print(str(number) + " is odd number.")

WAP to check that a given year is a leap year or not.

year = int(input("Enter Year = "))
print('-'*20)
if (year % 400 == 0):
print(str(year) + " is a leap year.")
elif (year % 100 == 0):
print(str(year) + " isn't a leap year.")
elif(year % 4 == 0):
print(str(year)+ " is a leap year.")
else:
print(str(year) + " isn't a leap year.")

WAP to input the age of a person and check that he/she is eligible for license for not.

age = int(input("Enter Age = "))
print('-'*10)
if (age >=18):
print("he/she is eligible")
else:
print("he/she is not eligible")

Monday, June 3, 2019

WAP to input the marks of a student and print the result (passing marks = 40 %)

Marks = float(input('Enter marks = '))
print('-'*10)
if (Marks<40.0):
print('fail = ' + str(Marks))
else:
print('Pass = ' + str(Marks))

Sunday, May 26, 2019

Saturday, May 25, 2019

WAP to input the temperature in Fahrenheit and convert it into Celsius and vice versa

print("1: Convert temperature from Fahrenheit to Celsius.")
print("2: Convert temperature from Celsius to Fahrenheit.")
print('-'*10)
choice = int(input('Enter your choice (1, 2): '))
print('-'*10)
if(choice == 1):
        fh = float(input('Enter temperature in Fahrenheit: = '))
        cl = (fh - 32) / 1.8
        print('temperature in Celsius = ' + str(cl))   
elif(choice == 2):
        cl = float(input('Enter temperature in Celsius: = '))
        fh = (cl*1.8)+32
        print('Temperature in Fahrenheit: = ' + str(fh))
else:
        print("Invalid Choice !!!")

WAP to input a number. If the number is even, print its square otherwise print its cube

Number = float(input('Enter a number = '))
print('-'*10)
if (Number % 2 == 0):
print('Even')
print('Square = ' + str(Number * Number))
else:
print('Odd')
print('Cube = ' + str(Number * Number * Number))

WAP to input employee code, name and basic salary of an employee and calculate the following values

# HRA 40 % of basic salary
# DA 10 % of basic salary
# CCA 5 % of basic salary
# GS Basic + HRA + DA + CCA
# PF 10 % of GS
# IT 10 % of GS
# NS GS – (PF + IT)
#Display all the values.

EmployeeCode = int(input('Enter Employee Code = '))
EmployeeName = input('Enter Employee Name = ')
BasicSalary  = float(input('Enter Basic salary = '))
print('-'*10)
HRA = (BasicSalary * 40 ) / 100
DA = (BasicSalary * 10) / 100
CCA = (BasicSalary * 5) / 100
GS = BasicSalary + HRA + DA + CCA
PF = (GS * 10) / 100
IT = (GS * 10) / 100
NS = (GS - (PF + IT))

print('EmployeeCode = ' + str(EmployeeCode))
print('EmployeeName = ' + EmployeeName)
print('BasicSalary = ' + str(BasicSalary))
print('HRA = ' + str(HRA))
print('DA = ' + str(DA))
print('CCA = ' + str(CCA))
print('GS = ' + str(GS))
print('PF = ' + str(PF))
print('IT = ' + str(IT))
print('NS = ' + str(NS))

Wednesday, May 22, 2019

WAP to find out the area of a triangle

base = float(input('Enter Base = '))
height = float(input('Enter Height = '))
print('-'*10)
print('area = ' + str((base * height) / 2))

Monday, May 13, 2019

WAP to input inches from the user and convert it into yards and feet

Inches = float(input('Enter leangth in inches = '))
print('-'*10)
print('feets = ' + str ( Inches/12  ) )
print('yards = ' + str ( Inches/36  ) )

Friday, May 10, 2019

WAP to input a character and print its ASCII value

c = input("Enter a character =  ")
print('-'*10)
print("The ASCII value of '" + c + "' is",ord(c))

WAP to input principle, rate and time from the user and calculate the simple interest and total amount. Display all the values

Principle = float(input('Enter principle amount = '))
Rate = float(input('Enter rate(%) = '))
Time = float(input('Enter time = '))
#A = P(1 + rt)
print('-'*10)
print('principle amount = ' + str(Principle))
print('rate = ' + str(Rate))
print('time = ' + str(Time))
print('amount = ' + str(Principle * (1 + ((Rate / 100) * Time ) )))

WAP to input side of a square and calculate the area

Side = float(input('Enter side = '))
print('-'*10)
print('area = ' + str( Side * Side ))

WAP to input length and breadth of a rectangle and calculate the area and perimeter

Length = float(input('Enter Length = '))
Breath = float(input('Enter Breath = '))
print('-'*10)
print('perimeter = ' + str(2*(Length + Breath)))
print('area = ' + str(Length * Breath))

Thursday, May 9, 2019

WAP to input radius and calculate the area and circumference of a circle

import math
Radius = float(input('Enter radius = '))
print('-'*10)
print('Area = ' + str(math.pi * Radius *Radius))
print('circumference = ' + str(2 * math.pi * Radius))

WAP to input a number and print its cube

number = int(input('Enter Number = '))
print('-'*10)
print('square of a given number = ' +str (number * number * number))

WAP to find out the square of a given number

number = int(input('Enter Number = '))
print('-'*10)
print('square of a given number = ' +str (number * number))

WAP to input roll number, name, marks and phone of a student and display the values

RollNumber = int(input('Enter Roll Number = '))
Name = input('Enter Name = ')
Marks = int(input('Enter Marks of english subject = '))
Phone = int(input('Enter Phone Number = '))
print('-'*10)
print('Roll Number = '+ str(RollNumber))
print('Name = '+ Name)
print('Marks of english subject = '+ str(Marks))
print('Phone Number = '+ str(Phone))