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 1760 of 3366
3K+ Views
Python Tkinter can be used to create all kinds of GUI programs for the web and desktop. In this article we will see how to create a digital clock displaying hour, minute and seconds live.We use the time module to import the method strftime which displays the time in Hour, minute and seconds format. We create a canvas to hold these values. We refresh the values of strftime after every 200 milli seconds. We define a recursive function to achieve this.Exampleimport time from tkinter import * canvas = Tk() canvas.title("Digital Clock") canvas.geometry("350x200") canvas.resizable(1, 1) label = Label(canvas, font=("Courier", 30, 'bold'), ... Read More
1K+ Views
The progressbar is a common GUI element which is used to show the progress of certain task. In tis article we will see how to create a progressbar using the Python tkinter GUI library.In the below program we have imported the progressbar sub-module of tkinter.ttk module. Then used the style object to create the style options and supply the value for the length of the button as well as value of the progress.Exampleimport tkinter as tk from tkinter.ttk import Progressbar from tkinter import ttk canv = tk.Tk() canv.title("Tkinter Progressbar") canv.geometry('250x100') style = ttk.Style() style.theme_use('default') style.configure("grey.Horizontal.TProgressbar", background='blue') bar = Progressbar(canv, length=180, ... Read More
2K+ Views
Every programming language has a feature to create scripts and run them from the terminal or being called by other programs. When running such scripts we often need to pass on arguments needed by the script for various functions to be executed inside the script. In this article we will see what are the various ways to pass arguments into a python script.Using sys.argvThis is a inbuilt module sys.argv can process arguments that are passed on with the script. By default the first argument which is considered at sys.argv[0] is the file name. the rest of the arguments are indexed ... Read More
3K+ Views
Tkinter has great support for creating the GUI programs based on python. It offers different ways of styling a button on the Tkinter canvas based on its font, size, colour etc. In this article we will see how to apply style to specific buttons or all buttons in general on the canvas.Applying to Specific ButtonsLets consider the case when we have two buttons in the canvas and we want to apply some styling only to the first button. We use the W.TButton as part of the configuration along with the font and the foreground colour.Examplefrom tkinter import * from tkinter.ttk ... Read More
154 Views
Suppose we have a number N, we have to find all factors of N and return the product of four factors of N such that: The sum of the four factors is same as N. The product of the four factors is maximum. All four factors can be equal to each other to maximize the product.So, if the input is like N = 60, then the output will be All the factors are -> 1 2 3 4 5 6 10 12 15 20 30 60 and product is 50625, as we 15 has been selected four times to make ... Read More
170 Views
Suppose we have a sorted doubly linked list of unique positive numbers; we have to find pairs in the doubly linked list whose product is same as a given value x. We have to keep in mind that, this will be solved without consuming any extra space.So, if the input is like L = 1 ⇔ 2 ⇔ 4 ⇔ 5 ⇔ 6 ⇔ 8 ⇔ 9 and x = 8, then the output will be (1, 8), (2, 4)To solve this, we will follow these steps −curr := head, nxt := headwhile nxt.next is not None is non-zero, donxt ... Read More
211 Views
Suppose we have an array A where GCD of every possible pair of elements of another array is given, we have to find the original numbers which are used to compute the given GCD array.So, if the input is like A = [6, 1, 1, 13], then the output will be [13, 6] as gcd(13, 13) is 13, gcd(13, 6) is 1, gcd(6, 13) is 1, gcd(6, 6) is 6To solve this, we will follow these steps −n := size of Asort array A in descending orderoccurrence := an array of size A[0] and fill with 0for i in range ... Read More
693 Views
Suppose we have a sequence of numbers called bn, this is represented using a recurrence relation like b1=1 and bn+1/bn=2n . We have to find the value of log2(bn) for a given n.So, if the input is like 6, then the output will be 5 as log2(bn) = (n * (n - 1)) / 2 = (6*(6-1))/2 = 15We can solve this problem by solving this relation as follows −bn+1/bn = 2nbn/bn-1 = 2n-1…b2/b1 = 21 , If we multiply all of above, we can get(bn+1/bn).(bn/bn-1)……(b2/b1) = 2n + (n-1)+……….+1So, bn+1/b1 = 2n(n+1)/2As 1 + 2 + 3 + ………. ... Read More
301 Views
Suppose we have a string whose length is m, and this string is containing only lowercase letters, we have to find the n-th permutation of string lexicographically.So, if the input is like string = "pqr", n = 3, then the output will be "qpr" as all permutations are [pqr, prq, qpr, qrp, rpq, rqp], they are in sorted order.To solve this, we will follow these steps −MAX_CHAR := 26MAX_FACT := 20factorials := an array of size MAX_FACTfactorials[0] := 1for i in range 1 to MAX_FACT, dofactorials[i] := factorials[i - 1] * isize := size of stringoccurrence := an array of ... Read More
164 Views
Suppose we have two integers N and K; we have to find N unique values whose bit-wise OR is same as K. If there is no such result, then return -1So, if the input is like N = 4 and K = 6, then the output will be [6, 0, 1, 2].To solve this, we will follow these steps −MAX := 32visited := a list of size MAX and fill with Falseres := a new listDefine a function add() . This will take numpoint := 0value := 0for i in range 0 to MAX, doif visited[i] is non-zero, thengo for ... Read More