0% found this document useful (0 votes)
7 views17 pages

1.write A Python Program To Print All Arithmetic Operations Using Input Statements

The document contains a series of Python programming exercises covering various topics such as arithmetic operations, area and perimeter calculations for different shapes, finding the greatest of three numbers, grading based on percentage, calculating net salary, generating Fibonacci series, and demonstrating string operations. Each section includes code snippets along with expected outputs. The exercises are designed to enhance programming skills and understanding of Python functions and data structures.

Uploaded by

cog.bda2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views17 pages

1.write A Python Program To Print All Arithmetic Operations Using Input Statements

The document contains a series of Python programming exercises covering various topics such as arithmetic operations, area and perimeter calculations for different shapes, finding the greatest of three numbers, grading based on percentage, calculating net salary, generating Fibonacci series, and demonstrating string operations. Each section includes code snippets along with expected outputs. The exercises are designed to enhance programming skills and understanding of Python functions and data structures.

Uploaded by

cog.bda2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

DATE : 18-12-2024

1.Write a python program to print all arithmetic operations using input


statements
a=input('Enter first number: ')

b=input('Enter second number: ')

c=float(a)+float(b)

print("the sum is",c)

c=float(a)-float(b)

print("the difference is",c)

c=float(a)*float(b)

print("the product is",c)

c=float(a)/float(b)

print("the quotient is",c)

c=float(a)%float(b)

print("the remainder is",c)

OUTPUT:

1
DATE : 18-12-2024

2(a).Write a python program to calculate area and perimeter of rectangle


a=input("Enter length: ")

b=input("Enter breadth: ")

area=float(a)*float(b)

print("The area of rectangle is ",area)

perimeter=(2)*(float(a)+float(b))

print("the perimeter of rectangle is ",perimeter)

OUTPUT:

2
DATE : 18-12-2024

2(b).Write a python program to calculate area and perimeter of triangle


a=input('Enter base ')

b=input('Enter height ')

area=1/2*float(a)*float(b)

print("the area of traingle is :",area)

s1=input("Enter size1 :")

s2=input("Enter size2 :")

s3=input("Enter size3 :")

peri=float(s1)+float(s2)+float(s3)

print("the perimeter of traingle is: ",peri)

OUTPUT:

3
DATE : 18-12-2024

2(c).Write a python Program to calculate area of square


a=input("Enter side :")

s=int(a)*int(a)

print("the area of square is:",s)

OUTPUT:

4
DATE : 4-01-2025

3.Write a python program to check the greatest of three numbers


a=input("Enter 1st number :")

b=input("Enter 2nd number :")

c=input("Enter 3rd number :")

if a>b and a>c:

print("the largest number is: ",a)

elif b>c and b>a:

print("the largest number is: ",b)

else:

print("the largest number is: ",c)

OUTPUT:

5
DATE : 4-01-2025

4.Write a python program to print the grade of a student based on


conditions
a=int(input("Enter the percentage: "))

if a>=90:

print("Grade A")

elif a>=80:

print("Grade B")

elif a>=60:

print("Grade C")

elif a>=50:

print("Grade D")

elif a>=35:

print("Grade E")

else:

print("FAIL")

OUTPUT:

6
DATE : 4-01-2025

5) Write a python program to calculate net salary of employee based on the


following conditions:

(i)if basic salary 5000 to 2000 then ha=0,ha=0,da=0

(ii)20000 to 30000 then ta=5% of basic salary, hra=0,da=5%

(iii)30000 to 50000 then ta=10% of basic salary, hra=0,da=5%

(iv)50000 to 80000 then ta=10% of basic salary, hra=5%,da=5%

Total salary

7
DATE : 22-01-2025

6.Write a python program to find fibonacci series upto nterms


n=int(input("Enter a number for fibonacci series: "))

n1=0

n2=1

count=0

if n<count:

print("pls enter positive integer")

elif n==1:

print(n1)

else:

print("fibonacci series")

while count<n:

print(n1)

nth=n1+n2

n1=n2

n2=nth

count+=1

OUTPUT:

8
DATE : 22-01-2025

7.Write a python program to find sum and product of an array

arr=(1,2,3,4,5,6)

sum=0

product=1

for i in range(0,len(arr)):

sum=sum+arr[i]

product=product*arr[i]

print("the sum of array is: ",sum)

print("the product of array is: ",product)

OUTPUT:

9
DATE : 29-01-2025

8.Write a python program to demonstrate arithmetic operations using


functions

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

b=int(input("Enter second number: "))

def add(a,b):

c=a+b

print("the sum is:",c)

def sub(a,b):

c=a-b

print("the difference is:",c)

def mult(a,b):

c=a*b

print("the product is :",c)

def div(a,b):

c=a/b

print("the quotient is :",c)

add(a,b)

sub(a,b)

mult(a,b)

div(a,b)

OUTPUT:

10
DATE : 29-01-2025

9.Write a python program to illustrate string operations

str="python"

str1="world"

print(str)

print(str1)

print("+ operation of str and str1 is: ",str+str1)

print("* operation of str is: ",str*3)

print("[] operation of string is :",str[4])

print("[:] operation of string is :",str1[1:4])

print('IN operation of string is :','py' in str)

print('NOT IN operation of string is :','hi' not in str1)

print("the string str is :%s" %(str))

print(r'C://python21')

OUTPUT:

11

DATE : 29-01-2025
10.Write a python program to print greatest and smallest value from
array

a=[1,5,6,3]

min=a[0]

for i in range(0,len(a)):

if min>a[i]:

min=a[i]

print("minimum",min)

max=a[0]

for i in range(0,len(a)):

if max<a[i]:

max=a[i]

print("maximum",max)

OUTPUT:

12

DATE :12-02-2025
11.Write a python program to illustrate functions in four ways

a=int(input("enter first number : "))

b=int(input("enter second number : "))

def type1(a,b):

area=a*b

return area

def type2():

str="java"

str1="python"

print("str +str1=",str+str1)

def type3():

import array

n=array.array('i',[2,5,7,6,9])

return n

def type4(a):

squ=a*a

print("square =",squ)

result=type1(a,b)

print("area=",result)

type2()

result=type3()

print(result)

type4(a)

13

OUTPUT:
10
2

You might also like