Category: New Python tutorial

python tutorials and learn python

Created with Sketch.

Python List Slice

Python List Slice   Summary: in this tutorial, you’ll learn about Python list slice and how to use it to manipulate lists effectively. Introduction to Python List slice notation Lists support the slice notation that allows you to get a sublist from a list: sub_list = list[begin: end: step] Code language: Python (python) In this…
Read more

Python sorted

Python sorted Summary: in this tutorial, you’ll learn how to use the Python sorted() function to sort a list. Introduction to the Python sorted() function The sort() method sorts a list in place. In other words, it changes the order of elements in the original list. To return the new sorted list from the original…
Read more

Python Sort List

Python Sort List   Summary: in this tutorial, you’ll learn how to use the Python List sort() method to sort a list. Introduction to the Python List sort() method To sort a list, you use the sort() method: list.sort() Code language: Python (python) The sort() method sorts the original list in place. It means that…
Read more

Python Tuples

Python Tuples Summary: in this tutorial, you’ll learn about Python tuples and how to use them effectively. Introduction to Python tuples Sometimes, you want to create a list of items that cannot be changed throughout the program. Tuples allow you to do that. A tuple is a list that cannot change. Python refers to a…
Read more

Python List

Python List Summary: in this tutorial, you’ll learn about Python List type and how to manipulate list elements effectively. What is a List A list is an ordered collection of items. Python uses the square brackets ([]) to indicate a list. The following shows an empty list: empty_list = [] Code language: Python (python) Typically,…
Read more

Python Function Docstrings

Python Function Docstrings Summary: in this tutorial, you’ll learn about how to use docstrings to add documentation to a function. Introduction to the help() function Python provides a built-in function called help() that allows you to show the documentation of a function. The following example shows the documentation of the print() function: help(print) Code language:…
Read more

Python Lambda Expressions

Python Lambda Expressions Summary: in this tutorial, you’ll learn about Python lambda expressions and how to use them to write anonymous functions. Sometimes, you need to write a simple function that contains one expression. However, you need to use this function once. And it’ll unnecessary to define that function with the def keyword. That’s where…
Read more

Python Recursive Functions

Python Recursive Functions   Summary: in this tutorial, you’ll learn about Python recursive functions and how to use them to simplify your code. Introduction to recursive functions A recursive function is a function that calls itself until it doesn’t. The following fn() function is a recursive function because it has a call to itself: def…
Read more

Python Keyword Arguments

Python Keyword Arguments Summary: in this tutorial, you’ll learn about the Python keyword arguments, and how to use them to make function calls more obvious. Introduction to the Python keyword arguments Let’s start with a simple function that calculates the net price from the selling price and discount: def get_net_price(price, discount): return price * (1-discount)…
Read more

Python Default Parameters

Python Default Parameters Summary: in this tutorial, you’ll learn about the Python default parameters to simplify function calls. Introduction to Python default parameters When you define a function, you can specify a default value for each parameter. To specify default values for parameters, you use the following syntax: def function_name(param1, param2=value2, param3=value3, …): Code language:…
Read more