Blog

python tutorials and learn python

Created with Sketch.

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

Python Functions

Python Functions Summary: in this tutorial, you’ll learn to develop Python functions by using the def keyword. What is a function A function is a named code block that performs a job or returns a value. Why do you need functions in Python Sometimes, you need to perform a task multiple times in a program.…
Read more

Python pass

Python pass Summary: in this tutorial, you’ll learn how to use the Python pass statement as a placeholder. Introduction to the Python pass statement Suppose that you have the following if…else statement: counter = 1 max = 10 if counter <= max: counter += 1 else: # implement later Code language: Python (python) In the…
Read more

Python continue

Python continue Summary: in this tutorial, you’ll learn about the Python continue statement and how to use it to control the loop. Introduction to the Python continue statement The continue statement is used inside a for loop or a while loop. The continue statement skips the current iteration and starts the next one. Typically, you…
Read more

Python break

Python break   Summary: in this tutorial, you’ll learn about the Python break statement and how to use it to exit a loop prematurely. Introduction to the Python break statement Sometimes, you wan to terminate a for loop or a while loop prematurely regardless of the results of the conditional tests. In these cases, you…
Read more

Python while

Python while Summary: in this tutorial, you’ll learn about the Python while statement and how to use it to run a code block as long as a condition is true. Introduction to the Python while statement Python while statement allows you to execute a code block repeatedly as long as a condition is True. The…
Read more

Python for Loop with Range

Python for Loop with Range Summary: in this tutorial, you’ll learn about the Python for loop and how to use it to execute a code block a fixed number of times. Introduction to Python for loop statement with the range() function In programming, you often want to execute a block of code multiple times. To…
Read more