التخطي إلى المحتوى الرئيسي

Python Program List


 
WAP to convert temperature from c to f? c/5 = (f-32)/9
Solution:-

c=int(input("enter temprature in celsius"))  # "25"  to 25
f=(9*c+160)/5
print(f)

WAP to calculate the sum of date of birth in a single digit?  (10061988)

Solution:-
dob = int(input("enter date of birth in ddmmyyyy")) #10061998
y1 = dob%10  #8   % return rem and // floor div
dob=dob//10  #1006199
y2 = dob%10   #9
dob=dob//10  ##100619
y3=dob%10     #9
dob=dob//10  ##10061
y4=dob%10     #1
dob = dob//10  #1006
y5 = dob%10    #6

dob = dob//10  #100
y6 = dob%10   #0
dob = dob//10  #10
y7 = dob%10   #0
y8 = dob//10   #1

s=  y1+y2+y3+y4+y5+y6+y7+y8
print(s)

s1 = s%10
s2=  s//10

print(s1+s2)


WAP to calculate the salary of an employee where basic, ta, da, comm, pf,noofleave will be entered by the users?

Solution:-

basic = int(input("Enter basic"))
ta=int(input("Enter ta in percentage")) #in per
da=int(input("Enter da in percentage"))
comm=int(input("Enter commision"))
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 of any assigned number?

num=2
sq = num*num
cb = num*num*num
print("Square is ",sq)
print("Cube is ",cb)


WAP to calculate the addition of complex numbers?

2+3i
4+5i
,,,,,,,,,,
6+8i


Solution:-

num1 = 2+3j
num2 = 4+5j
num3 = num1+num2
print(num3)


,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

WAP to calculate the area of triangle and circle in the same program?

pi=3.14
radius = float(input("enter radius")) #3.5
area = pi*radius*radius
#print("area of cirlce is ",area)
print("area of cirlce 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 enter complete income in the year and display income tax slab and total taxable amount?

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 the five-digit number where first and last digit will be the same?

num = int(input("enter any five digit number")) #12345
print(num)
a = num%10   #5
num=num//10  #1234
b = num%10   #4
num=num//10  #123
c = num%10   #3
num=num//10  #12
d = num%10   #2
e = num//10  #1
num1 = e*10000+b*1000+c*100+d*10+a*1
print(num1)

2)  WAP to calculate electricity bill where unit price, total consumption, the extra load will be entered by the users?

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 where rate and time will be constant and the principal will be an integer?

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))  # to convert float to string


WAP to Check Greatest Number using Ternary Operator?


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 that entered number is positive or negative suing ternary operator?

num=int(input("Enter number to take input from user's"))
print("number is positive") if num>=0 else print  ("number is negative")

WAP to check that candidate is eligible for  vote or not?

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 that salary is in come tax slab or not?
salary =45000
print("income tax slab") if salary>= 20834 else print("not in income tax slab")

WAP to check vowel, consonant?


WAP to check that number is 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 Example:-

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



Example of Ladder If-else for grace mark 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 convert binary to decimal and decimal to binary:-

WAP to print all char of keyboard?

i=32
while i<=126:
    print(chr(i))  #ascii to char
    i=i+1

WAP to print -5 to -1 and -1 to -5 using single while Loop?

i=1
while i<=10:
    if i<=5:
        print(i-6)
    else:
        print(5-i)
    i=i+1


WAP to display prime in the 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=count+1
     

 if count==2:
  print(result)

 first=second

 second=result


Q)  WAP to display only prime element in Set?

Q)  WAP to display factorial of set elements?


Q)  WAP to find max and second max element in set?


Q)  WAP to input any number and that number will be in the first position then the user will get first prize if second then the user will be the second winner, if third then the user will be third winner otherwise failure.


Q)  WAP to convert set to list and list to set?


q)  WAP to find max key and max value in the dictionary?
emp = {"empid":1001,"zlmn":"xyz","job":"manager","salary":45000}
#print(emp["empid"])
max=''
d =''
for key in emp:
    if max<key[0]:
        max=key[0]
        d=key

print(d) 


Q)  WAP to reverse dictionary elements?

emp = {"empid":1001,"empname":"xyz","job":"manager","salary":45000}
print(emp["empid"])
for key in emp:
    print(key,emp[key])


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






تعليقات

المشاركات الشائعة من هذه المدونة

Uncontrolled form input in React-JS

  Uncontrolled form input in React-JS? If we want to take input from users without any separate event handling then we can uncontrolled the data binding technique. The uncontrolled input is similar to the traditional HTML form inputs. The DOM itself handles the form data. Here, the HTML elements maintain their own state that will be updated when the input value changes. To write an uncontrolled component, you need to use a ref to get form values from the DOM. In other words, there is no need to write an event handler for every state update. You can use a ref to access the input field value of the form from the DOM. Example of Uncontrolled Form Input:- import React from "react" ; export class Info extends React . Component {     constructor ( props )     {         super ( props );         this . fun = this . fun . bind ( this ); //event method binding         this . input = React . createRef ();...

JSP Page design using Internal CSS

  JSP is used to design the user interface of an application, CSS is used to provide set of properties. Jsp provide proper page template to create user interface of dynamic web application. We can write CSS using three different ways 1)  inline CSS:-   we will write CSS tag under HTML elements <div style="width:200px; height:100px; background-color:green;"></div> 2)  Internal CSS:-  we will write CSS under <style> block. <style type="text/css"> #abc { width:200px;  height:100px;  background-color:green; } </style> <div id="abc"></div> 3) External CSS:-  we will write CSS to create a separate file and link it into HTML Web pages. create a separate file and named it style.css #abc { width:200px;  height:100px;  background-color:green; } go into Jsp page and link style.css <link href="style.css"  type="text/css" rel="stylesheet"   /> <div id="abc"> </div> Exam...

JDBC using JSP and Servlet

JDBC means Java Database Connectivity ,It is intermediates from Application to database. JDBC has different type of divers and provides to communicate from database server. JDBC contain four different type of approach to communicate with Database Type 1:- JDBC-ODBC Driver Type2:- JDBC Vendor specific Type3 :- JDBC Network Specific Type4:- JDBC Client-Server based Driver  or JAVA thin driver:- Mostly we prefer Type 4 type of Driver to communicate with database server. Step for JDBC:- 1  Create Database using MYSQL ,ORACLE ,MS-SQL or any other database 2   Create Table using database server 3   Create Form according to database table 4  Submit Form and get form data into servlet 5  write JDBC Code:-     5.1)   import package    import java.sql.*     5.2)  Add JDBC Driver according to database ide tools     5.3)  call driver in program         ...