Blog

python tutorials and learn python

Created with Sketch.

NumPy arange()

NumPy arange() Summary: in this tutorial, you’ll learn how to use the numpy arange() function to create a numpy array with evenly spaced numbers. Introduction to the numpy arange() function The numpy arange() function creates a new numpy array with evenly spaced numbers between start (inclusive) and stop (exclusive) with a given step: numpy.arange(start, stop,…
Read more

NumPy ones()

NumPy ones() Summary: in this tutorial, you’ll learn how to use the numpy ones() function to create a numpy array of a given shape whose elements are filled with ones. The ones() function of the numpy module allows you to create a numpy array of a given shape whose elements are filled with ones. For…
Read more

NumPy zeros()

NumPy zeros() Summary: in this tutorial, you’ll learn how to create a numpy array of a given shape whose elements are filled with zeros. The zeros() function of the numpy module allows you to create a numpy array of a given shape whose elements are filled with zeros. For example, the following uses the zeros()…
Read more

Create NumPy Array

Create NumPy Array Summary: in this tutorial, you’ll learn how to create NumPy arrays including one-dimensional, two-dimensional, and three-dimensional arrays. The array is the core data structure of the NumPy library. A NumPy array is a grid of values with the same type and indexed by a tuple of non-negative integers. All arrays are instances…
Read more

What is NumPy

What is NumPy Summary: in this tutorial, you’ll have a good understanding of NumPy and how it helps you perform calculations fast and efficiently. Introduction to NumPy NumPy stands for Numerical Python and is pronounced as /ˈnʌmpaɪ/. Numpy is a Python library that performs numerical calculations. NumPy is very fast because it is written in…
Read more

Python NumPy

Python NumPy This Python NumPy Tutorial helps you learn NumPy from scratch so that you can use it effectively in your data science & machine learning projects. What you’ll learn Create single and multi-dimensional NumPy arrays Effectively use NumPy built-in functions & methods Perform mathematical operations on arrays Extract elements from arrays using slicing and…
Read more

Python unittest subtest

Python unittest subtest Summary: in this tutorial, you’ll learn how to define parameterized tests using unittest‘s subTest() context manager. Introduction to the unittest subtest context manager First, create a new module called pricing.py and define a calculate() function as follows: def calculate(price, tax=0, discount=0): return round((price – discount) * (1+tax), 2) Code language: Python (python)…
Read more

Python unittest Coverage

Python unittest Coverage Summary: in this tutorial, you’ll learn how to use the Python unittest coverage command to generate a test coverage report. What is test coverage? Test coverage is a ratio between the number of lines executed by at least one test case and the total number of lines of the code base: test…
Read more

Python Mock Requests

Python Mock Requests Summary: In this tutorial, you’ll learn how to mock the requests module in Python to test an API call using the unittest module. The requests module is an HTTP library that allows you to send HTTP requests easily. Typically, you use the requests module to call an API from a remote server.…
Read more

Python Stubs

Python Stubs Summary: in this tutorial, you’ll learn how to use Python stubs to isolate parts of your program from each other for unit testing. Introduction to the Python stubs Stubs are test doubles that return hard-coded values. The primary purpose of stubs is to prepare a specific state of the system under test. Stubs…
Read more