Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
19 views

Python Prog

The document contains a series of Python programming exercises for a lab exam in 2024, including tasks such as swapping two numbers, performing arithmetic operations, calculating the perimeter and area of a rectangle, computing simple interest, finding the largest of three numbers, checking eligibility for a driving license, printing patterns, and generating multiplication tables. Each task is accompanied by example code snippets and sample input/output. The exercises are designed to test fundamental programming skills in Python.

Uploaded by

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

Python Prog

The document contains a series of Python programming exercises for a lab exam in 2024, including tasks such as swapping two numbers, performing arithmetic operations, calculating the perimeter and area of a rectangle, computing simple interest, finding the largest of three numbers, checking eligibility for a driving license, printing patterns, and generating multiplication tables. Each task is accompanied by example code snippets and sample input/output. The exercises are designed to test fundamental programming skills in Python.

Uploaded by

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

I PUC PYTHON PROGRAMS FOR LAB EXAM 2024

1. Write a program to swap two numbers using third variable.


a=int(input(“Enter the value of a “))
b=int(input(“Enter the value of b”))
Enter the value of a 40
print(“The values before swapping”)
Enter the value of b 90
print(“a=”,b,”b=”,b)
The values before swapping a= 90 b= 90
temp=a The values after swapping a= 40 b= 40
a=b
b=temp
print(“The values after swapping”)
print(“a=”,b,”b=”,b)

2. Write a program to enter two integers and perform all arithmetic operations.
a=int(input(“Enter first number”))
b=int(input(“Enter second number”)) Enter first number3
print(“The addition of two numbers=”,a+b) Enter second number5
print(“The difference of two numbers=”,a-b) The addition of two numbers= 8
print(“The product of two numbers=”,a*b) The difference of two numbers= -2
print(“The quotient of two numbers=”,a/b) The product of two numbers= 15
print(“The reminder of two numbers=”,a%b) The quotient of two numbers= 0.6
print(“The floor division of two numbers=”,a//b) The reminder of two numbers= 3
The floor division of two numbers= 0

3. Write a program to accept the length and breadth of rectangle and calculate its
perimeter and area.
Enter the length of recatangle10
l= float(input(“Enter the length of recatangle”)) Enter the breadth of recatangle20
b= float(input(“Enter the breadth of recatangle”)) Perimeter of rectangle= 60.0
perimeter=2*(l+b) Area of rectangle= 200.0
area=l*b
print(“Perimeter of rectangle=”,perimeter)
print(“Area of rectangle=”,area)

4. Write a program to calculate simple interest.


p=float(input(“Enter the principal amount”))
t=float(input(“Enter the time duration in years”)) Enter the principal amount 200000
r=float(input(“Enter the rate of interest per annum”)) Enter the time duration in years2
si=(p*t*r)/100 Enter the rate of interest per annum7
ap=p+si simple interest= 28000.0 amount
print(“simple interest=”,si) payable= 228000.0
print(“amount payable=”,ap)
5. Write a program to find largest among three numbers.

num1=int(input(“Enter first number”)) Enter first number7


num2=int(input(“Enter second number”)) Enter second number3
num3=int(input(“Enter third number”)) Enter third number4
large=num1 The largest among three numbers is= 7
if num2>large:
large=num2
if num3>large:
large=num3
print(“The largest among three numbers is=”,large)

6. Write a program that takes name and age f use and displays a message weather the
user is eligible to apply for driving license or not.
name=input(“Enter your name”) Enter your name: Deeksha
age=int(input(“Enter your age”) Enter your age17
if age>=18: Deeksha sorry you are not eligible
print(name,”is eligible to spply driving license”)
else:
print(name,”sorry you are not eligible”)

12345
7. Write a program to print the pattern.
1234
row=5
123
for i in range(row,0,-1):
12
for j in range(1,i+1):
print(j,end=” “) 1
print()

8. Write a program to print multiplication table(COMMON PROGRAM TO WRITE)

def mul_table(number):
print("Multiplication Table for", number)
for i in range(1, 11):
result = number * i
print(number, "x", i, "=", result)
number = int(input("Enter the number: "))
mul_table(number)

You might also like