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

Python Codes

The document contains code snippets for calculating the area and perimeter of a square, finding the square root of a number, swapping two variables, adding two numbers, calculating the surface volume and area of a cylinder, and calculating the area of a rectangle.

Uploaded by

cohoti1106
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Python Codes

The document contains code snippets for calculating the area and perimeter of a square, finding the square root of a number, swapping two variables, adding two numbers, calculating the surface volume and area of a cylinder, and calculating the area of a rectangle.

Uploaded by

cohoti1106
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

calculate area & perimeter of square Find square root of no Swap 2 varables

side=int(input("enter no:")) a=int(input("enter no:")) x=int(input("enter x:"))


area=side*side z=a**0.5 y=int(input("enter y:"))
perimeter=4*side print(z) print("before swaping x
print("area of square:",area) is",x,"y is",y)
print("perimeter of square:",perimeter) x,y=y,x
print("after swaping x
is",x,"y is",y)
surface volume and area of cylinder Add 2 no Area of rectangle
pi=22/7 a=input("enter no:") l=int(input("enter
height=float(input("enter height:")) b=input("enter no:") length:"))
radius=float(input("enter radius:")) b=int(input("enter
volume=pi*radius*radius*height sum=int(a)+ int(b) breadth:"))
area=((2*pi*radius)*height)+((pi*radius**2)*2) area=l*b
print("volume is:",volume) print("{0} and {1} is print("area=",area)
print("area is:",area) {2}".format (a,b,sum))

Swap 2 varables
num1=input("enter num1:")
num2=input("enter num2:")
print("numbers before swapping")
print("num1:",num1)
print("num2:",num2)
temp=num1
num1=num2
num2=temp
print("numbers after swapping")
print("num1:",num1)
print("num2:",num2)

You might also like