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

By Rishi Jain: 1) 1 Digit To 3 Digit

The document contains Python code snippets for solving various math and programming problems. There are 23 sections that include code to calculate areas and perimeters of shapes, convert between units like Celsius to Fahrenheit, perform arithmetic operations, use assignment operators, find simple interest, check if a number is an anagram, and more. The code demonstrates how to take user input, perform calculations, and print outputs.

Uploaded by

Rishi Jain
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)
34 views

By Rishi Jain: 1) 1 Digit To 3 Digit

The document contains Python code snippets for solving various math and programming problems. There are 23 sections that include code to calculate areas and perimeters of shapes, convert between units like Celsius to Fahrenheit, perform arithmetic operations, use assignment operators, find simple interest, check if a number is an anagram, and more. The code demonstrates how to take user input, perform calculations, and print outputs.

Uploaded by

Rishi Jain
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
You are on page 1/ 19

-BY RISHI JAIN

1) 1 Digit to 3 digit
a=int(input('Enter the 1-digit no.'))

b=((a)*100)+((a+1)*10)+(a+2)

print(b)

2) Area and Perimeter of all Object


Circle
import math

print('area and perimeter of circle')

r=int(input('Enter the radius'))

A=math.pi*(r**2)

P=2*math.pi*r
print(A)

print(P)

Rectangle
print('area and perimeter of rectangle')

l=int(input('Enter the length'))

b=int(input('Enter the length'))

A=l*b

P=2*(l+b)

print(A)

print(P)
Square
print('area and perimeter of square:')

a=int(input('Enter the length'))

A=a**2

P=4*a

print(A)

print(P)

Right Angle Triangle


print('area of right angle triangle:')

b=int(input('Enter the base'))

h=int(input('Enter the hieght'))

e=(b**2+h**2)**0.5

P=b+h+e

D=1/2*b*h

print(D)
prin
t(P)

3) Area of Triangle
a=int(input('Enter the 1st side'))

b=int(input('Enter the 2nd side'))

c=int(input('Enter the 3rd side'))

s=(a+b+c)/2

a=(s*(s-a)*(s-b)*(s-c))**0.5

print(a)
4) Arithmatic Operator
a=int(input('Enter the 1st value'))

b=int(input('Enter the 2nd value'))

print('sum',a+b)

print('subract',a-b)

print('division',a/b)

print('multiplication',a*b)

print('modulus',a%b)

print('exponent',a**b)

print('floor division',a//b)

5) Assignment Operator
c=int(input('Enter the value'))

c+=5
print(c)

c-=5

print(c)

c*=1

print(c)

c//=2

print(c)

c**=2

print(c)

c%=10

print(c)

c/=4

print(c)

6) Celsius to fehrenheit
c=float(input('Enter the temperature'))

f=(c+32)*9/5
print(f,'f')

k=273+c

print(k,'K')

7) Centimeters to Meter and Foot


a=int(input('Enter the hieght in cm no.'))

inch=2.54*a

feet=12*(2.54*a)

print(inch,"inch")

print(feet,"feet")

8) Cube and Squares of a Number


a=int(input('Enter the value'))
print('exponent',a**2)

print('exponent',a**3)

9) Days to Year
d=int(input('enter the number of days'))

Y=d//365

W=(d%365)//7

D=(d%365)%7

print(Y,'year',W,'week',D,'days')

10) Feet to Meter


feet=F=int(input('Enter the value'))

meter=M=F//3.280
print(M)

11) 4 Digit Number


a=int(input('Enter the 4 digit no.'))

b=a//100

c=a%100

s=b**2+c**2

print(s)

12) Marks Table


Name=input('enter the name')
standard=input('enter the class')

physics=int(input('enter the marks obtained in physics fron 100'))

chemistry=int(input('enter the marks obtained in chemistry fron 100'))

maths=int(input('enter the marks obtained in maths fron 100'))

M=physics+maths+chemistry

P=(M/300)*100

print(M)

print(P)

13) Multiple Assignment and Swapping


x,y=5,6

x,y=y+5,x+3

print(x,y)

a=int(input('Enter the 1st value'))

b=int(input('Enter the 2nd value'))

a,b=b,a

print(a,b)
14) Reverse of Two Digit Number
a=int(input('Enter the two digit number'))

b=a//10

c=a-(b*10)

d=(c*10)+b

print(d)

15) Seconds to Minutes


S=int(input('enter the time'))

M=S//60

s=S%60

print(M,'Minutes',s,'Seconds')
16) Simple Interest
p=int(input('Enter the principle'))

r=int(input('Enter the rate of interest'))

t=int(input('Enter the time'))

ST=p*r*t/100

print(ST)

17) Solving Equation


import math

x=int(input('enter the value of x'))

y=int(input('enter the value of y'))

z=int(input('enter the value of z'))


a=(4*x**4)+(3*y**3)+(9*z)+(6*math.pi)

print(a)

18) Swap Variable with Sum


a=int(input('Enter the 1-digit no.'))

b=int(input('Enter the 1-digit no.'))

c=int(input('Enter the 1-digit no.'))

a,b=a+b,b+c

print(a,"\n",b)

19) Type ID
a=int(input('Enter the value'))

print( type(a))
print( id(a))

a=int(input('Enter the value'))

print( type(a))

print( id(a))

b=int(input('Enter the value'))

print( type(b))

print( id(b))

20) Math function


import math

a=eval(input('enter the value'))

print(math.sqrt(a))

b=eval(input('enter the value'))

print(math.ceil(b))

print(math.exp(a))

print(math.fabs(b))
print(math.floor(b))

N=eval(input('enter the num'))

B=eval(input('enter the base'))

print(math.log(N,B))

s=eval(input('enter the value'))

print(math.log10(s))

b=eval(input('enter the base'))

e=eval(input('enter the power'))

print(math.pow(b,e))

A=eval(input('enter the angle'))

print(math.sin(A))

print(math.cos(A))

print(math.tan(A))

j=eval(input('enter the value'))

print(math.degrees(j))

x=eval(input('enter the value'))

print(math.radians(x))
21) Anagram
a=input("enter string1=")

b=input("enter string2=")

check=True

for i in a:

if i not in b:

check=False

if(check==True):

for i in b:

if i not in a:

check=False
if(check==True):

print("anagram")

else:

print("not anagram")

22) Confirming Sides Of Triangle


a=int(input('enter the value: '))

b=int(input('enter the value: '))

c=int(input('enter the value: '))

if((a+b>c) and (b+c>a) and (c+a>b)):

print('it is a triangle')

else:

print('it is not a triangle')


23) Choice For Normal Series And Alternative Negative Series
ex="y"

while(ex=='y' or ex=='Y'):

print('a=4,7,10.......40')

print('b=-4,7,-10.......-40')

ch=input('enter your choice: ')

if(ch=='a'):

for i in range(1,41,3):

print(i,end=' ')

elif(ch=='b'):

for i in range(1,41,3):

if(i%2==0):

print(-1*i,end=" ")

else:

print(i,end=" ")
else:

print('your choice does not exist')

ex=input("Do you want to continue?(y,n)")

You might also like