0% found this document useful (0 votes)
2 views

Div Python

The document contains acknowledgments expressing gratitude to mentors, teachers, and family for their support in completing a project. It includes an index of various programming tasks and their corresponding code implementations, such as calculating average marks, creating a calculator, checking for even or odd numbers, and more. Each program is designed to demonstrate different programming concepts and techniques.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Div Python

The document contains acknowledgments expressing gratitude to mentors, teachers, and family for their support in completing a project. It includes an index of various programming tasks and their corresponding code implementations, such as calculating average marks, creating a calculator, checking for even or odd numbers, and more. Each program is designed to demonstrate different programming concepts and techniques.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Acknowledgment

I would like to express my sincere gratitude to


all these individuals for mentoring and
supporting me in completing this project
My teacher Dr. Janmejay Pant, for providing
me with invaluable insights and direction.
Our esteemed Hod Dr Sandeep Bhudhani, for
fostering an environment of learning and
creativity within our University.
To my parents, their constant encouragement,
patience, and understanding have been the
pillars of my success.
I am grateful to my friends who contributed
ideas and perspectives that enriched the
project.
Thank you everyone for shaping this project
and enhancing my learning experience.
INDEX

1. Program to calculate avg marks and give


grade.
2. Program to make calculator using
repetition.
3. Program to check whether even or odd
only if number less then 100.
4. Program to check whether string is
upper, lower, digit or special case.
5. Program to multiply without using *
operator.
6. Program to check whether last digit is
divisible by 5 or not.
7. Program to print list and twice of each
element of list.
8. Program to print table of 5 and if
value>10 then break the program.
9. Program to print prime number within
a range.
10. Program to print fibonacci series.
11. Program to find smallest and largest
number of list.
12. Program to check whether
palindrome or not.
13. Program to find second highest
number in a list.
14. Program to reverse a list.
15. Program to convert tuple into list and
vica versa.
16. Program to concatinate two list.
17. Program to search element in list.
18. Program to check leap year or not.
19. Program to find factorial of number.
20. Program to check even or not within
a range.
1. Program to find avg marks and
give grade accordingly
a=int(input("Enter first subject marks:"))
b=int(input("Enter second subject marks:"))
c=int(input("Enter third subject marks:"))
d=int(input("Enter fourth subject marks:"))
e=int(input("Enter fivth subject marks:"))
avg=(a+b+c+d+e)/5
if avg>=91 and avg<=100:
print("Grade A")
elif avg<=90 and avg>=81:
print("Grade B")
elif avg<=80 and avg>=71:
print("Grade C")
elif avg<=70 and avg>=61:
print("Grade D")
elif avg<=60 and avg>=51:
print("Grade E")
elif avg<=50 and avg>=0:
print("Grade F")
else:
print("Not applicable")
2.Program to make basic calculator and
menu should continuously available

def add(num1,num2):
return num1+num2
def sub(num1,num2):
if num2>num1:
return num2-num1
else:
return num1-num2
def multi(num1,num2):
return num1*num2
def div(num1,num2):
if num2>num1:
return num2/num1
else:
return num1/num2
def mod(num1,num2):
if num2>num1:
return num2%num1
else:
return num1%num2
while True:
num1=int(input("Enter fist number="))
num2=int(input("Enter second number="))
print("Press 1 for addition\nPress 2 for subtraction\nPress
3 for multiplication\nPress 4 for division\nPress 5 for
reminder")
num=int(input("Enter a number to do task\n"))
if num==1:
print("Addition of",num1,"and",num2,"is",add(num1,num2))
elif num==2:
print("Subtraction of",num1,"and",num2,"is",sub(num1,num2))
elif num==3:
print("Multiplication of",num1,"and",num2,"is",multi(num1,num2))
elif num==4:
print("Division of",num1,"and",num2,"is",div(num1,num2))
elif num==5:
print("Reminder=",mod(num1,num2))
else:
print("Only press 1 to 5")
print("Do you want to continue?\nPress 1 to continue\nPress any key to break")
ch=int(input("Enter your choice:-"))
if ch==1:
continue
else:
break
3. Program to check whether even
or odd if less then 100
num=int(input("Enter a number to check whether
a number is even or odd\nThe number should
be less then 100\nEnter a number="))
if num<=100:
if num%2==0:
print("The given number",num,"is even")
else:
print("The given number",num,"is odd")
else:
print("The given number is out of range\nPlease
enter number between 1 to 100 only")
4. Program to check whether upper,
lower, digit or special character
print("Press any key to check whether it is
lowercase,uppercase,digit or special character")
ch=input("Enter the character:")
if ch.islower():
print("The given character",ch,"is a lowercase")
elif ch.isupper():
print("The given character",ch,"is a uppercase")
elif ch.isdigit():
print("The given character",ch,"is a digit")
else:
print("The given character",ch,"is a special character")
5. WAP to multiply without using * operator

n1=int(input("Enter first number:"))


n2=int(input("Enter second number:"))
product=0
count=n1
while count>0:
count=count-1
product=product+n2
print("The product
of",n1,"and",n2,"is",product)
6. Program to check whether last
digit divisible by 5 or not
num=int(input("Enter a number="))
last_digit=num%10
if last_digit%5==0:
print("The last digit of",num,"which
is",last_digit,"is divisible by 5")
else:
print("The last digit of",num,"which
is",last_digit,"is not divisible by 5")
7. Program to create list and print
twice of each element

lst1=[]
lst2=[]
elements=int(input("Enter number of elements you want in
list="))
for i in range(elements):
num=int(input("Enter element of list="))
lst1.append(num)
print("Original list is given below:\n",lst1)
for j in lst1:
lst2.append(j*2)
print("The list which contain twice of each element in list is:\
n",lst2)
8. Program to print table of 5 and if
value>10 then break the program
num=int(input("Enter element to
print table="))
for i in range(1,11):
if i*num>10:
break
print(num,"X",i,"=",num*i)
9. Program to find prime number
within a range
lowernum=int(input("Enter number to start:-"))
uppernum=int(input("Enter number to stop:-"))
print("Prime numbers
between",lowernum,"and",uppernum,"are:")
for num in range(lowernum,uppernum+1):
#all prime numbers are greater then 1
if num>1:
for i in range(2,num):
if num%i==0:
break
else:
print(num)
10. Program to print fibbonacci
series
nterms=int(input("How many terms?\n"))
#First two numbers
n1,n2=0,1
count=0
#check if the number of term is valid
if nterms<=0:
print("Please enter positive integer")
#If there is only one term,return n1
elif nterms==1:
print("Fibonacci sequence upto",nterms,":",n1)
#Generate fibonacci sequence
else:
print("Fibonacci sequence:")
while count < nterms:
print(n1)
nth=n1+n2
#Update values
n1=n2
n2=nth
count+=1
11. Program to find smallest and largest
number in list
lst=[]
elements=int(input("Enter element of list="))
for i in range(elements):
element=input("Enter list value=")
lst.append(element)
print("Largest value of list is:",max(lst))
print("Smallest value of list is:",min(lst))
12.Program to check whether
palindrome or not
st=input("Enter a string:\n")
i,j=0,len(st)-1
is_palindrome=True #assume palindrome
while i<j:
if st[i]!=st[j]: #mismatch
is_palindrome=False
break
i+=1
j-=1
if is_palindrome:
print("Yes")
else:
print("No")
13. Program to find second highest number
in list

lst=[]
need=int(input("Enter the element you want in
list:-"))
for i in range(need):
elements=int(input("Enter the element of
list="))
lst.append(elements)
lst.sort()
print("Second largest number is:",lst[need-2])
14. Program to reverse a list

lst=[]
need=int(input("Enter the element you want in
list:-"))
for i in range(need):
elements=int(input("Enter the element of list="))
lst.append(elements)
print("Original list:\n",lst)
lst.reverse()
print("Reverse list:\n",lst)
15. Program to convert tuple into list
and vica versa
lst=[] #Empty list
tup=eval(input("Enter tuple:"))
need=int(input("Enter the element you want in
list:-")) #Value needed in list
for i in range(need):
elements=int(input("Enter the element of
list="))
lst.append(elements) #Append element in list
print("Original list:\n",lst)
print("Original tuple:\n",tup)
lst2=tuple(lst)
tup2=list(tup)
print("After covertion list in tuple and tuple in
list they are:")
print("List converted into tuple:",lst2)
print("Tuple converted into list:",tup2)
16. Program to concatinate 2 tuple

tup1=eval(input("Enter first tuple:"))


tup2=eval(input("Enter second tuple:"))
print("The original tuples are:")
print(tup1)
print(tup2)
res=tup1+tup2
print("The tuple after concatenation is:",res)
17. Program to count occurence of
element in tuple

tup=eval(input("Enter the tuple:-"))


search=int(input("Enter the element to
search="))
count=tup.count(search)
print("The occurance
of",search,"in",tup,"is:",count)
18. Program to check whether
leap year or not
year=int(input("Enter a
year="))
if year%4==0:
print(year,"is a leap
year")
else:
print(year,"is not a
19. Program to find factorial of a
number

num1=int(input("Enter a
number to find factorial="))
fact=1
if num1<0:
print("Sorry! Factorial does
not exist for negative
number")
elif num1==0:
print("Factorial of 0 is 1")
else:
for i in range(1,num1+1):
fact=fact*i
print("The factorial
of",num1,"is",fact)
20.Program to print even number
between 2 to n

num1=int(input("Enter a number to start="))


num2=int(input("Enter a number to stop="))
num3=num2+1
for i in range(num1,num3):
if i%2==0:
print(i,"is a even number")
else:
print(i,"is not a even number")

You might also like