0% found this document useful (0 votes)
21 views1 page

Builtins Worksheet

This document provides information about built-in functions in Python like min(), max(), abs(), pow(), and round(). It includes examples of using these functions and the types of values they return. It also shows how to use the help() function to get documentation on other functions. The round() function is explored in more detail, showing its argument types and return types. Examples of rounding numbers to different decimal places are demonstrated in a table.

Uploaded by

H pm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views1 page

Builtins Worksheet

This document provides information about built-in functions in Python like min(), max(), abs(), pow(), and round(). It includes examples of using these functions and the types of values they return. It also shows how to use the help() function to get documentation on other functions. The round() function is explored in more detail, showing its argument types and return types. Examples of rounding numbers to different decimal places are demonstrated in a table.

Uploaded by

H pm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CSC108H Fall 2023 Worksheet: Built-in Functions

1. Built-in Functions

Without running the code, complete the table below by filling in the values that the expressions produce, as well
as the types of those values.

Python Expression Result Type of Result

min(4, 6, 2.5) 2.5 float

max(10.1, 13, 16)


16 int

abs(-5.2)
5.2 float

pow(2, 3)
power of 8 int

2. Built-in Function: help

The built-in function help can be used to provide information about other functions. Answer the following ques-
tions, using the output of help(round) below:

Help on built-in function round in module builtins:

round(number, ndigits=None)
Round a number to a given precision in decimal digits.

The return value is an integer if ndigits is omitted or None. Otherwise


the return value has the same type as the number. ndigits may be negative.

Question Answer

What are the types function round can return?


int and float

What is the minimum number of arguments function round can take? round(x)
1

What is the maximum number of arguments function round can take? round(x,y)
2

3. Built-in Function: Using round


Complete the table below with the results of the following calls to round:
Python Expression Result Python Expression Result
2
round(1.6) round(3.14159, 2)
3.14

round(1234.5678, -2) round(2.5)


1200.0 2
round 2 numbers before decimal
.5 , round to nearest even number
gave a float, return a float
round (3.5) = 4

You might also like