Built in functions Python Tutorial



In this video, we cover a handful of the built-in functions with Python 3. For a full list, see: https://docs.python.org/3/library/functions.html

We cover absolute value (abs()), the help() functions, max(), min() ...which are how to find maximum and minimum of a list, how to round a number with round(), as well as ceil() and floor(), even though these last two are NOT built in, it just seemed like a good time to bring them up. Finally, we cover converting floats, ints, and strings to and from each other.

There are still quite a few other built in functions to Python 3, but the others are not really meant for a basics tutorial.

Sample code for the built in functions that are covered in the video:

Absolute Values:

exNum1 = -5
exNum2 = 5
print(abs(exNum1))
if abs(exNum1) == exNum2:
    print('True!')

The Help function:

This is probably one of the most under-utilized commands in Python, many people do not even know that it exists. With help(), you can type it with empty parameters to engage in a search, or you can put a specific function in question in the parameter.

help()
Or...
import time
# will work in a typical installation of Python, but not in the embedded editor
help(time)
Max and Min:

How to find the maximum or highest number in a list...

or how to find the lowest or minimum number in a list.

exList = [5,2,1,6,7]

largest = max(exList)
print(largest)

smallest = min(exList)
print(smallest)

Rounding:

Rounding will round to the nearest whole. There are also ways to round up or round down.

x = 5.622
x = round(x)
print(x)

y = 5.256
y = round(y)
print(y)

Converting data types:

Many times, like reading data in from a file, you might find the datatype is incorrect, like when we mean to have integers, but they are currently in string form, or visa versa.

Converting a string to an integer:

intMe = '55'
intMe = int(intMe)
print(intMe)

Converting and integer to a string:

stringMe = 55
stringMe = str(stringMe)
print(stringMe)

Converting an integer to a float:

floatMe = 55
floatMe = float(floatMe)
print(floatMe)

You can also convert floats to strings, strings to floats, and more. Just make sure you do a valid operation. You still cannot convert the letter h to a float.


There exists 2 quiz/question(s) for this tutorial. for access to these, video downloads, and no ads.

The next tutorial:





  • Python Introduction
  • Print Function and Strings
  • Math with Python
  • Variables Python Tutorial
  • While Loop Python Tutorial
  • For Loop Python Tutorial
  • If Statement Python Tutorial
  • If Else Python Tutorial
  • If Elif Else Python Tutorial
  • Functions Python Tutorial
  • Function Parameters Python Tutorial
  • Function Parameter Defaults Python Tutorial
  • Global and Local Variables Python Tutorial
  • Installing Modules Python Tutorial
  • How to download and install Python Packages and Modules with Pip
  • Common Errors Python Tutorial
  • Writing to a File Python Tutorial
  • Appending Files Python Tutorial
  • Reading from Files Python Tutorial
  • Classes Python Tutorial
  • Frequently asked Questions Python Tutorial
  • Getting User Input Python Tutorial
  • Statistics Module Python Tutorial
  • Module import Syntax Python Tutorial
  • Making your own Modules Python Tutorial
  • Python Lists vs Tuples
  • List Manipulation Python Tutorial
  • Multi-dimensional lists Python Tutorial
  • Reading CSV files in Python
  • Try and Except Error handling Python Tutorial
  • Multi-Line printing Python Tutorial
  • Python dictionaries
  • Built in functions Python Tutorial
  • OS Module Python Tutorial
  • SYS module Python Tutorial
  • Python urllib tutorial for Accessing the Internet
  • Regular Expressions with re Python Tutorial
  • How to Parse a Website with regex and urllib Python Tutorial
  • Tkinter intro
  • Tkinter buttons
  • Tkinter event handling
  • Tkinter menu bar
  • Tkinter images, text, and conclusion
  • Threading module
  • CX_Freeze Python Tutorial
  • The Subprocess Module Python Tutorial
  • Matplotlib Crash Course Python Tutorial
  • Python ftplib Tutorial
  • Sockets with Python Intro
  • Simple Port Scanner with Sockets
  • Threaded Port Scanner
  • Binding and Listening with Sockets
  • Client Server System with Sockets
  • Python 2to3 for Converting Python 2 scripts to Python 3
  • Python Pickle Module for saving Objects by serialization
  • Eval Module with Python Tutorial
  • Exec with Python Tutorial