Search This Blog

Sunil had an assignment on "Areas & Volumes" given by his Mathematics Teacher - Hands - On - Using int - Math Operations Hackerank Questions and answers Course ID:55193

 1. Using intMath Operations

Area & Volume

Sunil had an assignment on "Areas & Volumes" given by his Mathematics Teacher. He was given 1.'Side', from which he have to find 

- Area of  Square &

- Volume of Cube

2.'Radius', From which he have to find 

-Area of Circle & 

-Volume of Sphere

3."pi" equals to 3.14

Write the function definition for the function "Integer_Math" which takes two arguments 'Side' and 'Radius'

Print the Areas and Volumes as per the Sample Test Case below.

Input Format for Custom Testing:

#In the first line, value for 'Side'

#In the second line, value for 'Radius'

Note:

-The outputs must be rounded off to two decimal places 

-Use round() for rounding off

   -Example: round(123.45555,2) is 123.46

Sample Test Case 1:

Sample Input

STDIN      Function parameter
-----      ------------------
5      →   Side
7      →   Radius
Sample Output
Area of Square is 25
Volume of Cube is 125
Area of Circle is 153.86
Volume of Sphere is 1436.03
Answer:
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'Integer_Math' function below.
#
# The function accepts following parameters:
#  1. INTEGER Side
#  2. INTEGER Radius
#
def Integer_Math(Side, Radius):
    # Write your code here
    AreaOfSquare = round((Side**2),2)
    VolumeOfCube = round((Side**3),2)
    AreaOfCircle = round((3.14*Radius**2),2)
    VolumeOfSphere = round(((4/3)*3.14*Radius**3),2)
    print('Area of Square is', AreaOfSquare)
    print('Volume of Cube is', VolumeOfCube)
    print('Area of Circle is', AreaOfCircle)
    print('Volume of Sphere is',VolumeOfSphere)
if __name__ == '__main__':
    Side = int(input().strip())
    Radius = int(input().strip())
    Integer_Math(Side, Radius)



Click on the image: 👇




No comments:

Post a Comment

If you have any doubts, Please let us know.