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 on Trending Technologies
Technical articles with clear explanations and examples
How to print in same line in Python?
The print() function in Python automatically prints in the next line each time. By default, print() adds a newline character () at the end of each output. Default Behavior Here's how print() works by default ? for i in range(5): print(i) 0 1 2 3 4 Using the end Parameter The print() function accepts an end parameter that controls what gets printed at the end of each output. By changing this parameter, you can print on the same line. Syntax print("text", end="character") ...
Read MoreHow to declare a variable in Python?
In Python, we need not declare a variable with some specific data type. Python has no command for declaring a variable. A variable is created when some value is assigned to it. The value assigned to a variable determines the data type of that variable. Thus, declaring a variable in Python is very simple: Just name the variable Assign the required value to it The data type of the variable will be automatically determined from the value assigned, we need not define it explicitly. Declare an ...
Read MoreHow to convert int to string in Python?
Type conversion is often needed when you want to convert one data type into another according to your requirements. Python provides several methods to convert integers to strings. Python has a built-in function str() to convert an integer to a string. We will discuss various methods to convert int to string in Python. Using str() Function This is the most commonly used method to convert int to string in Python. The str() function takes an integer variable as a parameter and converts it into a string ? Syntax str(integer_variable) Example ...
Read MoreHow to compare two lists in Python?
The list in Python is a collection of items that we often need to compare. Python provides several methods to compare two lists, each with different behaviors regarding element order and frequency. Using == Operator (Order Matters) The simplest method compares lists element by element in the same positions. This method considers both values and order ? def compare_lists(list1, list2): if list1 == list2: return "Equal" else: return "Not equal" # ...
Read MoreHow to run Python Program?
After writing Python code, you need to run it to execute and obtain the output. Running a Python program helps verify that your code is correct and produces the desired results. Python programs can be executed in several ways depending on your development environment and preferences. Running Python in IDLE IDLE (Integrated Development and Learning Environment) comes bundled with Python installation ? Write your Python code and save it with a .py extension To run the program, go to Run > Run Module or press F5 Example print("Hello, World!") print("Welcome to ...
Read MoreHow to install Python in Windows?
Python is a widely used high-level programming language. To write and execute code in Python, we first need to install Python on our system. Installing Python on Windows takes a series of few easy steps. This guide will walk you through the complete process. Step 1 − Select Version of Python to Install Python has various versions available with differences between the syntax and working of different versions of the language. We need to choose the version which we want to use or need. Python 3.x is the current version and recommended for new projects. Python ...
Read MoreWord Dictionary using Python Tkinter
In this article, we will create a GUI-based dictionary using PyDictionary and Tkinter modules. This application will allow users to search for word meanings through an intuitive graphical interface. PyDictionary is a Python module that helps to get meanings, translations, antonyms and synonyms of words. It uses WordNet for getting meanings, Google for translations, and synonym.com for getting synonyms and antonyms. PyDictionary uses BeautifulSoup and Requests modules as dependencies. Installation First, install the required module using pip ? pip install PyDictionary Creating the Dictionary Application Here's the complete code to create a ...
Read MoreWindow Resizer Control Panel in Tkinter
In this article, we will create a GUI-based window resizer control panel using Tkinter that allows you to resize a target window by adjusting its width and height through sliders. We'll use the ttk library from Tkinter to create the sliders and build a control panel that can launch a new window and dynamically resize it using three different controls: width-only, height-only, and proportional resizing. Creating the Basic Control Panel Let's start by creating the main window with the control interface − # Import the required Libraries from tkinter import * from tkinter import ttk ...
Read MoreWhat does the 'tearoff' attribute do in a Tkinter Menu?
The tearoff attribute in Tkinter Menu controls whether a menu can be "torn off" or detached from its parent window. When enabled, users can separate the menu into a floating window for easier access. Tearoff Options The tearoff attribute accepts a Boolean value with two behaviors: tearoff=0 − Menu remains attached to the parent window (default) tearoff=1 − Menu displays a dashed separator line at the top, allowing users to detach it Example: Non-Tearable Menu Here's how to create a menu that stays attached to the window: import tkinter as tk ...
Read MoreTkinter bell() method
Tkinter bell() method produces the default system sound or beep. This method can be invoked on any Tkinter widget to trigger the system's default notification sound. You can customize the system sound through your operating system's sound settings. Syntax widget.bell() Where widget can be any Tkinter widget like root window, Frame, Button, etc. Example Let's create a simple application with a button that plays the system bell sound when clicked − # Import the library from tkinter import * # Create an instance of tkinter frame win = Tk() ...
Read More