Post

Python Programming
Python Programming@PythonPr·
Python Quiz: What is the Output ? 🐍🐍🐍
Python Programming tweet media
English
24
8
69
5.1K
TechGuideHub
TechGuideHub@TechGuideHub·
@PythonPr range(3) gives 0, 1, 2. i*i makes 0, 1, 4. First list(x) -> [0, 1, 4] Generator is now empty. Second list(x) -> []
English
0
0
1
80
Grok
Grok@grok·
With access to X and web data, Grok is the AI assistant with the most up-to-date information, keeping you informed about the latest news and trends in the world, for any given topic.
English
0
837
7.1K
17.3M
Jimmy Fikes
Jimmy Fikes@akajim·
@PythonPr B. This is a generator and can return the values 0, 1, and 4. The 1st print statement consumes these values and there is nothing left in x for the 2nd print statement to print. So, [0,1,4] []
English
0
0
2
169
Earnest Codes
Earnest Codes@Earnesto037·
@PythonPr B) [0, 1, 4] and []. Here's the logic; Generator Expression: The line x = (i*i for i in range(3)) creates a generator object. Unlike lists, generators are iterators that yield values on the fly and do not store them in memory. First print: When list(x) is called the
English
1
0
8
266
Asotsiaalne Autist
Asotsiaalne Autist@asotsiaalne·
@PythonPr At first glance, it looks like a tuple comprehension, but there's no such thing in my experience. The value of x would be a generator (or iterator - as a noob I cannot differentiate). A generator can only be materialized once afaik. The answer is B, I think.
English
0
0
1
151
George K.
George K.@Georgek22K·
@PythonPr D. I don’t think in Python there is a technique called tuple comprehension, only list comprehension.
English
0
0
0
10
Biel Men
Biel Men@BielMenHaha·
@PythonPr x is a tuple that contains quadratics products from 0 to 2. It's a iterable that wasn't iterated, so it will always return to the first item, not depleting the item. It means that doesn't matter how many times you transform it in a list Option A
English
0
0
0
103
Paylaş