Page 209 - Computer Science V2.0 Class 11
P. 209
>>> pow(14, 3)
2744
>>> pow(3, 4, 5)
1
>>> pow(-2.3, 5)
-64.36342999999998
round()
The round() function takes two numeric values, namely, num and digit as arguments from the user and rounds off
the given input number num to the nearest integer or up to the specified precision (digits) after the decimal point.
For instance, the following function calls rounds the values 10.6 to nearest integer 11, 13.8907 to nearest integer
13.89 upto two decimal places, -12.0456 to -12.046 upto three decimal places, and -12.96 to -13.
>>> round(10.6)
11
>>> round(13.8907, 2)
13.89
>>> round(-12.0456, 3)
-12.046
>>> round(-12.96)
-13
The round(number, ndigits) rounds off the specified number to the number of digits specified as the
second argument ndigits. If the second argument is not specified. Number is rounded to the nearest integer.
The built-in functions are summarized in the following table:
S. No. Function Description Examples
1. print(<data object>) Outputs the value of an >>> print('Hello')
expression passed to it as an Hello
input. >>> print(2+14)
16
2. input(<display message>) Reads an input text from >>> name = input('Enter name:')
the user until a newline is Enter a name: Python
encountered and returns it as >>> print(name)
a string without evaluating its Python
value.
3. int(value), Input argument converted >>> int('234')
float(value), str(value) to integer, floating point and 234
string value respectively. >>> str(234)
'234'
>>> float('234.50')
234.5
>>> int(234.60)
234
4. eval(<string>) Evaluates the input argument >>> eval('15+10')
and returns the result of 25
evaluation.
Introduction to Functions 195

