WAP to Convert Temperature from Celsius to Fahrenheit
c = int(input("enter temperature in celsius"))
f = (9*c + 160) / 5
print(f)
WAP to Calculate Sum of DOB in Single Digit
dob = int(input("enter date of birth in ddmmyyyy"))
y1 = dob % 10
dob //= 10
y2 = dob % 10
dob //= 10
y3 = dob % 10
dob //= 10
y4 = dob % 10
dob //= 10
y5 = dob % 10
dob //= 10
y6 = dob % 10
dob //= 10
y7 = dob % 10
y8 = dob // 10
s = y1+y2+y3+y4+y5+y6+y7+y8
print(s)
s1 = s % 10
s2 = s // 10
print(s1 + s2)
WAP to Calculate Employee Salary
basic = int(input("Enter basic"))
ta = int(input("Enter ta in percentage"))
da = int(input("Enter da in percentage"))
comm = int(input("Enter commission"))
pf = int(input("Enter pf"))
noofleave = float(input("Enter no of leave"))
totalsal = basic + (basic*(ta/100)) + (basic*(da/100)) + (basic*(comm/100)) - (basic*(pf/100))
lsal = totalsal/30 * noofleave
ctotalsal = totalsal - lsal
print("Total Salary is ", totalsal)
print("Total Leave Deduction is ", lsal)
print("Total PF Deduction is ", (basic*(pf/100)))
print(ctotalsal)
WAP to Calculate Square and Cube
num = 2
sq = num*num
cb = num*num*num
print("Square is ", sq)
print("Cube is ", cb)
WAP to Add Two Complex Numbers
num1 = 2+3j
num2 = 4+5j
num3 = num1 + num2
print(num3)
WAP to Calculate Area of Circle and Triangle
pi = 3.14
radius = float(input("enter radius"))
area = pi * radius * radius
print("area of circle is %.2f" % area)
b = int(input("enter base"))
h = int(input("enter height"))
area = (b*h)/2
print("area of triangle is ", area)
WAP to Display Income Tax Slab
income = float(input("enter monthly income"))
yincome = 12 * income
if yincome >= 250000 and yincome <= 500000:
tax = yincome * (5/100)
elif yincome <= 1000000:
tax = yincome * (20/100)
else:
tax = yincome * (30/100)
print("monthly income is", income, "Yearly income is", yincome, "Tax is", tax)
WAP to Reverse Five-Digit Number
num = int(input("enter any five digit number"))
print(num)
a = num % 10
num //= 10
b = num % 10
num //= 10
c = num % 10
num //= 10
d = num % 10
e = num // 10
num1 = e*10000 + b*1000 + c*100 + d*10 + a
print(num1)
WAP to Calculate Electricity Bill
unitprice = float(input("enter unit price"))
consumption = float(input("enter total consumption"))
loadamount = 0
if consumption > 1000:
loadamount = float(input("enter load amount"))
bill = unitprice * consumption + loadamount
print("bill is ", bill, "load amount is", loadamount)
WAP to Calculate Simple Interest (Constant Rate and Time)
const = (8.23, 20)
p = int(input("enter amount"))
si = (p * const[0] * const[1]) / 100
print(si)
WAP to Calculate Compound Interest
p = float(input("enter amount"))
r = float(input("enter rate"))
t = float(input("enter time"))
n = float(input("enter number of time for interest applied"))
r1 = r / 100
A = p * ((1 + (r1/n)) ** (n * t))
print("Total Compound interest is " + str(A))
WAP to Find Greatest of Three Numbers (Ternary)
num1 = int(input("enter first number "))
num2 = int(input("enter second number"))
num3 = int(input("enter third number"))
print("num1 is greater") if num1>num2 and num1>num3 else print("num2 is greater") if num2>num3 else print("num3 is greater")
WAP to Check Positive or Negative
num = int(input("Enter number"))
print("number is positive") if num >= 0 else print("number is negative")
WAP to Check Leap Year
year = 2000
print("leap year") if year%4==0 and year%100!=0 else print("not leap year")
WAP to Check Income Tax Slab
salary = 45000
print("income tax slab") if salary >= 20834 else print("not in income tax slab")
WAP to Check One Digit or Two Digit
print("one digit") if (num>=0 and num<10) else print("two digit") if num<100 else print("above two digit")
Nested If-Else for Grace Marks
mark = int(input("enter mark"))
if mark>=28 and mark<33:
gmark = 33-mark
mark = mark + gmark
print("grace marks is ", gmark)
else:
if mark>=33:
print("Without grace ,Mark is "+str(mark))
else:
print("Out of grace criteria and failed,marks is "+str(mark))
Ladder If-Else Example
mark = int(input("enter mark"))
if mark>=28 and mark<33:
gmark = 33-mark
mark = mark + gmark
print("grace marks is ", gmark, mark)
elif mark>=33:
print("Without grace ,Mark is "+str(mark))
else:
print("Out of grace criteria and failed,marks is "+str(mark))
WAP to Print All ASCII Characters
i = 32
while i <= 126:
print(chr(i))
i += 1
WAP to Print -5 to -1 and -1 to -5 Using Single Loop
i = 1
while i <= 10:
if i <= 5:
print(i - 6)
else:
print(5 - i)
i += 1
WAP to Display Prime Numbers in Fibonacci Series
first, second = -1, 1
for i in range(1, 9):
count = 0
result = first + second
for j in range(1, result+1):
if result % j == 0:
count += 1
if count == 2:
print(result)
first = second
second = result
WAP to Find Max Key in Dictionary
emp = {"empid":1001,"zlmn":"xyz","job":"manager","salary":45000}
max = ''
d = ''
for key in emp:
if max < key[0]:
max = key[0]
d = key
print(d)
WAP to Reverse Dictionary Elements
emp = {"empid":1001,"empname":"xyz","job":"manager","salary":45000}
x=[]
y=[]
for key in emp:
x.append(key)
y.append(emp[key])
for i in range(len(x)-1,-1,-1):
print(x[i], y[i])
0 Comments
POST Answer of Questions and ASK to Doubt