Python3

Basic Program

Program to find the area and perimeter of rectangle

length=int(input("Type a length of a rectangle"))

width=int(input("Type a width of a rectangle"))

area=(length*width)

perimeter=(length+length+width+width)

print("The area of the Rectangle is",area)

print("The perimeter of the Rectangle is",perimeter)

Type a length of a rectangle 20

Type a width of a rectangle 30

The area of the Rectangle is 600

The perimeter of the Rectangle is 100

Program to find the volume of cube

side=int(input("Type a side of a cube to find its volume"))

volume=(side*side*side)

print("The volume of the cube is",volume)

Type a side of a cube to find its volume 5

The volume of the cube is 125

Program to find the area and perimeter of circle

r=int(input("enter radius of a circle"))

p=3.14

a=(p*r**2)

print("area=", a)

pe=(2*p*r)

print("perimeter=", pe)

enter radius of a circle6

area= 113.04

perimeter= 37.68

program to display the ascii value and character between two range

print("Enter beginning and ending range to get ascii value")

n1=int(input(" Enter beginning range"))

n2=int(input(" Enter ending range"))

for i in range(n1,n2):

print("%d=%c"%(i,chr(i)))

Enter beginning and ending range to get ascii value

Enter begining range65

Enter ending range71

65=A

66=B

67=C

68=D

69=E

70=F

program to check whether an alphabet is character or not

hello=input("Type anything to check if it is an alphabet or not ")

if hello in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV":

print("yes it is and alphabet")

elif(str(hello)):

print("no it is not an alphabet")

else:

print("no it is not an alphabet")

Type anything to check if it is an alphabet or not #

no it is not an alphabet

program to check entered character is in lowercase or uppercase

a=input("enter any letter")

print (ord(a))

b=(ord(a))

if(b >64 and b <91):

print("your character is in uppercase")

elif(b >96 and b <123):

print(" Your character is in lowercase")

else:

print("you haven't typed a letter")

enter any letter A

65

your character is in uppercase

program to test BITWISE Operator

a=int(input("Type a number"))

b=int(input("Type another number"))

c=(a&b)

print(c)


d=a|b

print(d)


e=(a<<b)

print(e)


f=(a>>b)

print(f)


g=(a^b)

print(g)


h=(~a)

print(h)

Type a number45

Type another number65

1

109

1660206966633859645440

0

108

-46