Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Vikram Chiluka
Page 19 of 22
Beginner Tips for Learning Python
Python is a beginner-friendly programming language widely used for web development, automation, data analysis, and software creation. Its simple syntax and versatility make it an ideal starting point for aspiring programmers. This guide provides practical tips to help beginners learn Python effectively. Master the Fundamentals First Building a solid foundation is crucial for understanding advanced Python concepts later ? Setting Up Python Install Python from the official website (python.org) and use IDLE or a code editor like VS Code to write your first programs. Essential Basics to Learn # Basic syntax - print ...
Read MoreHow can I convert Python tuple to C array?
In this article, we will show you how to convert a Python tuple to a C array. Python does not have a built-in array data type like other programming languages, but you can create an array using a library like NumPy. Installation If you haven't already installed NumPy on your system, run the following command to do so ? pip install numpy Methods for Tuple to Array Conversion The Python NumPy library provides various methods to create, manipulate and modify arrays in Python. Following are the two important methods that help us convert ...
Read MoreHow can I convert bytes to a Python string?
In Python, bytes are sequences of 8-bit values, while strings are sequences of Unicode characters. Converting bytes to strings is a common task when working with file I/O, network data, or encoded text. Python provides several built-in methods to perform this conversion efficiently. Converting Bytes to Strings in Python The following methods can be used to convert bytes to Python strings ? Using decode() method Using str() function Using codecs.decode() function Using pandas library Using decode() Method ...
Read MoreWhere are operators mapped to magic methods in Python?
In this article, we will explain where operators are mapped to magic methods in Python and how they enable operator overloading. Python Magic methods are special methods that begin and end with double underscores. They are also known as dunder methods. Magic methods are not intended to be invoked directly by you, but rather invocation occurs by the class on a specific action. When you use the + operator to add two numbers, the __add__() method is called internally. Many magic methods in Python are defined by built-in classes. To get the number of magic methods inherited by ...
Read MoreHow to pick a random number not in a list in Python?
Sometimes we need to pick a random number that is not present in a given list. Python provides several approaches to accomplish this task using the random module combined with different data structures and techniques. Using random.choice() with Loop The random.choice() function returns a random element from a sequence. We can combine it with a loop to find numbers not in the original list ? Syntax random.choice(sequence) Parameters sequence − any sequence like list, tuple, or range Example This example creates a new list of numbers not present in the ...
Read MoreHow to generate non-repeating random numbers in Python?
Generating non-repeating random numbers is a common requirement in Python applications. This article demonstrates four different approaches: using randint() with a loop, random.sample() with lists or ranges, and random.choices(). Using randint() with Loop and Checking This method generates random numbers one by one and checks if they already exist in the result list ? import random # Create empty list for storing unique random numbers random_numbers = [] # Generate 10 unique random numbers between 1 and 100 while len(random_numbers) < 10: num = random.randint(1, 100) ...
Read MoreHow to split Python tuples into sub-tuples?
In this article, we will show you how to split Python tuples into sub-tuples of equal size. Tuples are immutable, ordered collections in Python that can be divided into smaller chunks using various methods. What are Tuples? Tuples are immutable, ordered data structures used to store collections in Python. Unlike lists which are mutable and have variable length, tuples have a fixed length once created and cannot be modified. Method 1: Using Slicing The most straightforward approach uses slice notation with the range() function to create sub-tuples of a specific size. Example The following ...
Read MoreHow to zip a Python Dictionary and List together?
In this article, we will show you how to zip a Python dictionary and list together. Below are the various methods to accomplish this task ? Using zip() function Using append() function and items() function Using append() function and in operator Using zip() Function The zip() function combines two iterables by pairing their elements. When zipping a dictionary with a list, we use items() to get key-value pairs from the dictionary ? # input dictionary input_dict = {'Hello': 1, 'tutorialspoint': 2, 'python': 3, 'codes': 3} # input list input_list = [10, 20, ...
Read MoreHow to do Python math at command line?
Python can be used as a powerful calculator at the command line. When you invoke the Python interpreter, you get the (>>>) prompt where any mathematical expression can be entered and evaluated immediately upon pressing ENTER. Python Math Operators Python provides several arithmetic operators for mathematical calculations ? Operation Description a + b Addition - returns the sum of a and b a - b Subtraction - returns the difference of a and b -a Negation - changes the sign of a +a Identity - returns a ...
Read MoreHow to remove index list from another list in python?
In Python, removing multiple elements from a list using their indices requires careful handling to avoid index shifting issues. This article covers two effective methods: pop() and del keyword. Using pop() method Using del keyword The key principle is to remove elements in descending order of their indices to prevent index shifting issues. Why Sort Indices in Descending Order? When removing elements from a list, removing from the beginning changes the indices of subsequent elements. Here's why descending order is crucial ? Example of Index Shifting Problem # Original list and ...
Read More