Python List Comprehension

Introduction


The understanding of the fact that a lot of power is to be ignored by Python's idea. However, this is one of the most difficult subjects in the beginning. Through this, I want to help all those who are faced with problems with books.


 The principle of this idea will help you in two ways:
1. I will begin to write open and effective answers
2. Therefore, the code will be implemented quickly
Do you know the list of 35% faster than circles and 45% faster than the map? We find this as well as many fun things at this post.
  1. [x**2 for x in range(0,10)]
  2. [x for x in range(1,20) if x%2==0 ]
  3. [x for x in 'MATHEMATICS' if x in ['A','E','I','O','U']]


When I read this, I am sure both of them want to learn to be polite or to be better than this idea. However, the post will help you.
PS - This article is relevant to the start and use of Python Data users. If you are a user experience python, this post will not help you much.

Index


1. What kind of understanding?
2. Time advantage
3. Write knowledge of generators
4. Some science applications 

1. What is an understanding (LC)?


When I first used the LC, she took me to memory and reminded me of the structure of the form. Yes, you have it. Building a building concept is often taught in the XI class in India. (Check this) We've found some examples of simple texts that describe this idea.
We see basic examples:
1. {x ^ 2: x is a natural number less than 10}
2. {x: x is less than 20, xx even}
3. {x: x is a word 'math', x is the worker}
Now we've seen the work rules in accordance with Python LC (the same):
Do not worry, though somewhat sad. Wait and wait for me, it will be clear to go. Let's take a step to see what has happened. Any previous example involves three-layout, powerful elements and a timetable. Therefore, it can be said that the single agent for another loop.
Example 1: Attach Matrix
Purpose: Take pictures of repetition and return them to topic topics.

2. Time Advantage


In this section, we will find the time LC is used in terms of similar techniques. We will also try to resolve the LC situation and should be avoided well. In comparison with the killings, we will compare the readings in different ways.
Before jumping to compare the timing of different techniques, allow Python's map review.
map
It is used to apply any elements of the list or similar.
Materials: Map (technique, Python)
Creating Words (GE)
Have you ever heard of Generators in Python? We will try to understand it.

3. Write Knowledge Of Generators

The generator is the assistant, but returns to a single value and calculates votes between the calling people. It looks like a bowling balloon for cricket. Several measures are:
1. Starter: The captain determined that the bows of the argues are aware that he needs to bring the ball 6.
2. Ball 1: The thighs for the first time, the baseball machine controls the ball, the ball and the other player back to the fan.
3. Ball 2-5: As a rule
4. Ball 6: It's the final sequel to find out after this.
The road on the same road on the road. The key to the power generator is:
1. The Cricket knows it needs 6 times, it's called generator (it can even be the limit, but he will know)
2. As the landlord does not have the same six leaks at the same time, the generator also returns another value for another call.
3. As the bugs are recently named after each envelope, the generator will be restarted at any time
Let's consider a simple example - output the total number 0 to number N for the generator.
4. Use of these science projects

4. Some Science Applications


At the end of the development, let's talk about some of the conceptual ideas that are beneficial to the knowledge of the data. Quick summarize, remember the LC style:
[ output_expression() for(set of values to iterate) if(conditional filtering) ]





Comments

Popular posts from this blog

Python – Functions

What is Django in python?