Skip to content

Programming Articles

  • HOME
  • Python
  • JavaScript
  • C/C++
  • Java
  • Terms & Conditions and Privacy Policy
  • About US
Main Menu

How To

Python / Python HowTos

How to pad a string with zeroes to the left?

This is a very frequently asked question, how do I pad a numeric string with zeroes to the left, so that the string has a specific length? In this article, …

How to pad a string with zeroes to the left? Learn More
Python / Python HowTos

How to delete an element from a dictionary?

The del statement removes an element: Note that this mutates the existing dictionary, so the contents of the dictionary changes for anybody else who has a reference to the same instance. To return …

How to delete an element from a dictionary? Learn More
Python HowTos

How to count the occurrences of a list item in Python?

If you only want a single item’s count, use the count method: Important: this is very slow if you are counting multiple different items Each count call goes over the entire list of n elements. Calling count in a loop n times …

How to count the occurrences of a list item in Python? Learn More
Python HowTos

How to remove an element from a list by index in Python?

Use del and specify the index of the element you want to delete: Also supports slices: How to remove an element from a list by index in Python? You probably want pop: By …

How to remove an element from a list by index in Python? Learn More
Python HowTos

How to determine the type of an object in Python?

There are two built-in functions that help you identify the type of an object. You can use type() if you need the exact type of an object, and isinstance() to check an object’s type against something. …

How to determine the type of an object in Python? Learn More
Python HowTos

How can I print literal curly-brace characters in a string and also use .format on it in Python?

You need to double the {{ and }}: Here’s the relevant part of the Python documentation for format string syntax: Format strings contain “replacement fields” surrounded by curly braces {}. Anything that is not contained …

How can I print literal curly-brace characters in a string and also use .format on it in Python? Learn More
Python HowTos

How to import files from different folders in Python?

Sample query: I have the following folder structure. I want to import some functions from file.py in some_file.py. I’ve tried and some other various attempts but so far I couldn’t manage to import …

How to import files from different folders in Python? Learn More
Python / Python HowTos

How to move a file in Python?

Although os.rename() and shutil.move() will both rename files, the command that is closest to the Unix mv command is shutil.move(). The difference is that os.rename() doesn’t work if the source and destination are on different disks, while shutil.move() is …

How to move a file in Python? Learn More
Android / How To

How to get the current time and date in Android?

In this post, we’ll learn how can you get the current time and date in an Android app. How to get current time and date in Android? You could use: …

How to get the current time and date in Android? Learn More
Python HowTos

How to copy a file in Python?

In this post, we’ll discuss how to copy a file in Python with code examples. How to copy a file in Python? shutil has many methods you can use. One of …

How to copy a file in Python? Learn More
Python HowTos

How to check if a list is empty in python?

Query: For example, if passed the following: How do I check to see if a is empty? How to check if a list is empty in Python? This can be done using …

How to check if a list is empty in python? Learn More
Formatted Codes / Python HowTos

How to catch multiple exceptions in one line in Python?

Query explained: I know that I can do: I can also do this: But if I want to do the same thing inside two different exceptions, the best I can …

How to catch multiple exceptions in one line in Python? Learn More
Formatted Codes / Python HowTos

How to list all files of a directory in Python?

Query: How can I list all files of a directory in Python and add them to a list? How to list all files of a directory in Python? Method #1: os.listdir() will …

How to list all files of a directory in Python? Learn More
Android / How To

How to speed up the Android emulator?

You can now enable the Quick Boot option for Android Emulator. That will save the emulator state, and it will start the emulator quickly on the next boot. Click on …

How to speed up the Android emulator? Learn More
Git / How To

How to move uncommitted work to a new branch in Git?

Query: I started some work on a new feature and after coding for a bit, I decided this feature should be on its own branch. How do I move the …

How to move uncommitted work to a new branch in Git? Learn More
Python HowTos

How to use global variables in a function in Python?

Query: How can I create or use a global variable in a function? If I create a global variable in one function, how can I use that global variable in …

How to use global variables in a function in Python? Learn More
Formatted Codes / Python HowTos

How to iterate over dictionaries using ‘for’ loops in Python?

Query explained: I am a bit puzzled by the following code: What I don’t understand is the key portion. How does Python recognize that it needs only to read the key from …

How to iterate over dictionaries using ‘for’ loops in Python? Learn More

Posts navigation

1 2 3 Next

Featured Posts

History of UNIX

From UNIX to Linux – History of Linux

21st November 202013th November 2021

Top themes for Ubuntu

Best themes for Ubuntu: Make Ubuntu Beautiful

20th October 202029th November 2021

Strings in Python

Strings in Python

12th September 202010th November 2021

is python hard to learn

Is Python hard to learn? Top best learning resources

18th April 202013th November 2021

Recent posts

  • How to pad a string with zeroes to the left?
  • What is the difference between a process and a thread?
  • How to generate a random alpha-numeric string in Java?
  • How to auto-resize an image to fit a ‘div’ container?
  • How to get a Docker container’s IP address from the host?
  • How to display a JavaScript object?
Copyright © 2022 Programming Articles.
Powered by WordPress and HitMag.