How to Time Functions in Python using time.time

preview_player
Показать описание

^Downloadable code & more! This video teaches you how to time functions in python. Import time and then you can time how many seconds it takes for something to happen. This has endless applications.

This is a Python anaconda tutorial for help with coding, programming, or computer science. These are short python videos dedicated to troubleshooting python problems and learning Python syntax. For more videos see Python Help playlist by Rylan Fowers.





TIME FUNCTIONS PYTHON

I will show you how to time functions in python. We are in a text editor and first let me import time

and we will do an if name equal main

First I am going to save a start time as a variable named start.

Now lets write a small function we can time. lets just do an input so we can see how long it take to type

Next let’s save the time again but we will call it end.

and in this print statement if we do end minus start that will give us the time passed.

So let’s run this in the terminal to see what it’s like

and lets type our put

it took 7.5 second.

Lets see if i can time it faster

There you have it that is how you time functions in python

#PythonMarathon #LearnPython #PythonTutorial
Рекомендации по теме
join shbcf.ru