Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2094 of 3366
4K+ Views
In this tutorial, we are going to create a simple GUI calculator using the Tkinter module. Tkinter is builtin the Python module for developing the GUI application. It's easy to use and comes with Python. We can visualize our data with GUI applications.Let's see how to create a simple GUI calculator.Import everything from the Tkinter using *.Create an interface for the calculator.Create an input function that enters a number into the input field.Create an apparent function that wipes everything from the input field.And finally, evaluate function that computes and gives the result of the expression.Example# importing everyting from tkinter from tkinter import * ... Read More
2K+ Views
In this tutorial, we are going to learn how to create a run-length encoding in Python. Given a string return a new string containing char and frequency.For example, the string tutorialspoint will be encoded as t3u1o2r1i2a1l1s1p1n1. The order is every char+frequency. Join all of them and return. See the steps below to write the program.Write the function with the name run_length_encoding.Initialize a dictionary with OrderedDict to get an initial count of chars as 0.Iterate over every character of the string and increment the count in the dictionary.Join all the chars and their frequencies. And print it.Initialize the strings and invoke ... Read More
3K+ Views
In this tutorial, we are going to write a program that checks whether a string contains any special character or not. It's straightforward in Python.We will have a set of special characters in the string module. We can use that one to check whether a string contains any special characters or not. Let's see the steps to write the program.Import the string module.Store the special characters from string.punctuation in a variable.Initialize a string.Check whether the string has special characters or not using the map function.Print the result, whether valid or not.Example# importing the string module import string # special characters ... Read More
2K+ Views
Sometimes you want to accept input based on certain conditions. Here, we are going to see the same type of program. We will write a program that allows only words with vowels. We will show them whether the input is valid or not.Let's see the approach step by step.Define a list of vowels [A, E, I, O, U, a, e, i, o, u]Initialize a word or sentence.Iterate over the word or sentence.Check if it is present in the list or not. 3.1.1. If not, break the loop and print Not accepted.Else print acceptedExampleLet's convert the text into Python ... Read More
13K+ Views
In this tutorial, we are going to learn how to print the calendar of month and year using the calendar module of Python. It's a straightforward thing in Python. We need year and month numbers. That's it.Let's see how to print a year calendar. Follow the below steps to print the year calendar.Import the calendar module.Initialize the year number.Print the calendar using calendar.calendar(year) class.ExampleSee the below code. Live Demo# importing the calendar module import calendar # initializing the year year = 2020 # printing the calendar print(calendar.calendar(year))OutputIf you run the above code, you will get the following output. ... Read More
874 Views
In this tutorial, we are going to learn how to multiply two matrices using the NumPy library in Python. It's straightforward with the NumPy library.It has a method called dot for the matric multiplication. You can install the NumPy library with the following command.pip install numpyLet's see the steps involved in the program.Import the NumPy library.Initialize the matrices.Multiply the matrices with numpy.dot(matrix_1, matrix_2) method and store the result in a variable.Print the result.See the below code.Example# importing the module import numpy # initializing the matrices matrix_1 = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ... Read More
2K+ Views
Given a list of numbers, move all the zeroes to the end using list comprehensions. For example, the result of [1, 3, 0, 4, 0, 5, 6, 0, 7] is [1, 3, 4, 5, 6, 7, 0, 0, 0].It's a single line code using the list comprehensions. See the following steps to achieve the result.Initialize the list of numbers.Generate non-zeroes from the list and generate zeroes from the list. Add both. And store the result in a list.Print the new list.Example# initializing a list numbers = [1, 3, 0, 4, 0, 5, 6, 0, 7] # moving all the zeroes ... Read More
1K+ Views
In this tutorial, we are going to learn to merge, join, and concat the DataFrames using pandas library. I think you are already familiar with dataframes and pandas library. Let's see the three operations one by one.MergeWe have a method called pandas.merge() that merges dataframes similar to the database join operations. Follow the below steps to achieve the desired output. Merge method uses the common column for the merge operation.Initialize the Dataframes.Call the method pandas.merge() with three arguments dataframes, how (defines the database join operation), on (common field of the dataframes).ExampleLet's see an example.# importing the pandas library import pandas # creating dataframes ... Read More
4K+ Views
Google provides a static maps API that returns a map image on our HTTP request. We can directly request for a map image with different parameters based on our need.We have to create a billing account on Google to use this API. You can go to the website for more details.Let's see the steps to get the image of a location.Import the requests module.Initialise your API Key and base URL ("https://maps.googleapis.com/maps/api/staticmap?").Initialize the city and zoom value.Update the URL with API Key, City, and Zoom value.USend an HTTP request. And write the response to a file for saving the image.pdate the ... Read More
9K+ Views
In this tutorial, we are going to get the weather of a city using OpenWeatherMap API. To use the OpenWeatherMap API, we have to get the API key. We will get it by creating an account on their website.Create an account and get your API Key. It's free until 60 calls per minute. You have to pay if you want more than that. For this tutorial, the free version is enough. We need requests module for the HTTP requests and JSON module to work with the response. Follow the below steps to the weather of any city.Import the requests and JSON ... Read More