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

Python Lab Programs

Python

Uploaded by

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

Python Lab Programs

Python

Uploaded by

proop2324
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 2
IPUC PYTHON LAB PROGRAMS ~SET-1 #1) Write a program to swap two numbers using a third variable. humdeint{input("Enter First Number") ‘num2=int(input("Enter second Number")) print("Values of variables before swapping print("Value of numa", num) print("Value of num2:*, num2) 48 Swapping of two variables 4 Using third variable temp = numi um = num2 print("Value of numt:", numt) print("Value of num2:*, aum2) ourut Enter First Number100 Enter second Number200 Values of variables before swapping Value of num1: 100 Value of num2: 200 Values of variables after swapping Value of num1: 200 Value of num2: 100 ##Program to input two numbers and performing all arithmetic operations ‘num = int(input("Enter fist number: ") ‘num2 = int(input("Enter second number: ") print("Printing the result for all arithmetic operations: print("Addition:*;numd+num2) print(‘Subtraction:" numt-num2) print("Multiplication:*,numt*num2) print(*Divsion:* numt/num2) print("Modulus: ,numi%¥num2) output Enter first number: 10 Enter second number: 20 Printing the result for all arithmetic operations:- Addition: 30 Subtraction: -10 Multiplication: 200 Division: 0.5 ‘Modulus: 10 Department of Computer Scien 'YTHON Lab Programs IPUC PYTHON LAB PROGRAMS ~SET-2 #3 Python program to accept length and width of a rectangle and compute its perimeter and are Rei ling length from user length = float(input("Enter length of the rectangle: ") 4 Reading breadth from user breadth = float(input("Enter breadth of the rectangle: ")) f Calculating area area = length * breadth # Calculating perimeter perimeter = 2 * (lengtht breadth) 4 Displaying results print("Area of rectangle =", area) print("Perimeter of rectangle Enter length of the rectangle: 5 OUTPUT AREA, PE tne beet of herent hen ofectange= 200. yo Permnerotrecanges all 4# Ad) Write a Python program to calculate the amount payable if money has been lent on simple interest. Principal or money lent = P, Rate of interest = R% per annum and Time = T years. # Reading principal amount, rate and time START = floatlinput("Enter amount: )) t= float(input(Entr time) # Calculation siz (ptt*r)/100 Vv 4 Displaying result print'simple interest is:'si) ei (P xten) | Enter rate:3 ovTPUT i Simple interest is: 60.0 2 PYTHON-SET-2 Mohan C HOD,COMPSCI. DEPT. Page 1

You might also like