Predict the output of the Python code given below:

tuple1 = (11, 22, 33, 44, 55 ,66)

list1 =list(tuple1)

new_list = []

for i in list1:

if i%2==0:

new_list.append(i)

new_tuple = tuple(new_list)

print(new_tuple)

 

Answer:

Question 24 (Choice 2) -Teachoo.png

Output: (22, 44, 66)

Explanation:

  • tuple1 is a tuple with 6 elements.
  • tuple1 is converted into a list and assigned to list1.
  • A new list called ‘new_list’ is created.
  • The for loop iterates through each item in list1 and checks if it is divisible by 2. If it is, then the item is appended to new_list.
  • new_list is converted into a tuple and assigned to new_tuple.
  • new_tuple is then printed.
Remove Ads
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh is an IIT Kanpur graduate and has been teaching for 16+ years. At Teachoo, he breaks down Maths, Science and Computer Science into simple steps so students understand concepts deeply and score with confidence.

Many students prefer Teachoo Black for a smooth, ad-free learning experience.