- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 35164 Articles for Programming
1K+ Views
Python provides Pdfcrowd API v2 which is convert HTML documents to PDF. This API is very easy to use and the integration takes only a couple of lines of code. Installation Install the client library from PyPI $ pip install pdfcrowd Conversion will be completed in following 3 Steps from Webpage/HTML to PDF Step 1 − Download the library pdfkit $ pip install pdfkit Step 2 − Now download wkhtmltopdf For Ubuntu/Debian − sudo apt-get install wkhtmltopdf For Windows − (a) Download link : WKHTMLTOPDF (b) Set : PATH variable set binary folder ... Read More
1K+ Views
In this article, we will sort a list according to the second element in the sublist. Let’s say we have the following list − [['jack', 50], ['antony', 20], ['jones', 87], ['gary', 70], ['tom', 90], ['sam', 110], ['warner', 65]] The output should be the following i.e. sorted according to the second element − [['antony', 20], ['jack', 50], ['warner', 65], ['gary', 70], ['jones', 87], ['tom', 90], ['sam', 110]] Python program to sort a list according to the second element in the sublist using the sort() method Example # Custom Function def SortFunc(sub_li): sub_li.sort(key = lambda x: x[1]) return sub_li ... Read More
11K+ Views
Given two user input matrix. Our task is to display the addition of two matrix. In these problem we use nested List comprehensive. Algorithm Step1: input two matrix. Step 2: nested for loops only to iterate through each row and columns. Step 3: At each iterationshall add the corresponding elements from two matrices and shall store the result. Example code # Program to add two matrices using nested loop A=[] n=int(input("Enter N for N x N matrix : ")) #3 here #use list for storing 2D array #get the ... Read More
722 Views
We have to enter our height and weight. Our task is to calculate BMI using formula. Algorithm Step 1: input height and weight of your body. Step 2: then applying the formula for calculation BMI. Step 3: display BMI. Example Code height = float(input("Enter your height(m): ")) weight = float(input("Enter your weight(kg): ")) print("Your BMI is: ", round(weight / (height * height), 2)) Output Enter your height (m): 5.8 Input your weight (kg): 64 Your body mass index is: 1.9
18K+ Views
Given two user input matrix. Our task is to display the addition of two matrix. In these problem we use nested List comprehensive. Algorithm Step1: input two matrix. Step 2: nested for loops to iterate through each row and each column. Step 3: take one resultant matrix which is initially contains all 0. Then we multiply each row elements of first matrix with each elements of second matrix, then add all multiplied value. That is the value of resultant matrix. Example Code # Program to multiply two matrices A=[] n=int(input("Enter N for N x N matrix: ")) ... Read More
9K+ Views
Given three number a b and c, our task is that we have to find the maximum element in among in given number. Example Input: a = 2, b = 4, c = 3 Output: 4 Algorithm Step 1: input three user input number. Step2: Add three numbers to list. Step 3: Using max() function to find the greatest number max(lst). Step 4: And finally we will print maximum number. Example Code def maximum(a, b, c): list = [a, b, c] return max(list) # ... Read More
556 Views
Given three numbers x, y and z, our task is to calculate (x^y) % z Example Input: x = 2, y = 3, p = 3 Output: 2 Explanation : 2^3 % 3= 8 % 3 = 2. Algorithm Step 1: Input three numbers. Step 2: then we use pow() to calculating power and % for modular. Step 3: display result. Example Code x = int(input("Enter First Value ::>")) y = int(input("Enter Second Value ::>")) z= (int)(1e9+7) # pow function use d = pow(x, y) % z print ("Value Is=",d) Output Enter First Value ::> 2 Enter Second Value ::> 3 Value Is= 8
325 Views
Given a string that has set of words and spaces, our task is to move all spaces to front of string, by traversing the string only once. We will solve this problem quickly in Python using List Comprehension.ExampleInput: string = "python program" Output: string= “ pythonprogram"AlgorithmStep1: input a string with word and space. Step2: Traverse the input string and using list comprehension create a string without any space. Step 3: Then calculate a number of spaces. Step 4: Next create a final string with spaces. Step 5: Then concatenate string having no spaces. Step 6: Display string.Example Code# Function to ... Read More
772 Views
Two user input strings are given, our task is to print all the common characters in alphabetical order.ExampleInput: string1: python string2: program Output: opExplanationThe letters that are common between the two strings are o (1 times), p (1 time)AlgorithmStep 1: first we take two input string. Step 2: next we will do to convert these two strings into counter dictionary. Step 3: Now find common elements between two strings using intersection ( ) property. Step 4: Resultant will also be a counter dictionary having common elements as keys and their common frequencies as value. Step 5: Use elements () method ... Read More