1) What will be the output of the following code snippet? my_list = [10, 20, 30, 40, 50] print(my_list[1:4]) a) [10, 20, 30] b) [10, 20, 30, 40] c) [20, 30, 40] d) [20, 30, 40, 50] 2) What happens if you forget to increment the counter variable in a while loop that depends on it? a) The program will throw a SyntaxError. b) The loop will run once and then terminate. c) The loop will become an infinite loop. d) Python will automatically increment it for you. 3) Which statement is used to exit the current loop entirely, regardless of the condition? a) stop b) break c) continue d) exit 4) What will be the result of this list comprehension? [x * 2 for x in range(3)] a) [1, 2, 3] b) [0, 2, 4, 6] c) [2, 4, 6] d) [0, 2, 4] 5) What is a common side effect of removing an item from a list while iterating over it with a basic for item in my_list: loop? a) The items will be removed in reverse order. b) The loop will immediately crash with a ConcurrentModificationError. c) Some items in the list might be skipped. d) The list will be automatically backed up.
0%
List & Loops Extra Activity
مشاركة
مشاركة
مشاركة
بواسطة
Currdeptpyramak
تحرير المحتوى
طباعة
تضمين
المزيد
الواجبات
لوحة الصدارة
عرض المزيد
عرض أقل
لوحة الصدارة هذه في الوضع الخاص حاليًا. انقر على
مشاركة
لتجعلها عامة.
عَطَل مالك المورد لوحة الصدارة هذه.
عُطِلت لوحة الصدارة هذه حيث أنّ الخيارات الخاصة بك مختلفة عن مالك المورد.
خيارات الإرجاع
اختبار تنافسي
قالب مفتوح النهاية. ولا يصدر عنه درجات توضع في لوحة الصدارة.
يجب تسجيل الدخول
النمط البصري
الخطوط
يجب الاشتراك
الخيارات
تبديل القالب
إظهار الكل
ستظهر لك المزيد من التنسيقات عند تشغيل النشاط.
فتح النتائج
نسخ الرابط
رمز الاستجابة السريعة
حذف
استعادة الحفظ التلقائي:
؟