Post

Python Programming
Python Programming@PythonPr·
Python Quiz: What is the output of the following Python code?
Python Programming tweet media
English
31
17
319
99.2K
Burger King
Burger King@BurgerKing·
A better Whopper made for you, perfect down to the last bite. There’s a new king and it’s you!
English
0
381
5K
29.2M
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
Answer: [8, 12] Explanation: This is a list comprehension: c = [x for x in a if x not in b] It means: “Take each element x from list a and include it in c only if it is not present in list b.” Now check each value from a: 5 → present in b, so exclude it 8 → not in b, so include it 12 → not in b, so include it 2 → present in b, so exclude it
English
1
0
35
8.3K
Jimmy Fikes
Jimmy Fikes@akajim·
@PythonPr c is a list comprehension that finds all values in list a that are not in list b. Final output is [8, 12]
English
1
0
2
3.7K
Starlink
Starlink@Starlink·
Starlink’s high-speed internet is available in your area. Experience speeds up to 400+ Mbps to stream your favorite shows and sports, work from home, browse social media and more.
English
2.9K
4.5K
35.1K
92.3M
vAMSH
vAMSH@vamsshh·
@PythonPr 8 and 12 it evaluates completed expression first for each item in a if this item is not in b then print the item. So goes on to check 5 in b yes present so it won't be printed Similarly whatever item are present in b which are in a those will be not printed so 8,12
English
0
0
0
34
Manduka
Manduka@mandukayoga·
The PRO™ Yoga Mat: the mat that redefined yoga. Crafted since 1997. Engineered for durability. Designed for total control in every transition. The PRO® Mat is built to outlast trends—and your toughest flows. Backed by a lifetime guarantee.
English
0
170
2.4K
5.8M
Fariz Babayev
Fariz Babayev@SweetTechAZ·
@PythonPr Easy one! The answer is [8, 12]. Always love a good Python quiz to start the day.
English
0
0
0
647
Jeff
Jeff@Jeff72571425107·
@PythonPr 5 and 2 are in b so it will print 8 and 12 [8,12]
English
0
0
0
13
KbarisHatipoglu
KbarisHatipoglu@KbarisHatipoglu·
@PythonPr >>> a=[5,8,12,2] >>> b=[18,2,46,5] >>> c=[x for x in a if x in b] >>> print(c) [5, 2] >>> c=[x for x in a if x not in b] >>> print(c) [8, 12]
English
0
0
1
233
Earnest Codes
Earnest Codes@Earnesto037·
@PythonPr Answer [8, 12] The codeuses a list comprehension to filter elements. Here's the logic; Initialization: List a contains [5, 8, 12, 2]. List b contains [18, 2, 46, 5]. The Filter: The line c = [x for x in a if x not in b] iterates through every number in list a and checks if it
English
1
0
2
462
Clapper
Clapper@theclapperapp·
Dream it. Generate it. Share it. 👏🏻
English
0
0
0
11.4K
Paylaş