1.
WAPP to print multiplication table
puspa raj
n=int(input("Enter a number to multiply:-"))
for i in range(1,11):
print(n,"X", i,"=",i*n)
-------------------------------------------------------------------------------
2.WAPP to print string in reverse
a = input("Enter any String:-")
reverse_string = ""
for i in a: chuttamalle song
reverse_string = i + reverse_string
print("reverse string is ",reverse_string)
-----------------------------------------------------------
3.WAPPTO PRINT SQUARE
print("Numbers \t SQUARES")
for i in range(1,11): davuudi song
print(i,"\t", i **2)
4.WAPP TO PRINT REVERSE NUMBER
num1 = input("Enter any number : ")
print("Reverse number is : ", num1[: : -1])
5.WAPP TO DISPLAY NUMBER IN STRINGS
n = input("Enter number : ")
l = list(n) rasmika mandana
n = {0 : "Zero", 1 : "One", 2 : "Two", 3 : "Three", 4 : "Four", 5 : "Five", 6 : "Six", 7 :
"Seven", 8 : "Eight", 9 : "Nine"}
for i in l:
print(n[int(i)], end = " ")
6.WAPP TO FIND FACTORIAL NUMBER
n = int(input("Enter any number : "))
f=1
for i in range(1,n+1):
f=f*i
print("Factorial of a number is : ", f)
7.WAPP TO FIND NUMBER IS PALINDROME OR NOT
n = input("Enter any number : ")
r= n[: : -1]
if n == r:
print("Number is Palindrome")
else:
print("Number is not Palindrome")
8 Write a Python program to find the sum of two numbers.
a = 10
b = 20
c=a+b
print(c)
9.To find sale price of an item with given cost and discount (%).
cost = float(input("Enter the cost of an Item :- "))
disc = int(input("Enter the Discount (%) to be given :- "))
disc_amt = cost * disc/100
sale_price = cost-disc_amt
print("The cost price of an Item",cost)
print("Discount (%) given",disc)
print("Sale price is :- ", sale_price)
10.To calculate Simple and Compound interest
p = float(input('Enter amount: '))
t = float(input('Enter time: '))
r = float(input('Enter rate: '))
# Calculation
simple_interest = (p*t*r)/100
compound_interest = p * ( (1+r/100)**t - 1)
# Displaying result
print('Simple interest is: %f' % (simple_interest))
print('Compound interest is: %f' %(compound_interest))
11. WAPP To calculate Commission on the Sales done by a Sales man
name=input("Salesman Name :")
sales=float(input("Enter Sales done in Rs."))
if sales>=20000:
comm=sales*0.15
elif sales>=15000:
comm=sales*0.10
elif sales>=10000:
comm=sales*0.05
else:
comm=0.00
print("Sales in Rs.",sales)
print(name,"earned Commission in Rs.",comm)
12.WAPP TO CALCULATE MARKS,AVG AND GRADE
s1=int(input("Enter marks of the first subject: "))
s2=int(input("Enter marks of the second subject: "))
s3=int(input("Enter marks of the third subject: "))
s4=int(input("Enter marks of the fourth subject: "))
s5=int(input("Enter marks of the fifth subject: "))
tot=s1+s2+s3+s4+s5
avg=(s1+s2+s3+s4+s5)/5
print("Total Marks=",tot)
print("Average marks =",avg)
if(avg>=90):
print("Grade: A")
elif(avg>=80 and avg<90):
print("Grade: B")
elif(avg>=70 and avg<80):
print("Grade: C")
elif(avg>=60 and avg<70):
print("Grade: D")
else:
print("Grade: F")
13. WAPP to Check whether a number is positive, negative, or zero
number = int(input("Enter a number: "))
if number > 0:
print("Number is positive")
elif number < 0:
print("Number is negative")
else:
print("Number is zero")
14.WAPP TO CALCULATE PROFIT AND LOSS
def profit(cp, sp):
resultProfit = (sp - cp)
returnresultProfit
def loss(cp, sp):
resultLoss = (cp - sp)
returnresultLoss
cost_price = 500
selling_price = 1000
ifselling_price == cost_price:
print("Neither profit nor Loss")
elifselling_price>cost_price:
print("The Profit is", profit(cost_price, selling_price))
else:
print("The Loss is", loss(cost_price, selling_price))
15.WAPP to check username and password
u= "admin"
p = "password123"
def check_login(username, password):
if username==u and password==p:
return "Login successful!"
else:
return "Invalid username or password.Please try again"
input_username = input("Enter your username: ")
input_password = input("Enter your password: ")
result = check_login(input_username, input_password)
print(result)
16.WAPP to check reserved keys in python
import keyword
list=keyword.kwlist
print(len(list))
for i in list:
print(i)
17.WAPP TO CHECK NUMBER IS ODD or EVEN
num = int (input('Enter number to test whether it is ODD or EVEN:'))
if (num % 2) == 0:
print (num,'is the EVEN number')
else:
print (num, 'is the ODD number')
18.WAPP using del keyword
name = ["Elon Musk", "Bill Gates","SundarPichai"]
del name[1]
print (name)
19.WAPP using return keyword
def a(x, y):
return x + y
print (a(5, 5)
20.WAPP using in keyword
name = ['ram', 'sam', 'raj']
exist = 'rai' in name
print (exist)
21.WAPP USING TRY EXCEPT FINAL
try:
num_subjects =int(input("Enter the number of subjects: "))
total_marks = 0
for i in range(num_subjects):
marks = int(input(f"Enter marks for subject {i+1}: "))
total_marks += marks
average = total_marks / num_subjects
print("Average marks:", average)
except ValueError:
print("Invalid input. Please enter numbers only.")
except ZeroDivisionError:
print("Cannot calculate average for 0 subjects.")
finally:
print("Program execution completed.")
22.WAPPFOR NUMBER SYSTEM
a=int(input("Enter Number:-"))
print("Conversion of decimal number", a, "is:")
print( " Binary is:-\t", bin(a),)
print(" Octal is:-\t", oct(a))
print("Hexadecimal is:-", hex(a))
23.WAPP TO FIND WHETHER NUMBER IS PRIME OR COMPOSITE
num = int(input("Enter any number : "))
if num > 1:
for i in range(2, num):
if (num % i) == 0:
print(num, "is composite number")
break
else:
print(num, "is a PRIME number")
elifnum == 0 or 1:
print(num, "is a neither prime NOR composite number")
24.WAPP TO FIND DATA TYPE USING type()
a=1
b=6.0
c = "I am a String"
d=1+2j
e=False
f = ("I am", "a", "Tuple")
g = ["I am", "a", "List"]
h={3,2,1}
i = {"I am": 1, "a":2, "Dictionary":3}
j=None
k=True
#output
print(a,":-I am Integer", type(a))
print(b,type(b))
print(c,type(c))
print(d,type(d))
print(e,type(e))
print(f,type(f))
print(g,type(g))
print(h,type(h))
print(i,type(i))
print(j,type(j))
print(k,type(k))
25.WAPP TO DEMONSTRATE INTEGER LITERALS
# Integer literals
a = 10 # Decimal
b = 0b1010 # Binary
c = 0o12 # Octal
d = 0xA # Hexadecimal
# Floating-point literals
e = 3.14
f = 2.7e-3
# Complex literals
g = 2 + 3j
#output
print("Integer literals:", a, b, c, d)
print("Floating-point literals:", e, f)
print("Complex literal:", g)
26.WAPP TO DEMONSTRATE STRING LITERALS
# Single-quoted string
a= 'This is a single-quoted string.'
print(a)
# Double-quoted string
b= "This is a double-quoted string."
print(b)
# Triple-quoted string (for multi-line strings)
c = """This is a
multi-line string
using triple quotes."""
print(c)
# Escape sequences
d = "This string contains a tab \t and a newline \n character."
print(d)
27.WAPP TO COUNT TOTAL NO.OF VOWELS AND CONSONANTS IN A STRING
str = input("Enter String : ")
v = 0;c = 0;u=0;l=0
for i in range(0,len(str)):
if(str[i].isupper()):
u=u+1
elif((str[i].islower())):
l=l+1
str=str.lower()
for i in range(0,len(str)):
ifstr[i] in ('a',"e","i","o","u"):
v = v + 1;
elif (str[i] >= 'a' and str[i] <= 'z'):
c = c + 1;
print("Total vowels are:-",v)
print("Total Consonants are:-",c)
print("Total Uppercase are:-",u)
print("Total lowercase are:-",l)
28.WAPP TO Check Whether a Given Number is Perfect Number or not
n = int(input("Enter any number: "))
sum1 = 0
for i in range(1, n):
if(n % i == 0):
sum1 = sum1 + i
if (sum1 == n):
print(n," is a Perfect number!")
else:
print(n," is not a Perfect number!")
29.WAPP TO Check Whether a Given Number is Armstrong Number or not
n = int(input('Enter number '))
t=n
cube_sum = 0
while t!= 0:
k = t % 10
cube_sum += k**3
t = t//10
ifcube_sum == n:
print(n, ' is an Armstrong Number')
else:
print(n, 'is not a Armstrong Number')
30.WAPP TO demonstrate Boolean Literal
x = (1 == True)
y = (2 == False)
a = True + 100
b = False + 101
print("x is", x)
print("y is", y)
print("a:", a)
print("b:", b)
34.Python program to count the total number of digits in a number
n=1234567890
n = str(n)
count=0
for i in n:
count += 1
print(count)
35.Python program to convert the month name to a number of days.
month = ["January", "April", "August","June","November"]
# iterate through each mont in the list
for i in month:
if i == "February":
print("The month of February has 28/29 days")
elif i in ("April", "June", "September", "November"):
print("The month of",i,"has 30 days.")
elif i in ("January", "March", "May", "July", "August", "October",
"December"):
print("The month of",i,"has 31 days.")
else:
print(i,"is not a valid month name.")
36. Write a python program to find sum and product of all its digits
num=int(input("Enter a number:"))
num1=num
print("------------------------------------------")
product=1
sumd=0
while num1>0:
d=num1%10
sumd+=d
product*=d
num1=num1//10
print("OUTPUT VALUES")
print("*************")
print("Sum of the digits of",num,"is : ",sumd)
print("product of the digits of",num,"is : ",product)
print("------------------------------------------")
37. Write a python program to input month number out of 1 to 12
and display corresponding month name , for example if we enter 3
it display March .
mno=int(input("Enter a Month Number : "))
if mno==1:
month=str(mno)+" --> January"
elif mno==2:
month=str(mno)+" --> February"
elif mno==3:
month=str(mno)+" --> March"
elif mno==4:
month=str(mno)+" --> April"
elif mno==5:
month=str(mno)+" --> May"
elif mno==6:
month=str(mno)+" --> June"
elif mno==7:
month=str(mno)+" --> July"
elif mno==8:
month=str(mno)+" --> August"
elif mno==9:
month=str(mno)+" --> September"
elif mno==10:
month=str(mno)+" --> October"
elif mno==11:
month=str(mno)+" --> November"
elif mno==12:
month=str(mno)+" --> December"
else:
month="Invalid Input... Please enter 1 to 12 only...."
print(month)
38(a).WAPP using Arithmetic Operator
a=10
b=2
print(a+b)
print(a-b)
print(a*b)
print(a/b)
print(a//b)
print(a%b)
print(a**b)
38(b).WAPP using Relational Operator
a=10
b=5
print(a>b)
print(a>=b)
print(a<b)
print(a<=b)
print(a==b)
print(a!=b)
39. WAPP using Assignment Operator
a = 10 # Assignment Operator
a=a+ 5 # Addition Assignment
print ("a += 5 : ", a)
a -= 5 # Subtraction Assignment
print ("a -= 5 : ", a)
a *= 5 # Multiplication Assignment
print ("a *= 5 : ", a)
a /= 5 # Division Assignment
print ("a /= 5 : ",a)
a %= 3 # Remainder Assignment
print ("a %= 3 : ", a)
a **= 2 # Exponent Assignment
print ("a **= 2 : ", a)
a //= 3 # Floor Division Assignment
print ("a //= 3 : ", a)
40.WAPP using Logical Operator AND
a=3
b =2
if (a>0 and b>0):
print ("Both the values are positive")
else:
print ("Atleast one number is negative")
41.WAP to count vowels ,consonants
str = input("Enter String : ")
v = 0;c = 0;u=0;l=0
for i in range(0,len(str)):
if(str[i].isupper()):
u=u+1
elif((str[i].islower())):
l=l+1
str=str.lower()
for i in range(0,len(str)):
if str[i] in ('a',"e","i","o","u"):
v = v + 1;
elif (str[i] >= 'a' and str[i] <= 'z'):
c = c + 1;
print("Total vowels are:-",v)
print("Total Consonants are:-",c)
print("Total Uppercase are:-",u)
print("Total lowercase are:-",l)