Sign in

Technology Enthusiast | Loves Humor | Hobby Runner | Avid Reader

The basic introduction to Python’s Generator Function and Generator Expression.

Photo by Jason Blackeye on Unsplash

In one of my previous articles, I briefly discussed the concept of Generator Expressions, in this one we are going to explore Generators in detail.

Before moving ahead, make sure you are familiar with some basic terms,

  • Iteration is the process of repeating a block of code for a certain number of times.
  • Iterable is an object which can be looped/iterated over.
  • Iterator is an iterable object with a state.
  • Comprehension is a way of writing the code in a short and concise manner.

I have already written articles for above mentioned topics and hence skipping a detailed discussion. …


Breaking the ‘iterating confusion’ around these terms.

Photo by Matt Seymour on Unsplash

While writing an article about Generators, I realized that though iteration, iterable and iterator are so commonly used in programming; there is a certain degree of confusion around them. It’s crucial to understand the underlying concept for a better implementation. This is going to be a short and quick article to help us determine what is an iterable and what is an iterator.

Iteration

  • In layman’s language it is ‘repeating steps’.
  • Iteration in programming is a repetition of a block of code for a certain number of times.
  • This can be achieved by using loops.

Iterable

  • Iterable is an object which can…


A comprehensive guide to Python’s Comprehension capabilities.

Image by author

To understand Python’s Comprehension capabilities, it’s important to understand the concept of comprehension at first. Comprehension in programming is nothing but writing the (existing) code in a short and concise manner, mostly one single line. It is constructing a new sequence by shortening the existing one. Being good at code comprehension is fairly an important skill. You need to understand the implementation to apply the comprehension capabilities of programming. Python-3 supports comprehensions for,


Learn the ways to implement string interpolation in Python.

String interpolation is a process of injecting value into a placeholder (a placeholder is nothing but a variable to which you can assign data/value later) in a string literal. It helps in dynamically formatting the output in a fancier way. Python supports multiple ways to format string literals. All string interpolation methods always return new values and do not manipulate the original string.

Iffat Malik Gore

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store