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

WAP to print the system date

import datetime
now = datetime.datetime.now()
print(now)

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  ) )