Write a python program to input a number and print its square root, cube root, square, cube and absolute value, and also print a random number....
Answers
Answered by
6
The given problem is solved using - Python.
from numpy import cbrt
from random import random
n=int(input('Enter a number: '))
print('Square root of the number:',n**(1/2))
print('Cube root of the number:',cbrt(n))
print('Square of the number:',n**2)
print('Cube of the number:',n**3)
print('Absolute value of the number:',abs(n))
print('A random number: ',random())
- To print the square root of a number, we can simply raise the number to the power ½.
- To print the cube root of a number, we can use cbrt() function present in numPy module.
- To print square and cube of a number, we can raise the number to the power - 2 and 3.
- abs() function is used to calculate the absolute value of a number.
- We can generate random number using random module. The function random() generates a random number between 0 and 1.
See attachment for output. The output for random value may be different.
Attachments:
Similar questions
Math,
25 days ago
Business Studies,
25 days ago
Math,
1 month ago
Hindi,
1 month ago
Hindi,
9 months ago
Social Sciences,
9 months ago
Math,
9 months ago