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

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