0% found this document useful (0 votes)
2 views6 pages

Holiday Homework

The document contains a series of Python code snippets that perform basic arithmetic operations, calculate areas and perimeters of geometric shapes, convert temperatures, and determine properties of numbers (even/odd, positive/negative, largest/smallest). Each code snippet prompts the user for input and outputs the result of the computation. The examples illustrate fundamental programming concepts and operations in Python.

Uploaded by

kaushikarjun128
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)
2 views6 pages

Holiday Homework

The document contains a series of Python code snippets that perform basic arithmetic operations, calculate areas and perimeters of geometric shapes, convert temperatures, and determine properties of numbers (even/odd, positive/negative, largest/smallest). Each code snippet prompts the user for input and outputs the result of the computation. The examples illustrate fundamental programming concepts and operations in Python.

Uploaded by

kaushikarjun128
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

CODE

1.
numb1=(int(input("enter a number")))
numb2=(int(input("enter a number")))
sum=numb1+numb2
print("The sum is:", sum)

2.
numb1=(int(input("enter a number")))
numb2=(int(input("enter a number")))
diff=numb1-numb2
print("The difference is:", diff)

3.
numb1=(int(input("enter a number")))
numb2=(int(input("enter a number")))
product=numb1*numb2
print("The product is:", product)

4.
numb1=(int(input("enter a number")))
numb2=(int(input("enter a number")))
quotient=numb1/numb2
print("The quotient is:", quotient)

5.
numb1=(int(input("enter a number")))
numb2=(int(input("enter a number")))
remainder=numb1%numb2
print("The remainder is:", remainder)

6.
numb1=(int(input("enter a number")))
square=numb1**2
print("The square of a number is:", square)
7.
numb1=(int(input("enter a number")))
cube=numb1**3
print("The cube of a number is:", cube)

8.
principal=(int(input("enter the principal amount")))
rate=(int(input("enter the rate of interest")))
time=(int(input("enter the time in years")))
Si=(principal*rate*time)/100
print("The simple interest is:", Si)

9.
principal=(int(input("enter the principal amount")))
rate=(int(input("enter the rate of interest")))
time=(int(input("enter the time in years")))
Ci=principal*(1 + rate/100)**time - principal
print("The compound interest is:", Ci)

10.
length=(int(input("enter the length of the rectangle")))
width=(int(input("enter the width of the rectangle")))
area=length*width
print("The area of the rectangle is:", area)

11.
length=(int(input("enter the length of the rectangle")))
width=(int(input("enter the width of the rectangle")))
perimeter=2*(length+width)
print("The perimeter of the rectangle is:", perimeter)

12.
radius=(int(input("enter the radius of the circle")))
pi=3.14
area=pi*radius**2
print("The area of the circle is:", area)
14.
radius=(int(input("enter the radius of the circle")))
pi=3.14
circumference=2*pi*radius
print("The circumference of the circle is:", circumference)

15.
temperature=(int(input("enter the temperature in Celsius")))
Fahrenheit=(temperature*9/5)+32
print("The temperature in Fahrenheit is:", Fahrenheit)

16.
temperature=(int(input("enter the temperature in Fahrenheit")))
Celsius=(temperature-32)*5/9
print("The temperature in Celsius is:", Celsius)

17.
number=(int(input("enter a number")))
if number%2==0:
print("The number is even.")
else:
print("The number is odd.")

18.
number=(int(input("enter a number")))
if number>0:
print("The number is positive.")
elif number<0:
print("The number is negative.")
else:
print("The number is zero.")

19.
numb1=(int(input("enter a number")))
numb2=(int(input("enter a number")))
if numb1>numb2:
print("The largest number is:", numb1)
else:
print("The largest number is:", numb2)

20.
numb1=(int(input("enter a number")))
numb2=(int(input("enter a number")))
if numb1<numb2:
print("The smallest number is:", numb1)
else:
print("The smallest number is:", numb2)

OUTPUT

1.
enter a number 34
enter a number 34
The sum is: 68

2.
enter a number 343
enter a number 343
The difference is: 0

3.
enter a number 34
enter a number 343
The product is: 11662

4.
enter a number 343
enter a number 53
The quotient is: 6.471698113207547

5.
enter a number 343
enter a number 43
The remainder is: 42

6.
enter a number 343
The square of a number is: 117649

7.
enter a number 343
The cube of a number is: 40353607

8.
enter a number 343
enter a number 4
Before swapping, the first number is: 343
Before swapping, the second number is: 4
After swapping, the first number is: 4
After swapping, the second number is: 4

9.
enter the principal amount 3433
enter the rate of interest 2
enter the time in years 3
The simple interest is: 205.98

10.
enter the principal amount 43433
enter the rate of interest 3
enter the time in years 3
The compound interest is: 4027.4117909999986

11.
enter the length of the rectangle 23
enter the width of the rectangle 4
The area of the rectangle is: 92

12.
enter the length of the rectangle 5
enter the width of the rectangle 5
The perimeter of the rectangle is: 20

13.
enter the radius of the circle 5
The area of the circle is: 78.5

14.
enter the radius of the circle 5
The circumference of the circle is: 31.400000000000002

15.
enter the temperature in Celsius 37
The temperature in Fahrenheit is: 98.6

16.
Enter the temperature in fahrenheit 67
The temperature in celsius is 19.5

17.
enter a number 21
The number is odd.

18.
enter a number 12
The number is positive.

19.
enter a number 1
enter a number 4
The largest number is: 4

20.
enter a number 54
enter a number 34
The smallest number is: 34

You might also like