0% found this document useful (0 votes)
38 views5 pages

Python Basics: Area, Interest, and Pyramids

Uploaded by

Nour Muneer
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)
38 views5 pages

Python Basics: Area, Interest, and Pyramids

Uploaded by

Nour Muneer
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

# Area of a circle

r=float(input("enter the radius"))

area=3.14*pow(r,2)

print(area)

# rounding a number

num=float(input("enter a number"))

num=round(num)

print(num)

# compound interest

principal=float(input("enter the principal"))

rate=float(input("enter the rate"))

time=float(input("enter the time in years"))

amount=principal*pow((1+rate/100),time)

print(amount)

# multiplication table

num= int(input("enter a number "))

for i in range(1,11):

print(num,"*",i,"=",num*i)

# negative or positive

num= int(input("enter a number"))

if num>0:

print("number is positive")

else:

if num<0:

print("number is negative")

else:

print("number is 0")
# even or odd

num=int(input("enter a number"))

if num == 0:

print("zero")

else:

if num % 2== 0:

print("num is even")

else:

print("num is odd")

# negative to positive

num=int(input("enter a number"))

if num<0:

num=num*-1

print(num)

else:

print(num)

#largest of 2 numbers

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

b=int(input("enter a number"))

if a>b:

print("first bigger")

else:

if a==b:

print("numbers are equal")

else:

print("second is bigger")
# largest of 3 numbers

o=int(input("enter a number"))

g=int(input("enter a number"))

t=int(input("enter a number"))

if o>g>t:

print("first bigger")

else:

if g>t>o:

print("second is bigger")

else:

print("last is bigger")

# swapping

e=int(input("enter a number"))

n2= e % 10

n1= e-n2

temp=n2

n2=n2*10

n1=n1/10

new=n2+n1

print(new)

# increasing num pyramid

r=int(input("enter the number of rows:"))

k=1

for i in range(1,r+1):

for i in range(1,i+1):

print(k, end =' ')

k=k+1

print('')

k=1
# same num pyramid

r=int(input("enter the number of rows:"))

c=1

for i in range(1,r+1):

for i in range(1,i+1):

print(c, end =' ')

print('')

# new row new num pyramid

r=int(input("enter the number of rows:"))

d=1

for i in range(1,r+1):

for i in range(1,i+1):

print(d, end =' ')

print('')

d=d+1

# new row new char pyramid

r=int(input("enter the number of rows:"))

char= 'a'

s=97

for i in range(1,r+1):

for i in range(1,i+1):

print(char, end =' ')

print('')

s=s+1

char=chr(s)
#increasing char pyramid

r=int(input("enter the number of rows:"))

chara= 'a'

g=97

for i in range(1,r+1):

for i in range(1,i+1):

chara=chr(g)

print(chara, end =' ')

g=g+1

print('')

You might also like