Skip to content

Python

Python is an high level, interpreted, general-purpose programming language. It’s based on design philosophy that emphasizes highly on code readability. It supports structured, object-oriented and functional programming paradigm. It has gained popularity due to its ease of use and collection of large sets of standard libraries.

Array in Python

Python offers several array-like structures. The built-in array.array stores values of a specified primitive type, while lists can hold mixed objects and NumPy arrays support numerical operations. It is a collection of elements having the same data type and always start from index value and index start from 0 to 1. It doesn’t have a fixed size which means it can be expand it or shrink it. We can declare… Read More »Python Arrays Explained: array.array vs Lists and NumPy

Python Arrays Explained: array.array vs Lists and NumPy

  • by
Smallest number in array python

Quick answer: To find the second smallest distinct number in a Python list, use sorted(set(numbers))[1] after checking that at least two distinct values exist. For example, [5, 2, 4, 9, 7, 2] gives 4, because 2 occurs twice but is counted once. Method 1 (simple but inefficient): By sorting array Convert the input to a set to remove duplicates, sort the remaining values, and return index 1. Check the number… Read More »Find the Second Smallest Distinct Number in Python: Two Methods

Find the Second Smallest Distinct Number in Python: Two Methods

Build your own GUI calculator using Python

This Python 3 Tkinter tutorial builds a desktop calculator while explaining widgets, button callbacks and safe arithmetic handling. Python GUI Calculator The GUI calculator that we will build using Python look as follows. Requirement for GUI Calculator The only requirement is Python 3 and Tkinter package. It is one of the most popular Python library for creating GUI application. Most of the latest version of Python3 comes with Tkinter. To… Read More »Build a Python Tkinter Calculator: GUI, Buttons and Safety

Build a Python Tkinter Calculator: GUI, Buttons and Safety

Build practical data science skills with Python, SQL, statistics, data preparation, visualization, machine learning and communication. This updates the article’s 2021 framing for current learners. Today, our mobile devices generates more data than ever before, posing new challenges for storage and analysis. According to Forbes, 2.5 quintillion bytes of data is created every day. Gaining marketing insight from this ever-growing database in a timely manner is becoming increasingly difficult. This is… Read More »7 Essential Data Science Skills: Updated Learning Roadmap

7 Essential Data Science Skills: Updated Learning Roadmap

Python dictionaries map hashable keys to values. To merge dictionaries, choose between mutating an existing dictionary with update() and creating a new one using unpacking or the union operator. There are two ways to merge two or more dictionaries in Python: Merging dictionaries using dict.update(). Merging using **kwargs. Merge two or more dictionaries using dict.update() Python Dictionary update() is a built-in function that accepts another dictionary or an iterable object (collection of key-value pairs)… Read More »Merge Python Dictionaries: update(), Unpacking and the | Operator

Merge Python Dictionaries: update(), Unpacking and the | Operator

Speed up Python by up to Million time

Numba and Cython can accelerate numerical Python workloads, but speedups vary with algorithm, input size, data types and compilation overhead. A claim of a universal million-fold speedup is misleading. Features like list comprehension speeds up Python code but finds limited use. Moreover, speed up gain is limited as it doesn’t address the above fundamental problem. But there are ways by which these bottle neck can be addressed and you can… Read More »Speed Up Python with Numba and Cython: Realistic Benchmarks

Speed Up Python with Numba and Cython: Realistic Benchmarks

Bubble sort repeatedly compares adjacent items and swaps them when out of order. It is useful for learning sorting, but Python’s built-in sorted() and list.sort() are preferable for production code. Bubble sort is an algorithm that compares the adjacent elements and swaps their positions if they are not in the intended order. It makes multiple passes through a list. Each pass through the list places the next largest value in… Read More »Bubble Sort in Python: Algorithm, Code and Complexity

Bubble Sort in Python: Algorithm, Code and Complexity

  • by