Pawandeep has Published 50 Articles

How to sort a dictionary in Python?

pawandeep

pawandeep

Updated on 11-Mar-2021 09:21:11

4K+ Views

A dictionary is a data structure that consists of key and value pairs. We can sort a dictionary using two criteria −Sort by key − The dictionary is sorted in ascending order of its keys. The values are not taken care of.Sort by value − The dictionary is sorted in ... Read More

What is Bubble Sort in Python? Explain with an example?

pawandeep

pawandeep

Updated on 11-Mar-2021 09:14:09

1K+ Views

Bubble sort is a sorting algorithm to sort a list into ascending (or descending) order. This is the easiest sorting algorithm but it is not very efficient. It can be used on small input sizes but not time efficient for lists or arrays with larger length. Its time complexity is ... Read More

Explain Binary Search in Python

pawandeep

pawandeep

Updated on 11-Mar-2021 09:11:49

3K+ Views

Binary search is a searching algorithm which is used to search an element from a sorted array. It cannot be used to search from an unsorted array. Binary search is an efficient algorithm and is better than linear search in terms of time complexity.The time complexity of linear search is ... Read More

How to read CSV file in Python?

pawandeep

pawandeep

Updated on 11-Mar-2021 09:10:51

3K+ Views

A CSV file stands for Comma Separated Values file. It is a plain text file in which data values are separated by commas and hence represent a tabular data in the form of plain text with the help of commas. A CSV file has .csv extension.Here’s how a CSV files ... Read More

How long does it take to learn Python?

pawandeep

pawandeep

Updated on 11-Mar-2021 09:07:26

115 Views

How fast can someone learn or excel in something completely depends on one’s interest in learning, dedication and persistence.Now, how long does it take to learn Python depends on how much do you want to learn.The basics of Python which include functions, loops, conditional statements, datatypes, etc., would take about ... Read More

Is Python a scripting language?

pawandeep

pawandeep

Updated on 11-Mar-2021 09:06:44

4K+ Views

Yes, Python is a scripting language.Scripting language v/s Programming languageThe first question which strikes into the mind is, what is the difference between programming and scripting language. The only difference which exists is that the scripting language does not require any compilation, it is directly interpreted.For example, the programs written ... Read More

How to declare a global variable in Python?

pawandeep

pawandeep

Updated on 11-Mar-2021 09:06:20

3K+ Views

What is a global variable?A global variable is a variable that is declared outside the function but we need to use it inside the function.Example Live Demodef func():    print(a) a=10 func()Output10Here, variable a is global. As it is declared outside the function and can be used inside the function as ... Read More

Write a program to form a cumulative sum list in Python

pawandeep

pawandeep

Updated on 10-Mar-2021 14:26:20

2K+ Views

The cumulative sum till ith element refers to the total sum from 0th to ith element.The program statement is to form a new list from a given list. The ith element in the new list will be the cumulative sum from 0 to ith element in the given list.For example, ... Read More

Write a Python program to find if a number is strong number or not

pawandeep

pawandeep

Updated on 10-Mar-2021 14:19:01

619 Views

What is a Strong Number?A Strong number is one that is equal to the sum of the factorial of its digits.Example145 Factorial of 1=1 Factorial of 4=24 Factorial of 5=120 Sum=1+24+120    =145Following program is to find if the input number is a strong number or not. Return ‘True’ if ... Read More

How to round off a number in Python?

pawandeep

pawandeep

Updated on 10-Mar-2021 14:18:23

588 Views

Python has an inbuilt round() function to round off a number.The round() method in Python takes two parameters −The first one is the number to be rounded off.The second one specifies the number of digits to which the number must be rounded off.Here, the second parameter is optional.If second parameter ... Read More

Advertisements