Datasets:
task stringclasses 1
value | src stringclasses 1
value | lang stringclasses 1
value | kind stringclasses 4
values | topic stringclasses 13
values | template stringclasses 54
values | entry stringclasses 117
values | reference stringlengths 46 221 ⌀ | tests listlengths 5 8 ⌀ | test_code stringlengths 149 783 ⌀ | answer stringlengths 1 221 | completion stringlengths 23 237 | prompt stringlengths 160 508 | qhash stringlengths 16 16 | code stringlengths 51 255 ⌀ | buggy stringclasses 625
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code | a11_code_gen | python | write_function | lists | w_filter_range#0 | between_times | def between_times(xs):
return sorted(x * -3 for x in xs if 11 <= x <= 17) | [
"assert between_times([8, 11, 10, 2, 6]) == [-33]",
"assert between_times([2, 28, 36, 53, 12, 20]) == [-36]",
"assert between_times([34, 25, -29, 55, 9, -13, 23, 58, 37, -14]) == []",
"assert between_times([-14, -23, -24, 22, 36, 60, 22, 49, -15]) == []",
"assert between_times([]) == []",
"assert between_... | assert between_times([8, 11, 10, 2, 6]) == [-33]
assert between_times([2, 28, 36, 53, 12, 20]) == [-36]
assert between_times([34, 25, -29, 55, 9, -13, 23, 58, 37, -14]) == []
assert between_times([-14, -23, -24, 22, 36, 60, 22, 49, -15]) == []
assert between_times([]) == []
assert between_times([38, 16, 12, 26, -23, 47... | def between_times(xs):
return sorted(x * -3 for x in xs if 11 <= x <= 17) | ```python
def between_times(xs):
return sorted(x * -3 for x in xs if 11 <= x <= 17)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة `between_times(xs)` تأخذ قائمة أعداد صحيحة وتُرجع قائمة مرتبة تصاعديًا تحتوي حاصل ضرب كل عنصر يقع بين 11 و17 (شاملًا الطرفين) في -3.
مثال: `between_times([8, 11, 10, 2, 6])` يجب أن تُرجع `[-33]`.
الجواب: | a27a629418a958c1 | null | null |
code | a11_code_gen | python | write_function | lists | w_running#0 | running_sum | def running_sum(xs):
out, s = [], 0
for x in xs:
s += x
if s > 80:
s = 0
out.append(s)
return out | [
"assert running_sum([32, 35, 15, 42, 3, 6, 23, 16, 16]) == [32, 67, 0, 42, 45, 51, 74, 0, 16]",
"assert running_sum([]) == []",
"assert running_sum([20, 21, 27, 67, 33, 67]) == [20, 41, 68, 0, 33, 0]",
"assert running_sum([34, 21, 64]) == [34, 55, 0]",
"assert running_sum([]) == []",
"assert running_sum([... | assert running_sum([32, 35, 15, 42, 3, 6, 23, 16, 16]) == [32, 67, 0, 42, 45, 51, 74, 0, 16]
assert running_sum([]) == []
assert running_sum([20, 21, 27, 67, 33, 67]) == [20, 41, 68, 0, 33, 0]
assert running_sum([34, 21, 64]) == [34, 55, 0]
assert running_sum([]) == []
assert running_sum([38, 63, -7, 69, 76]) == [38, 0... | def running_sum(xs):
out, s = [], 0
for x in xs:
s += x
if s > 80:
s = 0
out.append(s)
return out | ```python
def running_sum(xs):
out, s = [], 0
for x in xs:
s += x
if s > 80:
s = 0
out.append(s)
return out
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة `running_sum(xs)` تُرجع قائمة المجاميع التراكمية لعناصر xs، مع قاعدة: إذا أصبح المجموع الجاري أكبر من 80 بعد إضافة عنصر فإنه يُصفَّر قبل تسجيله.
مثال: `running_sum([32, 35, 15, 42, 3, 6, 23, 16, 16])` يجب أن تُرجع `[32, 67, 0, 42, 45, 51, 74, 0, 16]`.
الجواب: | 49ff19bcb8f96792 | null | null |
code | a11_code_gen | python | write_function | arabic_text | w_count_letter#1 | count_letter | def count_letter(text):
return text.count('ج') | [
"assert count_letter('قلم عربية قمر عمل طائرة مدينة سفينة علم') == 0",
"assert count_letter('سلام عمل سوق') == 0",
"assert count_letter('برمجة سفينة') == 1",
"assert count_letter('') == 0",
"assert count_letter('سوق سفينة معلم باب طائرة خبز حديقة بيت') == 0",
"assert count_letter('سيارة مكتبة بيت نهر طالب... | assert count_letter('قلم عربية قمر عمل طائرة مدينة سفينة علم') == 0
assert count_letter('سلام عمل سوق') == 0
assert count_letter('برمجة سفينة') == 1
assert count_letter('') == 0
assert count_letter('سوق سفينة معلم باب طائرة خبز حديقة بيت') == 0
assert count_letter('سيارة مكتبة بيت نهر طالب معلم') == 0
assert count_lett... | def count_letter(text):
return text.count('ج') | ```python
def count_letter(text):
return text.count('ج')
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ الدالة `count_letter(text)` بحيث تُعيد عدد مرات ظهور الحرف «ج» في النص، حيث text سلسلة نصية بالعربية.
للتوضيح: الاستدعاء `count_letter('قلم عربية قمر عمل طائرة مدينة سفينة علم')` يُرجع `0`.
الجواب: | 912e559f5e4d386d | null | null |
code | a11_code_gen | python | write_function | arabic_text | w_count_letter#1 | count_in_text | def count_in_text(text):
return sum(1 for w in text.split() if w.startswith('ح')) | [
"assert count_in_text('باب كتاب طالب قهوة نهر برتقال') == 0",
"assert count_in_text('سفينة قهوة نور سوق') == 0",
"assert count_in_text('قهوة حاسوب') == 1",
"assert count_in_text('سيارة شجرة سفينة سيارة ميناء جبل ماء شجرة') == 0",
"assert count_in_text('بحر صديق كتاب علم صحراء شجرة') == 0",
"assert count_i... | assert count_in_text('باب كتاب طالب قهوة نهر برتقال') == 0
assert count_in_text('سفينة قهوة نور سوق') == 0
assert count_in_text('قهوة حاسوب') == 1
assert count_in_text('سيارة شجرة سفينة سيارة ميناء جبل ماء شجرة') == 0
assert count_in_text('بحر صديق كتاب علم صحراء شجرة') == 0
assert count_in_text('') == 0
assert count_i... | def count_in_text(text):
return sum(1 for w in text.split() if w.startswith('ح')) | ```python
def count_in_text(text):
return sum(1 for w in text.split() if w.startswith('ح'))
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ الدالة `count_in_text(text)` بحيث تُعيد عدد الكلمات (المفصولة بمسافات) التي تبدأ بالحرف «ح»، حيث text سلسلة نصية بالعربية.
للتوضيح: الاستدعاء `count_in_text('باب كتاب طالب قهوة نهر برتقال')` يُرجع `0`.
الجواب: | 4ab52172273f5de8 | null | null |
code | a11_code_gen | python | write_function | math | w_poly#1 | p | def p(x):
return -6 * x ** 2 + (3) * x + (-4) | [
"assert p(9) == -463",
"assert p(-19) == -2227",
"assert p(14) == -1138",
"assert p(0) == -4",
"assert p(-5) == -169",
"assert p(3) == -49",
"assert p(7) == -277",
"assert p(0) == -4"
] | assert p(9) == -463
assert p(-19) == -2227
assert p(14) == -1138
assert p(0) == -4
assert p(-5) == -169
assert p(3) == -49
assert p(7) == -277
assert p(0) == -4 | def p(x):
return -6 * x ** 2 + (3) * x + (-4) | ```python
def p(x):
return -6 * x ** 2 + (3) * x + (-4)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ دالة `p(x)` تحسب المقدار -6x² + 3x - 4 لقيمة x المعطاة وتُرجع الناتج عددًا صحيحًا.
للتوضيح: الاستدعاء `p(9)` يُرجع `-463`.
الجواب: | 7261a3c33f13e155 | null | null |
code | a11_code_gen | python | write_function | math | w_poly#0 | poly | def poly(x):
return -8 * x ** 2 + (1) * x + (1) | [
"assert poly(8) == -503",
"assert poly(-10) == -809",
"assert poly(15) == -1784",
"assert poly(-10) == -809",
"assert poly(-11) == -978",
"assert poly(-5) == -204",
"assert poly(10) == -789",
"assert poly(0) == 1"
] | assert poly(8) == -503
assert poly(-10) == -809
assert poly(15) == -1784
assert poly(-10) == -809
assert poly(-11) == -978
assert poly(-5) == -204
assert poly(10) == -789
assert poly(0) == 1 | def poly(x):
return -8 * x ** 2 + (1) * x + (1) | ```python
def poly(x):
return -8 * x ** 2 + (1) * x + (1)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة بايثون `poly(x)` تُرجع قيمة كثيرة الحدود -8x² + 1x + 1 عند العدد الصحيح x.
مثال: `poly(8)` يجب أن تُرجع `-503`.
الجواب: | 0ea7501336e5bdd7 | null | null |
code | a11_code_gen | python | write_function | arabic_text | w_count_letter#0 | count_in_text | def count_in_text(text):
return text.count('و') | [
"assert count_in_text('سفينة كتاب صحراء بيت تفاحة صديق') == 0",
"assert count_in_text('شجرة برمجة ميناء مكتبة علم سفينة') == 0",
"assert count_in_text('ماء بحر خبز صديق مطر قهوة عربية') == 1",
"assert count_in_text('سماء سماء مدرسة جمل لغة') == 0",
"assert count_in_text('سوق بحر بيت') == 1",
"assert count... | assert count_in_text('سفينة كتاب صحراء بيت تفاحة صديق') == 0
assert count_in_text('شجرة برمجة ميناء مكتبة علم سفينة') == 0
assert count_in_text('ماء بحر خبز صديق مطر قهوة عربية') == 1
assert count_in_text('سماء سماء مدرسة جمل لغة') == 0
assert count_in_text('سوق بحر بيت') == 1
assert count_in_text('نهار قلم رمل قمر خبز... | def count_in_text(text):
return text.count('و') | ```python
def count_in_text(text):
return text.count('و')
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة بايثون `count_in_text(text)` تأخذ نصًا عربيًا وتُرجع عدد مرات ظهور الحرف «و» في النص.
مثال: `count_in_text('سفينة كتاب صحراء بيت تفاحة صديق')` يجب أن تُرجع `0`.
الجواب: | ab896bcd9e09f596 | null | null |
code | a11_code_gen | python | predict_output | recursion | p_rec#0 | null | null | null | null | 1 | الناتج:
```text
1
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
def f(n):
if n <= 2:
return 2
return 1 * f(n - 1) + -1
print(f(3))
```
الجواب: | 617ef90cdbcdb826 | def f(n):
if n <= 2:
return 2
return 1 * f(n - 1) + -1
print(f(3)) | null |
code | a11_code_gen | python | write_function | lists | w_filter_range#0 | in_range_scaled | def in_range_scaled(xs):
return sorted(x * -2 for x in xs if 18 <= x <= 41) | [
"assert in_range_scaled([19, 49, 18, 23, 31, 22]) == [-62, -46, -44, -38, -36]",
"assert in_range_scaled([43, 29, 2, 53, 39, 46, 50, 27]) == [-78, -58, -54]",
"assert in_range_scaled([-26, 7, -6, 46, 52, 17, 49]) == []",
"assert in_range_scaled([3, -12, 57, -4, 33, 6, -27]) == [-66]",
"assert in_range_scale... | assert in_range_scaled([19, 49, 18, 23, 31, 22]) == [-62, -46, -44, -38, -36]
assert in_range_scaled([43, 29, 2, 53, 39, 46, 50, 27]) == [-78, -58, -54]
assert in_range_scaled([-26, 7, -6, 46, 52, 17, 49]) == []
assert in_range_scaled([3, -12, 57, -4, 33, 6, -27]) == [-66]
assert in_range_scaled([35, 58, 46]) == [-70]
... | def in_range_scaled(xs):
return sorted(x * -2 for x in xs if 18 <= x <= 41) | ```python
def in_range_scaled(xs):
return sorted(x * -2 for x in xs if 18 <= x <= 41)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة `in_range_scaled(xs)` تأخذ قائمة أعداد صحيحة وتُرجع قائمة مرتبة تصاعديًا تحتوي حاصل ضرب كل عنصر يقع بين 18 و41 (شاملًا الطرفين) في -2.
مثال: `in_range_scaled([19, 49, 18, 23, 31, 22])` يجب أن تُرجع `[-62, -46, -44, -38, -36]`.
الجواب: | 9d7190bb0cd065c1 | null | null |
code | a11_code_gen | python | predict_output | for_loop | p_loop#1 | null | null | null | null | 116
9 | الناتج:
```text
116
9
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
acc = 20
for x in range(-3, 12, 4):
acc += x * 8
print(acc)
print(x)
```
الجواب: | 42b31c67a6e1920c | acc = 20
for x in range(-3, 12, 4):
acc += x * 8
print(acc)
print(x) | null |
code | a11_code_gen | python | complete_function | loops | c_count_div#1 | count_matching | def count_matching(xs):
count = 0
for x in xs:
if x % 5 == 0 and x % 6 != 0:
count += 1
return count | [
"assert count_matching([38, 43, 54, 69, 38, 86, 14, 39, 61, 43]) == 0",
"assert count_matching([86, -29, -29, 6, 53]) == 0",
"assert count_matching([81, -14]) == 0",
"assert count_matching([-18, -33, 56, 86]) == 0",
"assert count_matching([79, 0, 11]) == 0",
"assert count_matching([-29, 39, 36, 70, 11, -2... | assert count_matching([38, 43, 54, 69, 38, 86, 14, 39, 61, 43]) == 0
assert count_matching([86, -29, -29, 6, 53]) == 0
assert count_matching([81, -14]) == 0
assert count_matching([-18, -33, 56, 86]) == 0
assert count_matching([79, 0, 11]) == 0
assert count_matching([-29, 39, 36, 70, 11, -25, 18, -15, -22]) == 3
assert ... | def count_matching(xs):
count = 0
for x in xs:
if x % 5 == 0 and x % 6 != 0:
count += 1
return count | ```python
def count_matching(xs):
count = 0
for x in xs:
if x % 5 == 0 and x % 6 != 0:
count += 1
return count
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: في الدالة الآتية جزء ناقص مكتوب ____. املأه لكي تُرجع الدالة عدد عناصر xs التي تقبل القسمة على 5 ولا تقبل القسمة على 6، واكتب الدالة بعد إكمالها.
```python
def count_matching(xs):
count = 0
for x in xs:
if ____:
count += 1
return count
`... | 65d977f655cf4b18 | null | null |
code | a11_code_gen | python | predict_output | dict | p_dict#0 | null | null | null | null | 5
يوسف
168
[('خالد', 25), ('حسن', 26)] | الناتج:
```text
5
يوسف
168
[('خالد', 25), ('حسن', 26)]
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
points = {'خالد': 25, 'حسن': 26, 'سلمى': 28, 'علي': 31}
points['سلمى'] += 10
points['يوسف'] = 48
print(len(points))
print(max(points, key=points.get))
print(sum(points.values()))
print(sorted(points.items(), key=lambda kv: ... | c52eff4ec40380ec | points = {'خالد': 25, 'حسن': 26, 'سلمى': 28, 'علي': 31}
points['سلمى'] += 10
points['يوسف'] = 48
print(len(points))
print(max(points, key=points.get))
print(sum(points.values()))
print(sorted(points.items(), key=lambda kv: (kv[1], kv[0]))[:2]) | null |
code | a11_code_gen | python | predict_output | list_slicing | p_slice#1 | null | null | null | null | [3, 1, 38, 31]
[26, 38, 3]
4 | الناتج:
```text
[3, 1, 38, 31]
[26, 38, 3]
4
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
lst = [37, 3, 1, 38, 31, 26]
print(lst[1:5])
print(lst[::-2])
print(len(lst[1:5]))
```
الجواب: | 2b909645a1bfc19a | lst = [37, 3, 1, 38, 31, 26]
print(lst[1:5])
print(lst[::-2])
print(len(lst[1:5])) | null |
code | a11_code_gen | python | predict_output | list_comprehension | p_comp#1 | null | null | null | null | [0, 1]
2 1 | الناتج:
```text
[0, 1]
2 1
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
vals = [(x + 0) // 4 for x in range(-2, 7) if x % 4 == 0]
print(vals)
print(len(vals), sum(vals))
```
الجواب: | 974a28133a3d0331 | vals = [(x + 0) // 4 for x in range(-2, 7) if x % 4 == 0]
print(vals)
print(len(vals), sum(vals)) | null |
code | a11_code_gen | python | predict_output | while_loop | p_while#1 | null | null | null | null | 12 3 | الناتج:
```text
12 3
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
n = 4171
count = 0
while n > 16:
n = n // 7
count += 1
print(n, count)
```
الجواب: | 2972b993fd46a6c7 | n = 4171
count = 0
while n > 16:
n = n // 7
count += 1
print(n, count) | null |
code | a11_code_gen | python | write_function | loops | w_fizz#1 | label_numbers | def label_numbers(n):
out = []
for i in range(1, n + 1):
s = ''
if i % 2 == 0:
s += 'Red'
if i % 4 == 0:
s += 'Blue'
out.append(s or str(i))
return out | [
"assert label_numbers(8) == ['1', 'Red', '3', 'RedBlue', '5', 'Red', '7', 'RedBlue']",
"assert label_numbers(18) == ['1', 'Red', '3', 'RedBlue', '5', 'Red', '7', 'RedBlue', '9', 'Red', '11', 'RedBlue', '13', 'Red', '15', 'RedBlue', '17', 'Red']",
"assert label_numbers(1) == ['1']",
"assert label_numbers(5) ==... | assert label_numbers(8) == ['1', 'Red', '3', 'RedBlue', '5', 'Red', '7', 'RedBlue']
assert label_numbers(18) == ['1', 'Red', '3', 'RedBlue', '5', 'Red', '7', 'RedBlue', '9', 'Red', '11', 'RedBlue', '13', 'Red', '15', 'RedBlue', '17', 'Red']
assert label_numbers(1) == ['1']
assert label_numbers(5) == ['1', 'Red', '3', '... | def label_numbers(n):
out = []
for i in range(1, n + 1):
s = ''
if i % 2 == 0:
s += 'Red'
if i % 4 == 0:
s += 'Blue'
out.append(s or str(i))
return out | ```python
def label_numbers(n):
out = []
for i in range(1, n + 1):
s = ''
if i % 2 == 0:
s += 'Red'
if i % 4 == 0:
s += 'Blue'
out.append(s or str(i))
return out
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ دالة بايثون `label_numbers(n)` تبني قائمة لكل i من 1 إلى n: إن قَبِل i القسمة على 2 أضف 'Red'، وإن قَبِلها على 4 أضف 'Blue' (فيصبح 'RedBlue' عند الاثنين)، وإن لم يتحقق أيٌّ منهما ضع str(i).
للتوضيح: الاستدعاء `label_numbers(8)` يُرجع `['1', 'Red', '3', 'RedBlue', ... | 1a7924ec3abb8088 | null | null |
code | a11_code_gen | python | write_function | math | w_poly#1 | evaluate | def evaluate(x):
return -2 * x ** 2 + (4) * x + (-5) | [
"assert evaluate(10) == -165",
"assert evaluate(18) == -581",
"assert evaluate(-18) == -725",
"assert evaluate(-17) == -651",
"assert evaluate(-8) == -165",
"assert evaluate(-6) == -101",
"assert evaluate(-8) == -165",
"assert evaluate(0) == -5"
] | assert evaluate(10) == -165
assert evaluate(18) == -581
assert evaluate(-18) == -725
assert evaluate(-17) == -651
assert evaluate(-8) == -165
assert evaluate(-6) == -101
assert evaluate(-8) == -165
assert evaluate(0) == -5 | def evaluate(x):
return -2 * x ** 2 + (4) * x + (-5) | ```python
def evaluate(x):
return -2 * x ** 2 + (4) * x + (-5)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ دالة `evaluate(x)` تحسب المقدار -2x² + 4x - 5 لقيمة x المعطاة وتُرجع الناتج عددًا صحيحًا.
للتوضيح: الاستدعاء `evaluate(10)` يُرجع `-165`.
الجواب: | 81642708ecb57e9e | null | null |
code | a11_code_gen | python | write_function | loops | w_fizz#1 | fizz | def fizz(n):
out = []
for i in range(1, n + 1):
s = ''
if i % 6 == 0:
s += 'Tic'
if i % 10 == 0:
s += 'Tac'
out.append(s or str(i))
return out | [
"assert fizz(29) == ['1', '2', '3', '4', '5', 'Tic', '7', '8', '9', 'Tac', '11', 'Tic', '13', '14', '15', '16', '17', 'Tic', '19', 'Tac', '21', '22', '23', 'Tic', '25', '26', '27', '28', '29']",
"assert fizz(6) == ['1', '2', '3', '4', '5', 'Tic']",
"assert fizz(6) == ['1', '2', '3', '4', '5', 'Tic']",
"assert... | assert fizz(29) == ['1', '2', '3', '4', '5', 'Tic', '7', '8', '9', 'Tac', '11', 'Tic', '13', '14', '15', '16', '17', 'Tic', '19', 'Tac', '21', '22', '23', 'Tic', '25', '26', '27', '28', '29']
assert fizz(6) == ['1', '2', '3', '4', '5', 'Tic']
assert fizz(6) == ['1', '2', '3', '4', '5', 'Tic']
assert fizz(12) == ['1', '... | def fizz(n):
out = []
for i in range(1, n + 1):
s = ''
if i % 6 == 0:
s += 'Tic'
if i % 10 == 0:
s += 'Tac'
out.append(s or str(i))
return out | ```python
def fizz(n):
out = []
for i in range(1, n + 1):
s = ''
if i % 6 == 0:
s += 'Tic'
if i % 10 == 0:
s += 'Tac'
out.append(s or str(i))
return out
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ دالة بايثون `fizz(n)` تبني قائمة لكل i من 1 إلى n: إن قَبِل i القسمة على 6 أضف 'Tic'، وإن قَبِلها على 10 أضف 'Tac' (فيصبح 'TicTac' عند الاثنين)، وإن لم يتحقق أيٌّ منهما ضع str(i).
للتوضيح: الاستدعاء `fizz(29)` يُرجع `['1', '2', '3', '4', '5', 'Tic', '7', '8', '9',... | 9d5a9147bb5ef44c | null | null |
code | a11_code_gen | python | fix_bug | loops | f_power_sum#1 | power_sum | def power_sum(n):
total = 0
for i in range(1, n + 1):
total += 3 * i ** 2
return total | [
"assert power_sum(5) == 165",
"assert power_sum(6) == 273",
"assert power_sum(9) == 855",
"assert power_sum(12) == 1950",
"assert power_sum(10) == 1155",
"assert power_sum(1) == 3",
"assert power_sum(0) == 0"
] | assert power_sum(5) == 165
assert power_sum(6) == 273
assert power_sum(9) == 855
assert power_sum(12) == 1950
assert power_sum(10) == 1155
assert power_sum(1) == 3
assert power_sum(0) == 0 | def power_sum(n):
total = 0
for i in range(1, n + 1):
total += 3 * i ** 2
return total | ```python
def power_sum(n):
total = 0
for i in range(1, n + 1):
total += 3 * i ** 2
return total
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: في الشيفرة الآتية خطأ يجعل الدالة لا تعمل كما يجب. المطلوب منها أن تُرجع مجموع 3 × i^2 لكل عدد صحيح i من 1 إلى n (شاملًا n). اكتشف الخطأ وأعد كتابة الدالة بعد إصلاحه.
```python
def power_sum(n):
total = 0
for i in range(1, n + 1):
total = 3 * i ** 2
... | 22b6a31e10934529 | null | def power_sum(n):
total = 0
for i in range(1, n + 1):
total = 3 * i ** 2
return total |
code | a11_code_gen | python | predict_output | recursion | p_rec#1 | null | null | null | null | 45
9 | الناتج:
```text
45
9
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
def f(n):
if n < 10:
return n
return n % 10 + f(n // 10)
print(f(760959063))
print(f(f(760959063)))
```
الجواب: | c6a86bf4500f77af | def f(n):
if n < 10:
return n
return n % 10 + f(n // 10)
print(f(760959063))
print(f(f(760959063))) | null |
code | a11_code_gen | python | predict_output | strings | p_str#1 | null | null | null | null | BRAIN_WINTER
*rain_winter
Brain_winter | الناتج:
```text
BRAIN_WINTER
*rain_winter
Brain_winter
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
text = 'brain_winter'
print(text.upper())
print(text.replace('b', '*'))
print(text.capitalize())
```
الجواب: | c67919ef9fb772b4 | text = 'brain_winter'
print(text.upper())
print(text.replace('b', '*'))
print(text.capitalize()) | null |
code | a11_code_gen | python | fix_bug | lists | f_max_div#0 | best_multiple | def best_multiple(values):
best = None
for x in values:
if x % 3 == 0 and (best is None or x > best):
best = x
return best | [
"assert best_multiple([-27, -4, 18, 36, -17, 28]) == 36",
"assert best_multiple([-6, -15, -6]) == -6",
"assert best_multiple([1]) == None",
"assert best_multiple([10, -2, -26, -22, 8, -33]) == -33",
"assert best_multiple([-36, 13, 45, -21]) == 45",
"assert best_multiple([]) == None"
] | assert best_multiple([-27, -4, 18, 36, -17, 28]) == 36
assert best_multiple([-6, -15, -6]) == -6
assert best_multiple([1]) == None
assert best_multiple([10, -2, -26, -22, 8, -33]) == -33
assert best_multiple([-36, 13, 45, -21]) == 45
assert best_multiple([]) == None | def best_multiple(values):
best = None
for x in values:
if x % 3 == 0 and (best is None or x > best):
best = x
return best | ```python
def best_multiple(values):
best = None
for x in values:
if x % 3 == 0 and (best is None or x > best):
best = x
return best
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: الدالة التالية يُفترض أن تُرجع أكبر عنصر في القائمة values يقبل القسمة على 3، أو None إذا لم يوجد مثل هذا العنصر، لكنها تحتوي على خطأ برمجي. أصلح الخطأ واكتب الدالة الصحيحة كاملة.
```python
def best_multiple(values):
best = None
for x in values:
if x % ... | 8fa726e7615fad6c | null | def best_multiple(values):
best = None
for x in values:
if x % 3 == 0 and (best is None or x < best):
best = x
return best |
code | a11_code_gen | python | fix_bug | lists | f_max_div#0 | biggest_mult | def biggest_mult(xs):
best = None
for x in xs:
if x % 11 == 0 and (best is None or x > best):
best = x
return best | [
"assert biggest_mult([25, 49, 5, 23, -20]) == None",
"assert biggest_mult([-55, -44, -44]) == -44",
"assert biggest_mult([1, 12, 23]) == None",
"assert biggest_mult([23]) == None",
"assert biggest_mult([3, 32, 2, -7, -14, 23, 36, 28]) == None",
"assert biggest_mult([]) == None"
] | assert biggest_mult([25, 49, 5, 23, -20]) == None
assert biggest_mult([-55, -44, -44]) == -44
assert biggest_mult([1, 12, 23]) == None
assert biggest_mult([23]) == None
assert biggest_mult([3, 32, 2, -7, -14, 23, 36, 28]) == None
assert biggest_mult([]) == None | def biggest_mult(xs):
best = None
for x in xs:
if x % 11 == 0 and (best is None or x > best):
best = x
return best | ```python
def biggest_mult(xs):
best = None
for x in xs:
if x % 11 == 0 and (best is None or x > best):
best = x
return best
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: الدالة التالية يُفترض أن تُرجع أكبر عنصر في القائمة xs يقبل القسمة على 11، أو None إذا لم يوجد مثل هذا العنصر، لكنها تحتوي على خطأ برمجي. أصلح الخطأ واكتب الدالة الصحيحة كاملة.
```python
def biggest_mult(xs):
best = 0
for x in xs:
if x % 11 == 0 and (be... | e8fb0d18b35550b4 | null | def biggest_mult(xs):
best = 0
for x in xs:
if x % 11 == 0 and (best is None or x > best):
best = x
return best |
code | a11_code_gen | python | write_function | strings | w_reverse_words#0 | words_reversed | def words_reversed(s):
return ','.join([w for w in s.split() if len(w) >= 6][::-1]) | [
"assert words_reversed('of coffee cloud on orange it') == 'orange,coffee'",
"assert words_reversed('pixel winter data python by it') == 'python,winter'",
"assert words_reversed('vector in') == 'vector'",
"assert words_reversed('is') == ''",
"assert words_reversed('') == ''",
"assert words_reversed('') == ... | assert words_reversed('of coffee cloud on orange it') == 'orange,coffee'
assert words_reversed('pixel winter data python by it') == 'python,winter'
assert words_reversed('vector in') == 'vector'
assert words_reversed('is') == ''
assert words_reversed('') == ''
assert words_reversed('') == ''
assert words_reversed('oran... | def words_reversed(s):
return ','.join([w for w in s.split() if len(w) >= 6][::-1]) | ```python
def words_reversed(s):
return ','.join([w for w in s.split() if len(w) >= 6][::-1])
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة `words_reversed(s)` تأخذ جملة وتُرجع الكلمات التي طولها 6 أحرف أو أكثر بترتيب معكوس، مفصولًا بينها بالفاصل ','.
مثال: `words_reversed('of coffee cloud on orange it')` يجب أن تُرجع `'orange,coffee'`.
الجواب: | 8c35d0ac506924aa | null | null |
code | a11_code_gen | python | predict_output | list_comprehension | p_comp#0 | null | null | null | null | [3]
1 3 | الناتج:
```text
[3]
1 3
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
res = [x * 0 + 3 for x in range(3, 8) if x % 5 == 3]
print(res)
print(len(res), sum(res))
```
الجواب: | 59b68000f968fba5 | res = [x * 0 + 3 for x in range(3, 8) if x % 5 == 3]
print(res)
print(len(res), sum(res)) | null |
code | a11_code_gen | python | write_function | arabic_text | w_count_letter#0 | letter_count | def letter_count(text):
return sum(1 for w in text.split() if 'ش' in w) | [
"assert letter_count('ليل سفينة بحر') == 0",
"assert letter_count('معلم مدينة جمل قهوة حصان') == 0",
"assert letter_count('رمل لغة بيت تفاحة مطر') == 0",
"assert letter_count('حصان حاسوب باب نهر نهر طائرة نور ماء') == 0",
"assert letter_count('بيت شجرة باب جمل كتاب') == 1",
"assert letter_count('') == 0",... | assert letter_count('ليل سفينة بحر') == 0
assert letter_count('معلم مدينة جمل قهوة حصان') == 0
assert letter_count('رمل لغة بيت تفاحة مطر') == 0
assert letter_count('حصان حاسوب باب نهر نهر طائرة نور ماء') == 0
assert letter_count('بيت شجرة باب جمل كتاب') == 1
assert letter_count('') == 0
assert letter_count('بحر برتقال... | def letter_count(text):
return sum(1 for w in text.split() if 'ش' in w) | ```python
def letter_count(text):
return sum(1 for w in text.split() if 'ش' in w)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة بايثون `letter_count(text)` تأخذ نصًا عربيًا وتُرجع عدد الكلمات (المفصولة بمسافات) التي تحتوي على الحرف «ش» مرة واحدة على الأقل.
مثال: `letter_count('ليل سفينة بحر')` يجب أن تُرجع `0`.
الجواب: | 2612440a7008fa0a | null | null |
code | a11_code_gen | python | write_function | lists | w_filter_range#1 | in_range_scaled | def in_range_scaled(xs):
return sorted(x * 3 for x in xs if -7 <= x <= 7) | [
"assert in_range_scaled([-11, -2, 12, -15, 9, -16, 9]) == [-6]",
"assert in_range_scaled([21, -25, 5, -18, 10]) == [15]",
"assert in_range_scaled([9, 57, 53, 18]) == []",
"assert in_range_scaled([9, -5, 9, 8, 1, 47, -10, -20, -4, 21]) == [-15, -12, 3]",
"assert in_range_scaled([13, -27, 53, -21, 41, 47, -5,... | assert in_range_scaled([-11, -2, 12, -15, 9, -16, 9]) == [-6]
assert in_range_scaled([21, -25, 5, -18, 10]) == [15]
assert in_range_scaled([9, 57, 53, 18]) == []
assert in_range_scaled([9, -5, 9, 8, 1, 47, -10, -20, -4, 21]) == [-15, -12, 3]
assert in_range_scaled([13, -27, 53, -21, 41, 47, -5, 17, 44]) == [-15]
assert... | def in_range_scaled(xs):
return sorted(x * 3 for x in xs if -7 <= x <= 7) | ```python
def in_range_scaled(xs):
return sorted(x * 3 for x in xs if -7 <= x <= 7)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ دالة بايثون `in_range_scaled(xs)`: اختر من القائمة xs العناصر x التي تحقق -7 ≤ x ≤ 7، اضرب كلًا منها في 3، ثم أعِد النتائج مرتبة تصاعديًا.
للتوضيح: الاستدعاء `in_range_scaled([-11, -2, 12, -15, 9, -16, 9])` يُرجع `[-6]`.
الجواب: | ca7842e24b7e5b15 | null | null |
code | a11_code_gen | python | fix_bug | arabic_text | f_starts_with#0 | prefix_hits | def prefix_hits(text):
count = 0
for w in text.split():
if w.startswith('ك'):
count += 1
return count | [
"assert prefix_hits('رمل ميناء شمس سوق كتاب كتاب مكتبة') == 2",
"assert prefix_hits('وردة ليل حاسوب') == 0",
"assert prefix_hits('كتاب مكتبة برمجة بحر حاسوب قلم') == 1",
"assert prefix_hits('كتاب برمجة لغة سوق تفاحة') == 1",
"assert prefix_hits('جبل سيارة جمل') == 0",
"assert prefix_hits('جبل مطر دفتر صدي... | assert prefix_hits('رمل ميناء شمس سوق كتاب كتاب مكتبة') == 2
assert prefix_hits('وردة ليل حاسوب') == 0
assert prefix_hits('كتاب مكتبة برمجة بحر حاسوب قلم') == 1
assert prefix_hits('كتاب برمجة لغة سوق تفاحة') == 1
assert prefix_hits('جبل سيارة جمل') == 0
assert prefix_hits('جبل مطر دفتر صديق') == 0
assert prefix_hits(''... | def prefix_hits(text):
count = 0
for w in text.split():
if w.startswith('ك'):
count += 1
return count | ```python
def prefix_hits(text):
count = 0
for w in text.split():
if w.startswith('ك'):
count += 1
return count
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: الدالة التالية يُفترض أن تُرجع عدد الكلمات (المفصولة بمسافات) في النص العربي text التي تبدأ بالحرف «ك»، لكنها تحتوي على خطأ برمجي. أصلح الخطأ واكتب الدالة الصحيحة كاملة.
```python
def prefix_hits(text):
count = 0
for w in text.split():
if w.endswith('ك'... | fb13f18bfbb241b8 | null | def prefix_hits(text):
count = 0
for w in text.split():
if w.endswith('ك'):
count += 1
return count |
code | a11_code_gen | python | fix_bug | arabic_text | f_starts_with#0 | words_starting | def words_starting(sentence):
count = 0
for w in sentence.split():
if w.startswith('ب'):
count += 1
return count | [
"assert words_starting('نهار رمل نور باب فجر عمل') == 1",
"assert words_starting('عربية تفاحة برمجة معلم') == 1",
"assert words_starting('مطر بيت مدرسة صحراء خبز نهر') == 1",
"assert words_starting('مطر برتقال جمل مدرسة باب تفاحة سفينة') == 2",
"assert words_starting('سلام كتاب') == 0",
"assert words_star... | assert words_starting('نهار رمل نور باب فجر عمل') == 1
assert words_starting('عربية تفاحة برمجة معلم') == 1
assert words_starting('مطر بيت مدرسة صحراء خبز نهر') == 1
assert words_starting('مطر برتقال جمل مدرسة باب تفاحة سفينة') == 2
assert words_starting('سلام كتاب') == 0
assert words_starting('قلم لغة مكتبة') == 0
ass... | def words_starting(sentence):
count = 0
for w in sentence.split():
if w.startswith('ب'):
count += 1
return count | ```python
def words_starting(sentence):
count = 0
for w in sentence.split():
if w.startswith('ب'):
count += 1
return count
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: الدالة التالية يُفترض أن تُرجع عدد الكلمات (المفصولة بمسافات) في النص العربي sentence التي تبدأ بالحرف «ب»، لكنها تحتوي على خطأ برمجي. أصلح الخطأ واكتب الدالة الصحيحة كاملة.
```python
def words_starting(sentence):
count = 0
for w in sentence.split():
if... | 6ad4f2542f5c834f | null | def words_starting(sentence):
count = 0
for w in sentence.split():
if w.endswith('ب'):
count += 1
return count |
code | a11_code_gen | python | predict_output | list_slicing | p_slice#0 | null | null | null | null | [17, 18]
[28, 17]
17 | الناتج:
```text
[17, 18]
[28, 17]
17
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
xs = [28, 28, 30, 17, 18, 25]
print(xs[3:5])
print(xs[::3])
print(min(xs[3:5]))
```
الجواب: | 39f234defa4c74db | xs = [28, 28, 30, 17, 18, 25]
print(xs[3:5])
print(xs[::3])
print(min(xs[3:5])) | null |
code | a11_code_gen | python | predict_output | recursion | p_rec#1 | null | null | null | null | 444 | الناتج:
```text
444
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
def rec(n):
if n <= 0:
return 3
return 2 * rec(n - 1) + 4
print(rec(6))
```
الجواب: | ebcc7f573d38e8a9 | def rec(n):
if n <= 0:
return 3
return 2 * rec(n - 1) + 4
print(rec(6)) | null |
code | a11_code_gen | python | predict_output | list_comprehension | p_comp#0 | null | null | null | null | [-3, -3, 29]
3 23 | الناتج:
```text
[-3, -3, 29]
3 23
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
out = [x ** 2 - 7 for x in range(-4, 8) if x % 4 == 2]
print(out)
print(len(out), sum(out))
```
الجواب: | 827a2b654046244c | out = [x ** 2 - 7 for x in range(-4, 8) if x % 4 == 2]
print(out)
print(len(out), sum(out)) | null |
code | a11_code_gen | python | predict_output | sorting | p_sort#1 | null | null | null | null | ['code', 'table', 'river', 'planet', 'window']
['window', 'planet', 'table'] | الناتج:
```text
['code', 'table', 'river', 'planet', 'window']
['window', 'planet', 'table']
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
words = ['table', 'river', 'code', 'planet', 'window']
print(sorted(words, key=len))
print(sorted(words, key=lambda w: (len(w), w), reverse=True)[:3])
```
الجواب: | fc355cc3da01670c | words = ['table', 'river', 'code', 'planet', 'window']
print(sorted(words, key=len))
print(sorted(words, key=lambda w: (len(w), w), reverse=True)[:3]) | null |
code | a11_code_gen | python | predict_output | strings | p_str#0 | null | null | null | null | 1
tresed
7 | الناتج:
```text
1
tresed
7
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
text = 'desert'
print(text.find('e'))
print(text[::-1])
print(text.index('e') + len(text))
```
الجواب: | be6feeb52cb42a1a | text = 'desert'
print(text.find('e'))
print(text[::-1])
print(text.index('e') + len(text)) | null |
code | a11_code_gen | python | predict_output | arabic_text | p_arabic#0 | null | null | null | null | ليل
False
0 | الناتج:
```text
ليل
False
0
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
s = 'ليل'
print(s.replace(' ', '-'))
print('ب' in s)
print(s.count('ب'))
```
الجواب: | 05e89456dfa0a085 | s = 'ليل'
print(s.replace(' ', '-'))
print('ب' in s)
print(s.count('ب')) | null |
code | a11_code_gen | python | write_function | math | w_coprime#0 | count_coprime | def count_coprime(n):
from math import gcd
return sum(1 for i in range(1, n + 1) if gcd(i, 54) == 1) | [
"assert count_coprime(25) == 9",
"assert count_coprime(130) == 43",
"assert count_coprime(156) == 52",
"assert count_coprime(159) == 53",
"assert count_coprime(80) == 27",
"assert count_coprime(89) == 30",
"assert count_coprime(1) == 1"
] | assert count_coprime(25) == 9
assert count_coprime(130) == 43
assert count_coprime(156) == 52
assert count_coprime(159) == 53
assert count_coprime(80) == 27
assert count_coprime(89) == 30
assert count_coprime(1) == 1 | def count_coprime(n):
from math import gcd
return sum(1 for i in range(1, n + 1) if gcd(i, 54) == 1) | ```python
def count_coprime(n):
from math import gcd
return sum(1 for i in range(1, n + 1) if gcd(i, 54) == 1)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة `count_coprime(n)` تُرجع عدد الأعداد الصحيحة i في المدى من 1 إلى n (شاملًا) التي تكون أولية نسبيًا مع 54، أي أن القاسم المشترك الأكبر لها مع 54 يساوي 1.
مثال: `count_coprime(25)` يجب أن تُرجع `9`.
الجواب: | a1b51c9f4548bdde | null | null |
code | a11_code_gen | python | write_function | math | w_poly#0 | evaluate | def evaluate(x):
return -8 * x ** 2 + (6) * x + (4) | [
"assert evaluate(5) == -166",
"assert evaluate(-7) == -430",
"assert evaluate(-4) == -148",
"assert evaluate(-20) == -3316",
"assert evaluate(4) == -100",
"assert evaluate(1) == 2",
"assert evaluate(2) == -16",
"assert evaluate(0) == 4"
] | assert evaluate(5) == -166
assert evaluate(-7) == -430
assert evaluate(-4) == -148
assert evaluate(-20) == -3316
assert evaluate(4) == -100
assert evaluate(1) == 2
assert evaluate(2) == -16
assert evaluate(0) == 4 | def evaluate(x):
return -8 * x ** 2 + (6) * x + (4) | ```python
def evaluate(x):
return -8 * x ** 2 + (6) * x + (4)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة بايثون `evaluate(x)` تُرجع قيمة كثيرة الحدود -8x² + 6x + 4 عند العدد الصحيح x.
مثال: `evaluate(5)` يجب أن تُرجع `-166`.
الجواب: | 1c59f1e92619b6ea | null | null |
code | a11_code_gen | python | write_function | math | w_digit_pow#1 | sum_digit_pow | def sum_digit_pow(n):
return sum(int(d) ** 3 for d in str(n)) % 6 | [
"assert sum_digit_pow(2607) == 3",
"assert sum_digit_pow(910927) == 4",
"assert sum_digit_pow(416772) == 3",
"assert sum_digit_pow(224842) == 4",
"assert sum_digit_pow(209179) == 4",
"assert sum_digit_pow(98986) == 4",
"assert sum_digit_pow(124464) == 3",
"assert sum_digit_pow(0) == 0"
] | assert sum_digit_pow(2607) == 3
assert sum_digit_pow(910927) == 4
assert sum_digit_pow(416772) == 3
assert sum_digit_pow(224842) == 4
assert sum_digit_pow(209179) == 4
assert sum_digit_pow(98986) == 4
assert sum_digit_pow(124464) == 3
assert sum_digit_pow(0) == 0 | def sum_digit_pow(n):
return sum(int(d) ** 3 for d in str(n)) % 6 | ```python
def sum_digit_pow(n):
return sum(int(d) ** 3 for d in str(n)) % 6
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ دالة بايثون `sum_digit_pow(n)`: ارفع كل رقم من أرقام n للقوة 3، اجمع النتائج، ثم أعِد باقي قسمة المجموع على 6.
للتوضيح: الاستدعاء `sum_digit_pow(2607)` يُرجع `3`.
الجواب: | 0b41269a48d88cd1 | null | null |
code | a11_code_gen | python | predict_output | list_comprehension | p_comp#1 | null | null | null | null | [1, 2, 3]
3 6 | الناتج:
```text
[1, 2, 3]
3 6
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
res = [(x + 8) // 4 for x in range(-1, 9) if x % 4 == 3]
print(res)
print(len(res), sum(res))
```
الجواب: | 06a6944ffadf5fc3 | res = [(x + 8) // 4 for x in range(-1, 9) if x % 4 == 3]
print(res)
print(len(res), sum(res)) | null |
code | a11_code_gen | python | write_function | math | w_coprime#1 | phi_upto | def phi_upto(n):
from math import gcd
return sum(1 for i in range(1, n + 1) if gcd(i, 77) == 1) | [
"assert phi_upto(136) == 106",
"assert phi_upto(41) == 33",
"assert phi_upto(101) == 79",
"assert phi_upto(189) == 147",
"assert phi_upto(117) == 92",
"assert phi_upto(11) == 9",
"assert phi_upto(1) == 1"
] | assert phi_upto(136) == 106
assert phi_upto(41) == 33
assert phi_upto(101) == 79
assert phi_upto(189) == 147
assert phi_upto(117) == 92
assert phi_upto(11) == 9
assert phi_upto(1) == 1 | def phi_upto(n):
from math import gcd
return sum(1 for i in range(1, n + 1) if gcd(i, 77) == 1) | ```python
def phi_upto(n):
from math import gcd
return sum(1 for i in range(1, n + 1) if gcd(i, 77) == 1)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ دالة بايثون `phi_upto(n)` تعدّ قيم i حيث 1 ≤ i ≤ n و gcd(i, 77) = 1، ثم تُرجع العدد.
للتوضيح: الاستدعاء `phi_upto(136)` يُرجع `106`.
الجواب: | 842fce5f432a0bed | null | null |
code | a11_code_gen | python | predict_output | arabic_text | p_arabic#1 | null | null | null | null | م
0
5 | الناتج:
```text
م
0
5
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
kalima = 'مدينة'
print(kalima[0])
print(kalima.find('م'))
print(len(kalima))
```
الجواب: | 405974df91f53b52 | kalima = 'مدينة'
print(kalima[0])
print(kalima.find('م'))
print(len(kalima)) | null |
code | a11_code_gen | python | write_function | arabic_text | w_count_letter#1 | how_many | def how_many(text):
return sum(1 for w in text.split() if w.startswith('س')) | [
"assert how_many('حديقة رمل سوق جبل') == 1",
"assert how_many('') == 0",
"assert how_many('قمر شجرة ماء') == 0",
"assert how_many('حاسوب حاسوب قلم') == 0",
"assert how_many('عربية برتقال طائرة معلم قمر') == 0",
"assert how_many('مدينة معلم كتاب ليل شمس') == 0",
"assert how_many('حاسوب برمجة كتاب مدرسة ل... | assert how_many('حديقة رمل سوق جبل') == 1
assert how_many('') == 0
assert how_many('قمر شجرة ماء') == 0
assert how_many('حاسوب حاسوب قلم') == 0
assert how_many('عربية برتقال طائرة معلم قمر') == 0
assert how_many('مدينة معلم كتاب ليل شمس') == 0
assert how_many('حاسوب برمجة كتاب مدرسة لغة دفتر شمس تفاحة') == 0
assert how... | def how_many(text):
return sum(1 for w in text.split() if w.startswith('س')) | ```python
def how_many(text):
return sum(1 for w in text.split() if w.startswith('س'))
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ الدالة `how_many(text)` بحيث تُعيد عدد الكلمات (المفصولة بمسافات) التي تبدأ بالحرف «س»، حيث text سلسلة نصية بالعربية.
للتوضيح: الاستدعاء `how_many('حديقة رمل سوق جبل')` يُرجع `1`.
الجواب: | 4d13eb74acec2320 | null | null |
code | a11_code_gen | python | predict_output | recursion | p_rec#0 | null | null | null | null | 843 | الناتج:
```text
843
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
def calc(n):
if n < 2:
return n + 3
return calc(n - 1) + calc(n - 2)
print(calc(12))
```
الجواب: | f860416744499630 | def calc(n):
if n < 2:
return n + 3
return calc(n - 1) + calc(n - 2)
print(calc(12)) | null |
code | a11_code_gen | python | predict_output | list_comprehension | p_comp#0 | null | null | null | null | [13, 61]
2 74 | الناتج:
```text
[13, 61]
2 74
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
vals = [x ** 2 - 3 for x in range(3, 9) if x % 4 == 0]
print(vals)
print(len(vals), sum(vals))
```
الجواب: | db12ec4b324ed8cc | vals = [x ** 2 - 3 for x in range(3, 9) if x % 4 == 0]
print(vals)
print(len(vals), sum(vals)) | null |
code | a11_code_gen | python | predict_output | for_loop | p_loop#1 | null | null | null | null | -279
18 | الناتج:
```text
-279
18
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
total = 9
for i in range(-2, 21, 4):
total -= i * 6
print(total)
print(i)
```
الجواب: | 3582c9ac0810bbae | total = 9
for i in range(-2, 21, 4):
total -= i * 6
print(total)
print(i) | null |
code | a11_code_gen | python | write_function | dict | w_char_freq#1 | char_counts | def char_counts(s):
return {c: s.count(c) for c in 'dm'} | [
"assert char_counts('falcon we signal planet light window') == {'d': 1, 'm': 0}",
"assert char_counts('matrix matrix') == {'d': 0, 'm': 2}",
"assert char_counts('table apple') == {'d': 0, 'm': 0}",
"assert char_counts('stone table table rocket coffee river') == {'d': 0, 'm': 0}",
"assert char_counts('up roc... | assert char_counts('falcon we signal planet light window') == {'d': 1, 'm': 0}
assert char_counts('matrix matrix') == {'d': 0, 'm': 2}
assert char_counts('table apple') == {'d': 0, 'm': 0}
assert char_counts('stone table table rocket coffee river') == {'d': 0, 'm': 0}
assert char_counts('up rocket') == {'d': 0, 'm': 0}... | def char_counts(s):
return {c: s.count(c) for c in 'dm'} | ```python
def char_counts(s):
return {c: s.count(c) for c in 'dm'}
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ دالة بايثون `char_counts(s)` تعيد dict يربط كل محرف من المحارف 'd'، 'm' بعدد تكراره في s، مع إدراج المحارف غير الموجودة بقيمة 0.
للتوضيح: الاستدعاء `char_counts('falcon we signal planet light window')` يُرجع `{'d': 1, 'm': 0}`.
الجواب: | ce2397c42f593ac6 | null | null |
code | a11_code_gen | python | write_function | arabic_text | w_count_letter#1 | letter_count | def letter_count(text):
return sum(1 for w in text.split() if w.startswith('ف')) | [
"assert letter_count('طالب بيت سوق حصان') == 0",
"assert letter_count('') == 0",
"assert letter_count('رمل ميناء بيت صديق جبل') == 0",
"assert letter_count('برتقال كتاب تفاحة صديق') == 0",
"assert letter_count('قلم مدرسة برمجة تفاحة ميناء مطر مدينة نهر') == 0",
"assert letter_count('برتقال مدينة علم باب ب... | assert letter_count('طالب بيت سوق حصان') == 0
assert letter_count('') == 0
assert letter_count('رمل ميناء بيت صديق جبل') == 0
assert letter_count('برتقال كتاب تفاحة صديق') == 0
assert letter_count('قلم مدرسة برمجة تفاحة ميناء مطر مدينة نهر') == 0
assert letter_count('برتقال مدينة علم باب بيت') == 0
assert letter_count(... | def letter_count(text):
return sum(1 for w in text.split() if w.startswith('ف')) | ```python
def letter_count(text):
return sum(1 for w in text.split() if w.startswith('ف'))
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ الدالة `letter_count(text)` بحيث تُعيد عدد الكلمات (المفصولة بمسافات) التي تبدأ بالحرف «ف»، حيث text سلسلة نصية بالعربية.
للتوضيح: الاستدعاء `letter_count('طالب بيت سوق حصان')` يُرجع `0`.
الجواب: | eaa410b1a413fa0a | null | null |
code | a11_code_gen | python | fix_bug | arabic_text | f_starts_with#1 | count_prefix | def count_prefix(line):
count = 0
for w in line.split():
if w.startswith('ل'):
count += 1
return count | [
"assert count_prefix('سوق مكتبة سلام') == 0",
"assert count_prefix('نهار لغة ليل طائرة نهر') == 2",
"assert count_prefix('سيارة ليل نهار نهر لغة برمجة علم') == 2",
"assert count_prefix('ماء بيت لغة فجر خبز وردة لغة برمجة') == 2",
"assert count_prefix('قهوة قهوة مطر شجرة نهار فجر ليل ليل') == 2",
"assert c... | assert count_prefix('سوق مكتبة سلام') == 0
assert count_prefix('نهار لغة ليل طائرة نهر') == 2
assert count_prefix('سيارة ليل نهار نهر لغة برمجة علم') == 2
assert count_prefix('ماء بيت لغة فجر خبز وردة لغة برمجة') == 2
assert count_prefix('قهوة قهوة مطر شجرة نهار فجر ليل ليل') == 2
assert count_prefix('ليل تفاحة نور نها... | def count_prefix(line):
count = 0
for w in line.split():
if w.startswith('ل'):
count += 1
return count | ```python
def count_prefix(line):
count = 0
for w in line.split():
if w.startswith('ل'):
count += 1
return count
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: في الشيفرة الآتية خطأ يجعل الدالة لا تعمل كما يجب. المطلوب منها أن تُرجع عدد الكلمات (المفصولة بمسافات) في النص العربي line التي تبدأ بالحرف «ل». اكتشف الخطأ وأعد كتابة الدالة بعد إصلاحه.
```python
def count_prefix(line):
count = 0
for w in line.split():
... | 29248261c733d9c7 | null | def count_prefix(line):
count = 0
for w in line.split():
if 'ل' in w:
count += 1
return count |
code | a11_code_gen | python | complete_function | lists | c_rotate#0 | rotate_by | def rotate_by(arr):
if not arr:
return []
k = 7 % len(arr)
return arr[k:] + arr[:k] | [
"assert rotate_by([4, 25, 8, 3]) == [3, 4, 25, 8]",
"assert rotate_by([30, 38, -8, -8, 31]) == [-8, -8, 31, 30, 38]",
"assert rotate_by([-8, 9, 47, 46, -6, 43, 7, 23, -2, 25, 18]) == [23, -2, 25, 18, -8, 9, 47, 46, -6, 43, 7]",
"assert rotate_by([50]) == [50]",
"assert rotate_by([41, -2, 15, 49, -9, 43, -2,... | assert rotate_by([4, 25, 8, 3]) == [3, 4, 25, 8]
assert rotate_by([30, 38, -8, -8, 31]) == [-8, -8, 31, 30, 38]
assert rotate_by([-8, 9, 47, 46, -6, 43, 7, 23, -2, 25, 18]) == [23, -2, 25, 18, -8, 9, 47, 46, -6, 43, 7]
assert rotate_by([50]) == [50]
assert rotate_by([41, -2, 15, 49, -9, 43, -2, 46, 50, 31, 22, 22]) == ... | def rotate_by(arr):
if not arr:
return []
k = 7 % len(arr)
return arr[k:] + arr[:k] | ```python
def rotate_by(arr):
if not arr:
return []
k = 7 % len(arr)
return arr[k:] + arr[:k]
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أكمل الدالة التالية بوضع التعبير المناسب مكان ____ بحيث تُرجع الدالة القائمة بعد تدويرها 7 مواقع إلى اليسار (العنصر الأول ينتقل إلى النهاية في كل خطوة)، ثم اكتب الدالة كاملة.
```python
def rotate_by(arr):
if not arr:
return []
k = 7 % len(arr)
retur... | 7999b86dcb4c70fb | null | null |
code | a11_code_gen | python | predict_output | list_slicing | p_slice#0 | null | null | null | null | [7, 40, 24, 33]
[16, 10, -6, 33, 24, 40, 7, 11]
104 | الناتج:
```text
[7, 40, 24, 33]
[16, 10, -6, 33, 24, 40, 7, 11]
104
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
a = [11, 7, 40, 24, 33, -6, 10, 16]
print(a[1:5])
print(a[::-1])
print(sum(a[1:5]))
```
الجواب: | e46d4c71a3310833 | a = [11, 7, 40, 24, 33, -6, 10, 16]
print(a[1:5])
print(a[::-1])
print(sum(a[1:5])) | null |
code | a11_code_gen | python | predict_output | list_slicing | p_slice#0 | null | null | null | null | [15, 38, 35, 28, 20]
[20, 19, 20, 28, 35, 38, 15]
38 | الناتج:
```text
[15, 38, 35, 28, 20]
[20, 19, 20, 28, 35, 38, 15]
38
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
items = [15, 38, 35, 28, 20, 19, 20]
print(items[0:5])
print(items[::-1])
print(max(items[0:5]))
```
الجواب: | 12f653b24a4d0722 | items = [15, 38, 35, 28, 20, 19, 20]
print(items[0:5])
print(items[::-1])
print(max(items[0:5])) | null |
code | a11_code_gen | python | write_function | lists | w_running#0 | acc_reset | def acc_reset(xs):
out, s = [], 0
for x in xs:
s += x
if s > 14:
s = 0
out.append(s)
return out | [
"assert acc_reset([4, 7, 1, 9, 9, 5, 1]) == [4, 11, 12, 0, 9, 14, 0]",
"assert acc_reset([]) == []",
"assert acc_reset([14, -10, 12, -9, -10, 6, 8]) == [14, 4, 0, -9, -19, -13, -5]",
"assert acc_reset([-6, 12, -2, 2, 0, -4, -2, 0]) == [-6, 6, 4, 6, 6, 2, 0, 0]",
"assert acc_reset([1, 8, -10, 1, 9, 2, 3]) ==... | assert acc_reset([4, 7, 1, 9, 9, 5, 1]) == [4, 11, 12, 0, 9, 14, 0]
assert acc_reset([]) == []
assert acc_reset([14, -10, 12, -9, -10, 6, 8]) == [14, 4, 0, -9, -19, -13, -5]
assert acc_reset([-6, 12, -2, 2, 0, -4, -2, 0]) == [-6, 6, 4, 6, 6, 2, 0, 0]
assert acc_reset([1, 8, -10, 1, 9, 2, 3]) == [1, 9, -1, 0, 9, 11, 14]... | def acc_reset(xs):
out, s = [], 0
for x in xs:
s += x
if s > 14:
s = 0
out.append(s)
return out | ```python
def acc_reset(xs):
out, s = [], 0
for x in xs:
s += x
if s > 14:
s = 0
out.append(s)
return out
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة `acc_reset(xs)` تُرجع قائمة المجاميع التراكمية لعناصر xs، مع قاعدة: إذا أصبح المجموع الجاري أكبر من 14 بعد إضافة عنصر فإنه يُصفَّر قبل تسجيله.
مثال: `acc_reset([4, 7, 1, 9, 9, 5, 1])` يجب أن تُرجع `[4, 11, 12, 0, 9, 14, 0]`.
الجواب: | bc59060d485f8fc0 | null | null |
code | a11_code_gen | python | predict_output | list_comprehension | p_comp#0 | null | null | null | null | [60, 117]
2 177 | الناتج:
```text
[60, 117]
2 177
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
out = [x ** 2 - 4 for x in range(6, 12) if x % 3 == 2]
print(out)
print(len(out), sum(out))
```
الجواب: | 4e3679c98db4bb7e | out = [x ** 2 - 4 for x in range(6, 12) if x % 3 == 2]
print(out)
print(len(out), sum(out)) | null |
code | a11_code_gen | python | fix_bug | arabic_text | f_starts_with#1 | count_initial | def count_initial(line):
count = 0
for w in line.split():
if w.startswith('م'):
count += 1
return count | [
"assert count_initial('صحراء حديقة عربية حصان') == 0",
"assert count_initial('تفاحة فجر بحر عمل تفاحة برمجة') == 0",
"assert count_initial('سلام باب دفتر تفاحة لغة مدرسة بحر') == 1",
"assert count_initial('لغة طالب') == 0",
"assert count_initial('تفاحة كتاب مكتبة ماء قلم نهر') == 2",
"assert count_initial... | assert count_initial('صحراء حديقة عربية حصان') == 0
assert count_initial('تفاحة فجر بحر عمل تفاحة برمجة') == 0
assert count_initial('سلام باب دفتر تفاحة لغة مدرسة بحر') == 1
assert count_initial('لغة طالب') == 0
assert count_initial('تفاحة كتاب مكتبة ماء قلم نهر') == 2
assert count_initial('معلم جبل قمر قهوة سوق صديق م... | def count_initial(line):
count = 0
for w in line.split():
if w.startswith('م'):
count += 1
return count | ```python
def count_initial(line):
count = 0
for w in line.split():
if w.startswith('م'):
count += 1
return count
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: في الشيفرة الآتية خطأ يجعل الدالة لا تعمل كما يجب. المطلوب منها أن تُرجع عدد الكلمات (المفصولة بمسافات) في النص العربي line التي تبدأ بالحرف «م». اكتشف الخطأ وأعد كتابة الدالة بعد إصلاحه.
```python
def count_initial(line):
count = 0
for w in line:
if w.... | 8e53a9d6eea4fedd | null | def count_initial(line):
count = 0
for w in line:
if w.startswith('م'):
count += 1
return count |
code | a11_code_gen | python | fix_bug | arabic_text | f_starts_with#1 | begin_count | def begin_count(sentence):
count = 0
for w in sentence.split():
if w.startswith('د'):
count += 1
return count | [
"assert begin_count('دفتر سفينة بيت وردة وردة نور') == 1",
"assert begin_count('سيارة فجر مدينة') == 0",
"assert begin_count('جبل دفتر صديق سيارة برمجة وردة مكتبة') == 1",
"assert begin_count('شجرة جبل سوق جبل دفتر') == 1",
"assert begin_count('شجرة سوق دفتر') == 1",
"assert begin_count('معلم طالب دفتر تف... | assert begin_count('دفتر سفينة بيت وردة وردة نور') == 1
assert begin_count('سيارة فجر مدينة') == 0
assert begin_count('جبل دفتر صديق سيارة برمجة وردة مكتبة') == 1
assert begin_count('شجرة جبل سوق جبل دفتر') == 1
assert begin_count('شجرة سوق دفتر') == 1
assert begin_count('معلم طالب دفتر تفاحة طائرة') == 1
assert begin_... | def begin_count(sentence):
count = 0
for w in sentence.split():
if w.startswith('د'):
count += 1
return count | ```python
def begin_count(sentence):
count = 0
for w in sentence.split():
if w.startswith('د'):
count += 1
return count
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: في الشيفرة الآتية خطأ يجعل الدالة لا تعمل كما يجب. المطلوب منها أن تُرجع عدد الكلمات (المفصولة بمسافات) في النص العربي sentence التي تبدأ بالحرف «د». اكتشف الخطأ وأعد كتابة الدالة بعد إصلاحه.
```python
def begin_count(sentence):
count = 0
for w in sentence.spli... | 8bf57a4c3edbe531 | null | def begin_count(sentence):
count = 0
for w in sentence.split():
if w.endswith('د'):
count += 1
return count |
code | a11_code_gen | python | write_function | math | w_digit_pow#0 | digits_mod | def digits_mod(n):
return sum(int(d) ** 4 for d in str(n)) % 71 | [
"assert digits_mod(95025) == 17",
"assert digits_mod(272976) == 53",
"assert digits_mod(300984) == 60",
"assert digits_mod(416449) == 35",
"assert digits_mod(123234) == 25",
"assert digits_mod(749076) == 64",
"assert digits_mod(977672) == 24",
"assert digits_mod(0) == 0"
] | assert digits_mod(95025) == 17
assert digits_mod(272976) == 53
assert digits_mod(300984) == 60
assert digits_mod(416449) == 35
assert digits_mod(123234) == 25
assert digits_mod(749076) == 64
assert digits_mod(977672) == 24
assert digits_mod(0) == 0 | def digits_mod(n):
return sum(int(d) ** 4 for d in str(n)) % 71 | ```python
def digits_mod(n):
return sum(int(d) ** 4 for d in str(n)) % 71
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة `digits_mod(n)` تأخذ عددًا صحيحًا غير سالب n وتُرجع باقي قسمة (مجموع أرقام n كلٌّ مرفوع للأس 4) على 71.
مثال: `digits_mod(95025)` يجب أن تُرجع `17`.
الجواب: | b3f9b46c8b7c91c1 | null | null |
code | a11_code_gen | python | predict_output | list_slicing | p_slice#1 | null | null | null | null | [28, 15, -9]
[-5, -6, -9, 28, 20]
3 | الناتج:
```text
[28, 15, -9]
[-5, -6, -9, 28, 20]
3
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
a = [20, 39, 28, 15, -9, 22, -6, 2, -5]
print(a[2:5])
print(a[::-2])
print(len(a[2:5]))
```
الجواب: | 547b1250a12bfc68 | a = [20, 39, 28, 15, -9, 22, -6, 2, -5]
print(a[2:5])
print(a[::-2])
print(len(a[2:5])) | null |
code | a11_code_gen | python | predict_output | arabic_text | p_arabic#0 | null | null | null | null | 4
['جبل', 'مكتبة']
True | الناتج:
```text
4
['جبل', 'مكتبة']
True
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
text = 'جبل مكتبة'
print(text.find('م'))
print(text.split())
print('م' in text)
```
الجواب: | 9c1bd5b2100831b3 | text = 'جبل مكتبة'
print(text.find('م'))
print(text.split())
print('م' in text) | null |
code | a11_code_gen | python | predict_output | while_loop | p_while#1 | null | null | null | null | 3 4 | الناتج:
```text
3 4
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
n = 13810
steps = 0
while n > 12:
n = n // 8
steps += 1
print(n, steps)
```
الجواب: | d2c7ab494aad9988 | n = 13810
steps = 0
while n > 12:
n = n // 8
steps += 1
print(n, steps) | null |
code | a11_code_gen | python | fix_bug | loops | f_power_sum#0 | sum_powers | def sum_powers(n):
total = 0
for i in range(1, n + 1):
total += 3 * i ** 4
return total | [
"assert sum_powers(3) == 294",
"assert sum_powers(5) == 2937",
"assert sum_powers(10) == 75999",
"assert sum_powers(13) == 267813",
"assert sum_powers(7) == 14028",
"assert sum_powers(1) == 3",
"assert sum_powers(0) == 0"
] | assert sum_powers(3) == 294
assert sum_powers(5) == 2937
assert sum_powers(10) == 75999
assert sum_powers(13) == 267813
assert sum_powers(7) == 14028
assert sum_powers(1) == 3
assert sum_powers(0) == 0 | def sum_powers(n):
total = 0
for i in range(1, n + 1):
total += 3 * i ** 4
return total | ```python
def sum_powers(n):
total = 0
for i in range(1, n + 1):
total += 3 * i ** 4
return total
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: الدالة التالية يُفترض أن تُرجع مجموع 3 × i^4 لكل عدد صحيح i من 1 إلى n (شاملًا n)، لكنها تحتوي على خطأ برمجي. أصلح الخطأ واكتب الدالة الصحيحة كاملة.
```python
def sum_powers(n):
total = 0
for i in range(1, n + 1):
total = 3 * i ** 4
return total
```... | 0abb84c15e3279b6 | null | def sum_powers(n):
total = 0
for i in range(1, n + 1):
total = 3 * i ** 4
return total |
code | a11_code_gen | python | predict_output | functions | p_func#1 | null | null | null | null | -103
-85
-145 | الناتج:
```text
-103
-85
-145
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
def compute(x, y=8):
if x > y:
return x * -5 - y
return x + y * -5
print(compute(19))
print(compute(19, -10))
print(compute(compute(-10), 19))
```
الجواب: | 02d8a0238e5c133e | def compute(x, y=8):
if x > y:
return x * -5 - y
return x + y * -5
print(compute(19))
print(compute(19, -10))
print(compute(compute(-10), 19)) | null |
code | a11_code_gen | python | predict_output | list_slicing | p_slice#0 | null | null | null | null | [17]
[6, 20, 5, 10, 30]
17 | الناتج:
```text
[17]
[6, 20, 5, 10, 30]
17
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
a = [6, 17, 20, -4, 5, 14, 10, 12, 30]
print(a[1:2])
print(a[::2])
print(min(a[1:2]))
```
الجواب: | 70743f9ae7e08ede | a = [6, 17, 20, -4, 5, 14, 10, 12, 30]
print(a[1:2])
print(a[::2])
print(min(a[1:2])) | null |
code | a11_code_gen | python | predict_output | dict | p_dict#0 | null | null | null | null | 5
منى
138
-1 | الناتج:
```text
5
منى
138
-1
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
points = {'رنا': 24, 'زينب': 35, 'منى': 25, 'وليد': 16}
points['منى'] += 16
points['ليلى'] = 22
print(len(points))
print(max(points, key=points.get))
print(sum(points.values()))
print(points.get('هدى', -1))
```
الجواب: | 716a824187f3df74 | points = {'رنا': 24, 'زينب': 35, 'منى': 25, 'وليد': 16}
points['منى'] += 16
points['ليلى'] = 22
print(len(points))
print(max(points, key=points.get))
print(sum(points.values()))
print(points.get('هدى', -1)) | null |
code | a11_code_gen | python | predict_output | while_loop | p_while#0 | null | null | null | null | 113 | الناتج:
```text
113
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
m = 110
steps = 0
while m != 1:
if m % 2 == 0:
m = m // 2
else:
m = 3 * m + 1
steps += 1
print(steps)
```
الجواب: | b58f7fd706d88408 | m = 110
steps = 0
while m != 1:
if m % 2 == 0:
m = m // 2
else:
m = 3 * m + 1
steps += 1
print(steps) | null |
code | a11_code_gen | python | write_function | loops | w_fizz#0 | game | def game(n):
out = []
for i in range(1, n + 1):
s = ''
if i % 3 == 0:
s += 'Sun'
if i % 10 == 0:
s += 'Moon'
out.append(s or str(i))
return out | [
"assert game(28) == ['1', '2', 'Sun', '4', '5', 'Sun', '7', '8', 'Sun', 'Moon', '11', 'Sun', '13', '14', 'Sun', '16', '17', 'Sun', '19', 'Moon', 'Sun', '22', '23', 'Sun', '25', '26', 'Sun', '28']",
"assert game(0) == []",
"assert game(11) == ['1', '2', 'Sun', '4', '5', 'Sun', '7', '8', 'Sun', 'Moon', '11']",
... | assert game(28) == ['1', '2', 'Sun', '4', '5', 'Sun', '7', '8', 'Sun', 'Moon', '11', 'Sun', '13', '14', 'Sun', '16', '17', 'Sun', '19', 'Moon', 'Sun', '22', '23', 'Sun', '25', '26', 'Sun', '28']
assert game(0) == []
assert game(11) == ['1', '2', 'Sun', '4', '5', 'Sun', '7', '8', 'Sun', 'Moon', '11']
assert game(18) == ... | def game(n):
out = []
for i in range(1, n + 1):
s = ''
if i % 3 == 0:
s += 'Sun'
if i % 10 == 0:
s += 'Moon'
out.append(s or str(i))
return out | ```python
def game(n):
out = []
for i in range(1, n + 1):
s = ''
if i % 3 == 0:
s += 'Sun'
if i % 10 == 0:
s += 'Moon'
out.append(s or str(i))
return out
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة `game(n)` تُرجع قائمة نصوص للأعداد من 1 إلى n: العدد الذي يقبل القسمة على 3 يُستبدل بـ 'Sun'، وعلى 10 بـ 'Moon'، وعلى كليهما بـ 'SunMoon'، وإلا يُكتب العدد نفسه نصًا.
مثال: `game(28)` يجب أن تُرجع `['1', '2', 'Sun', '4', '5', 'Sun', '7', '8', 'Sun', 'Moon', '... | f1deac918e1725ce | null | null |
code | a11_code_gen | python | fix_bug | lists | f_max_div#1 | biggest_mult | def biggest_mult(nums):
best = None
for x in nums:
if x % 2 == 0 and (best is None or x > best):
best = x
return best | [
"assert biggest_mult([-27, 59, -4, 40, 58, -5]) == 58",
"assert biggest_mult([-6, -6, -4]) == -4",
"assert biggest_mult([1, 3, 5, 7]) == None",
"assert biggest_mult([39, 15, -25, 7, 18, -22, -22, 20]) == 20",
"assert biggest_mult([-27, 10, 1, 41, 7, 10, 46]) == 46",
"assert biggest_mult([]) == None"
] | assert biggest_mult([-27, 59, -4, 40, 58, -5]) == 58
assert biggest_mult([-6, -6, -4]) == -4
assert biggest_mult([1, 3, 5, 7]) == None
assert biggest_mult([39, 15, -25, 7, 18, -22, -22, 20]) == 20
assert biggest_mult([-27, 10, 1, 41, 7, 10, 46]) == 46
assert biggest_mult([]) == None | def biggest_mult(nums):
best = None
for x in nums:
if x % 2 == 0 and (best is None or x > best):
best = x
return best | ```python
def biggest_mult(nums):
best = None
for x in nums:
if x % 2 == 0 and (best is None or x > best):
best = x
return best
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: في الشيفرة الآتية خطأ يجعل الدالة لا تعمل كما يجب. المطلوب منها أن تُرجع أكبر عنصر في القائمة nums يقبل القسمة على 2، أو None إذا لم يوجد مثل هذا العنصر. اكتشف الخطأ وأعد كتابة الدالة بعد إصلاحه.
```python
def biggest_mult(nums):
best = None
for x in nums:
... | d8f20dd9d5233660 | null | def biggest_mult(nums):
best = None
for x in nums:
if x % 2 != 0 and (best is None or x > best):
best = x
return best |
code | a11_code_gen | python | write_function | math | w_sum_mult#1 | sum_multiples | def sum_multiples(n):
return sum(x for x in range(1, n) if x % 9 == 0 or x % 15 == 0) | [
"assert sum_multiples(271) == 5805",
"assert sum_multiples(137) == 1485",
"assert sum_multiples(149) == 1629",
"assert sum_multiples(234) == 4050",
"assert sum_multiples(124) == 1224",
"assert sum_multiples(68) == 357",
"assert sum_multiples(1) == 0"
] | assert sum_multiples(271) == 5805
assert sum_multiples(137) == 1485
assert sum_multiples(149) == 1629
assert sum_multiples(234) == 4050
assert sum_multiples(124) == 1224
assert sum_multiples(68) == 357
assert sum_multiples(1) == 0 | def sum_multiples(n):
return sum(x for x in range(1, n) if x % 9 == 0 or x % 15 == 0) | ```python
def sum_multiples(n):
return sum(x for x in range(1, n) if x % 9 == 0 or x % 15 == 0)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ دالة `sum_multiples(n)` تحسب مجموع كل عدد x حيث 1 ≤ x < n ويكون x من مضاعفات 9 أو من مضاعفات 15، ثم تُرجع هذا المجموع.
للتوضيح: الاستدعاء `sum_multiples(271)` يُرجع `5805`.
الجواب: | 922f72b444f5a15e | null | null |
code | a11_code_gen | python | predict_output | dict | p_dict#1 | null | null | null | null | 6
حسن
97
[('أحمد', 3), ('منى', 3)] | الناتج:
```text
6
حسن
97
[('أحمد', 3), ('منى', 3)]
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
points = {'سلمى': 17, 'هدى': 28, 'حسن': 36, 'عمر': 9, 'أحمد': 3}
points['هدى'] += 1
points['منى'] = 3
print(len(points))
print(max(points, key=points.get))
print(sum(points.values()))
print(s... | 8e50abfc9ddd98f4 | points = {'سلمى': 17, 'هدى': 28, 'حسن': 36, 'عمر': 9, 'أحمد': 3}
points['هدى'] += 1
points['منى'] = 3
print(len(points))
print(max(points, key=points.get))
print(sum(points.values()))
print(sorted(points.items(), key=lambda kv: (kv[1], kv[0]))[:2]) | null |
code | a11_code_gen | python | write_function | math | w_coprime#0 | rel_prime_count | def rel_prime_count(n):
from math import gcd
return sum(1 for i in range(1, n + 1) if gcd(i, 40) == 1) | [
"assert rel_prime_count(37) == 15",
"assert rel_prime_count(100) == 40",
"assert rel_prime_count(141) == 57",
"assert rel_prime_count(83) == 34",
"assert rel_prime_count(122) == 49",
"assert rel_prime_count(7) == 3",
"assert rel_prime_count(1) == 1"
] | assert rel_prime_count(37) == 15
assert rel_prime_count(100) == 40
assert rel_prime_count(141) == 57
assert rel_prime_count(83) == 34
assert rel_prime_count(122) == 49
assert rel_prime_count(7) == 3
assert rel_prime_count(1) == 1 | def rel_prime_count(n):
from math import gcd
return sum(1 for i in range(1, n + 1) if gcd(i, 40) == 1) | ```python
def rel_prime_count(n):
from math import gcd
return sum(1 for i in range(1, n + 1) if gcd(i, 40) == 1)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة `rel_prime_count(n)` تُرجع عدد الأعداد الصحيحة i في المدى من 1 إلى n (شاملًا) التي تكون أولية نسبيًا مع 40، أي أن القاسم المشترك الأكبر لها مع 40 يساوي 1.
مثال: `rel_prime_count(37)` يجب أن تُرجع `15`.
الجواب: | 87a0eaa4ae51396a | null | null |
code | a11_code_gen | python | write_function | arabic_text | w_count_letter#1 | count_ar | def count_ar(text):
return sum(1 for w in text.split() if 'ع' in w) | [
"assert count_ar('ليل لغة كتاب فجر فجر') == 0",
"assert count_ar('مدرسة مدينة جبل ماء') == 0",
"assert count_ar('خبز قهوة نهر') == 0",
"assert count_ar('خبز برمجة مطر جمل قمر') == 0",
"assert count_ar('قمر لغة بحر شجرة') == 0",
"assert count_ar('') == 0",
"assert count_ar('طائرة مدرسة عربية تفاحة قلم') ... | assert count_ar('ليل لغة كتاب فجر فجر') == 0
assert count_ar('مدرسة مدينة جبل ماء') == 0
assert count_ar('خبز قهوة نهر') == 0
assert count_ar('خبز برمجة مطر جمل قمر') == 0
assert count_ar('قمر لغة بحر شجرة') == 0
assert count_ar('') == 0
assert count_ar('طائرة مدرسة عربية تفاحة قلم') == 1
assert count_ar('') == 0 | def count_ar(text):
return sum(1 for w in text.split() if 'ع' in w) | ```python
def count_ar(text):
return sum(1 for w in text.split() if 'ع' in w)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ الدالة `count_ar(text)` بحيث تُعيد عدد الكلمات (المفصولة بمسافات) التي تحتوي على الحرف «ع» مرة واحدة على الأقل، حيث text سلسلة نصية بالعربية.
للتوضيح: الاستدعاء `count_ar('ليل لغة كتاب فجر فجر')` يُرجع `0`.
الجواب: | f84794e888bd9bd2 | null | null |
code | a11_code_gen | python | write_function | arabic_text | w_count_letter#0 | tally_letter | def tally_letter(text):
return sum(1 for w in text.split() if 'و' in w) | [
"assert tally_letter('بيت صحراء جبل كتاب نور حديقة') == 1",
"assert tally_letter('مطر سيارة قمر خبز قهوة طائرة') == 1",
"assert tally_letter('شجرة ليل نهار وردة حصان قهوة صديق عربية') == 2",
"assert tally_letter('عمل طالب بحر عربية') == 0",
"assert tally_letter('فجر عربية باب') == 0",
"assert tally_letter... | assert tally_letter('بيت صحراء جبل كتاب نور حديقة') == 1
assert tally_letter('مطر سيارة قمر خبز قهوة طائرة') == 1
assert tally_letter('شجرة ليل نهار وردة حصان قهوة صديق عربية') == 2
assert tally_letter('عمل طالب بحر عربية') == 0
assert tally_letter('فجر عربية باب') == 0
assert tally_letter('مدينة عمل فجر جبل سفينة مدرس... | def tally_letter(text):
return sum(1 for w in text.split() if 'و' in w) | ```python
def tally_letter(text):
return sum(1 for w in text.split() if 'و' in w)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة بايثون `tally_letter(text)` تأخذ نصًا عربيًا وتُرجع عدد الكلمات (المفصولة بمسافات) التي تحتوي على الحرف «و» مرة واحدة على الأقل.
مثال: `tally_letter('بيت صحراء جبل كتاب نور حديقة')` يجب أن تُرجع `1`.
الجواب: | df4036b643532aac | null | null |
code | a11_code_gen | python | fix_bug | lists | f_max_div#1 | largest_div | def largest_div(nums):
best = None
for x in nums:
if x % 8 == 0 and (best is None or x > best):
best = x
return best | [
"assert largest_div([35, -6, -20, -24, 57, -19, 51]) == -24",
"assert largest_div([-40, -32, -8]) == -8",
"assert largest_div([1, 9, 17, 25]) == None",
"assert largest_div([23, -21, 14, 26, -28, -11, 8]) == 8",
"assert largest_div([-42, -22, 14, -1, -31, -6, 46]) == None",
"assert largest_div([]) == None"... | assert largest_div([35, -6, -20, -24, 57, -19, 51]) == -24
assert largest_div([-40, -32, -8]) == -8
assert largest_div([1, 9, 17, 25]) == None
assert largest_div([23, -21, 14, 26, -28, -11, 8]) == 8
assert largest_div([-42, -22, 14, -1, -31, -6, 46]) == None
assert largest_div([]) == None | def largest_div(nums):
best = None
for x in nums:
if x % 8 == 0 and (best is None or x > best):
best = x
return best | ```python
def largest_div(nums):
best = None
for x in nums:
if x % 8 == 0 and (best is None or x > best):
best = x
return best
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: في الشيفرة الآتية خطأ يجعل الدالة لا تعمل كما يجب. المطلوب منها أن تُرجع أكبر عنصر في القائمة nums يقبل القسمة على 8، أو None إذا لم يوجد مثل هذا العنصر. اكتشف الخطأ وأعد كتابة الدالة بعد إصلاحه.
```python
def largest_div(nums):
best = None
for x in nums:
... | f91b71db02a77d44 | null | def largest_div(nums):
best = None
for x in nums:
if x % 8 == 0 and (best is None or x < best):
best = x
return best |
code | a11_code_gen | python | write_function | dict | w_char_freq#0 | count_chars | def count_chars(s):
return {c: s.count(c) for c in 'gn'} | [
"assert count_chars('go summer code in vector') == {'g': 1, 'n': 1}",
"assert count_chars('falcon garden brain a a we') == {'g': 1, 'n': 3}",
"assert count_chars('we it camel music desert') == {'g': 0, 'n': 0}",
"assert count_chars('garden on') == {'g': 1, 'n': 2}",
"assert count_chars('falcon stone an it v... | assert count_chars('go summer code in vector') == {'g': 1, 'n': 1}
assert count_chars('falcon garden brain a a we') == {'g': 1, 'n': 3}
assert count_chars('we it camel music desert') == {'g': 0, 'n': 0}
assert count_chars('garden on') == {'g': 1, 'n': 2}
assert count_chars('falcon stone an it vector matrix') == {'g': 0... | def count_chars(s):
return {c: s.count(c) for c in 'gn'} | ```python
def count_chars(s):
return {c: s.count(c) for c in 'gn'}
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة `count_chars(s)` تُرجع قاموسًا مفاتيحه المحارف 'g'، 'n' وقيمة كل مفتاح عدد مرات ظهوره في النص s (حتى لو كان صفرًا).
مثال: `count_chars('go summer code in vector')` يجب أن تُرجع `{'g': 1, 'n': 1}`.
الجواب: | 3b1ad2b0190da270 | null | null |
code | a11_code_gen | python | predict_output | arabic_text | p_arabic#1 | null | null | null | null | 7
11
1 | الناتج:
```text
7
11
1
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
w = 'مكتبة سفينة'
print(w.find('ف'))
print(len(w))
print(w.count('ف'))
```
الجواب: | 013a655d2045d948 | w = 'مكتبة سفينة'
print(w.find('ف'))
print(len(w))
print(w.count('ف')) | null |
code | a11_code_gen | python | predict_output | dict | p_dict#0 | null | null | null | null | 6
يوسف
215
[('راشد', 11), ('مريم', 13)] | الناتج:
```text
6
يوسف
215
[('راشد', 11), ('مريم', 13)]
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
marks = {'سلمى': 36, 'راشد': 11, 'وليد': 42, 'يوسف': 49, 'باسل': 46}
marks['يوسف'] += 18
marks['مريم'] = 13
print(len(marks))
print(max(marks, key=marks.get))
print(sum(marks.values()))
print(sorted(marks.items(), key=lambd... | 273490abd185b506 | marks = {'سلمى': 36, 'راشد': 11, 'وليد': 42, 'يوسف': 49, 'باسل': 46}
marks['يوسف'] += 18
marks['مريم'] = 13
print(len(marks))
print(max(marks, key=marks.get))
print(sum(marks.values()))
print(sorted(marks.items(), key=lambda kv: (kv[1], kv[0]))[:2]) | null |
code | a11_code_gen | python | predict_output | while_loop | p_while#1 | null | null | null | null | 55 | الناتج:
```text
55
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
x = 295
count = 0
while x != 1:
if x % 2 == 0:
x = x // 2
else:
x = 3 * x + 1
count += 1
print(count)
```
الجواب: | 2cef1d508081b8e7 | x = 295
count = 0
while x != 1:
if x % 2 == 0:
x = x // 2
else:
x = 3 * x + 1
count += 1
print(count) | null |
code | a11_code_gen | python | write_function | lists | w_filter_range#0 | between_times | def between_times(xs):
return sorted(x * 1 for x in xs if 13 <= x <= 21) | [
"assert between_times([5, 13, 8, 30, 10, 17, 10, 23, 26, 16]) == [13, 16, 17]",
"assert between_times([-4, 25, -4, 25, 43, -12]) == []",
"assert between_times([-16, 6, 60, 7, 2, 2, 38, 6, 21, 55]) == [21]",
"assert between_times([16, -5, 16, -6]) == [16, 16]",
"assert between_times([-29, 32, 24, 8, -12]) ==... | assert between_times([5, 13, 8, 30, 10, 17, 10, 23, 26, 16]) == [13, 16, 17]
assert between_times([-4, 25, -4, 25, 43, -12]) == []
assert between_times([-16, 6, 60, 7, 2, 2, 38, 6, 21, 55]) == [21]
assert between_times([16, -5, 16, -6]) == [16, 16]
assert between_times([-29, 32, 24, 8, -12]) == []
assert between_times(... | def between_times(xs):
return sorted(x * 1 for x in xs if 13 <= x <= 21) | ```python
def between_times(xs):
return sorted(x * 1 for x in xs if 13 <= x <= 21)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة `between_times(xs)` تأخذ قائمة أعداد صحيحة وتُرجع قائمة مرتبة تصاعديًا تحتوي حاصل ضرب كل عنصر يقع بين 13 و21 (شاملًا الطرفين) في 1.
مثال: `between_times([5, 13, 8, 30, 10, 17, 10, 23, 26, 16])` يجب أن تُرجع `[13, 16, 17]`.
الجواب: | c58dbdeee02467c9 | null | null |
code | a11_code_gen | python | write_function | arabic_text | w_count_letter#0 | count_hits | def count_hits(text):
return text.count('ا') | [
"assert count_hits('طالب سلام صحراء رمل مدرسة كتاب حديقة قمر') == 4",
"assert count_hits('سفينة عربية حديقة سلام سماء سماء نهر طائرة') == 4",
"assert count_hits('مدرسة طالب سلام جبل سوق') == 2",
"assert count_hits('رمل') == 0",
"assert count_hits('دفتر نهر') == 0",
"assert count_hits('ليل قلم سلام سيارة ط... | assert count_hits('طالب سلام صحراء رمل مدرسة كتاب حديقة قمر') == 4
assert count_hits('سفينة عربية حديقة سلام سماء سماء نهر طائرة') == 4
assert count_hits('مدرسة طالب سلام جبل سوق') == 2
assert count_hits('رمل') == 0
assert count_hits('دفتر نهر') == 0
assert count_hits('ليل قلم سلام سيارة طائرة مكتبة سماء') == 4
assert ... | def count_hits(text):
return text.count('ا') | ```python
def count_hits(text):
return text.count('ا')
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة بايثون `count_hits(text)` تأخذ نصًا عربيًا وتُرجع عدد مرات ظهور الحرف «ا» في النص.
مثال: `count_hits('طالب سلام صحراء رمل مدرسة كتاب حديقة قمر')` يجب أن تُرجع `4`.
الجواب: | 60eb85dc159fde66 | null | null |
code | a11_code_gen | python | write_function | math | w_sum_mult#1 | sum_div | def sum_div(n):
return sum(x for x in range(1, n) if x % 6 == 0 or x % 12 == 0) | [
"assert sum_div(161) == 2106",
"assert sum_div(38) == 126",
"assert sum_div(29) == 60",
"assert sum_div(251) == 5166",
"assert sum_div(254) == 5418",
"assert sum_div(228) == 4218",
"assert sum_div(1) == 0"
] | assert sum_div(161) == 2106
assert sum_div(38) == 126
assert sum_div(29) == 60
assert sum_div(251) == 5166
assert sum_div(254) == 5418
assert sum_div(228) == 4218
assert sum_div(1) == 0 | def sum_div(n):
return sum(x for x in range(1, n) if x % 6 == 0 or x % 12 == 0) | ```python
def sum_div(n):
return sum(x for x in range(1, n) if x % 6 == 0 or x % 12 == 0)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ دالة `sum_div(n)` تحسب مجموع كل عدد x حيث 1 ≤ x < n ويكون x من مضاعفات 6 أو من مضاعفات 12، ثم تُرجع هذا المجموع.
للتوضيح: الاستدعاء `sum_div(161)` يُرجع `2106`.
الجواب: | a68765d4831d5d8e | null | null |
code | a11_code_gen | python | write_function | strings | w_reverse_words#0 | rev_join | def rev_join(s):
return '/'.join([w for w in s.split() if len(w) >= 6][::-1]) | [
"assert rev_join('stone table to we at') == ''",
"assert rev_join('') == ''",
"assert rev_join('camel apple orange') == 'orange'",
"assert rev_join('by we light light brain python to') == 'python'",
"assert rev_join('river orange winter') == 'winter/orange'",
"assert rev_join('') == ''",
"assert rev_joi... | assert rev_join('stone table to we at') == ''
assert rev_join('') == ''
assert rev_join('camel apple orange') == 'orange'
assert rev_join('by we light light brain python to') == 'python'
assert rev_join('river orange winter') == 'winter/orange'
assert rev_join('') == ''
assert rev_join('stone') == '' | def rev_join(s):
return '/'.join([w for w in s.split() if len(w) >= 6][::-1]) | ```python
def rev_join(s):
return '/'.join([w for w in s.split() if len(w) >= 6][::-1])
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة `rev_join(s)` تأخذ جملة وتُرجع الكلمات التي طولها 6 أحرف أو أكثر بترتيب معكوس، مفصولًا بينها بالفاصل '/'.
مثال: `rev_join('stone table to we at')` يجب أن تُرجع `''`.
الجواب: | 04b3b63ad432018a | null | null |
code | a11_code_gen | python | complete_function | loops | c_count_div#0 | count_special | def count_special(xs):
count = 0
for x in xs:
if x % 9 == 0 and x % 8 != 0:
count += 1
return count | [
"assert count_special([78, 2, 33, 53, 16, 3, 68, 56, 3, 7]) == 0",
"assert count_special([-33, 1, 48]) == 0",
"assert count_special([36, 54, 45]) == 3",
"assert count_special([65, 17, 36, 71, 9, 79, -17, 82]) == 2",
"assert count_special([52, -23]) == 0",
"assert count_special([90, -21, -8, 29, 13, 28, -5... | assert count_special([78, 2, 33, 53, 16, 3, 68, 56, 3, 7]) == 0
assert count_special([-33, 1, 48]) == 0
assert count_special([36, 54, 45]) == 3
assert count_special([65, 17, 36, 71, 9, 79, -17, 82]) == 2
assert count_special([52, -23]) == 0
assert count_special([90, -21, -8, 29, 13, 28, -5, -22]) == 1
assert count_spec... | def count_special(xs):
count = 0
for x in xs:
if x % 9 == 0 and x % 8 != 0:
count += 1
return count | ```python
def count_special(xs):
count = 0
for x in xs:
if x % 9 == 0 and x % 8 != 0:
count += 1
return count
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أكمل الدالة التالية بوضع التعبير المناسب مكان ____ بحيث تُرجع الدالة عدد عناصر xs التي تقبل القسمة على 9 ولا تقبل القسمة على 8، ثم اكتب الدالة كاملة.
```python
def count_special(xs):
count = 0
for x in xs:
if ____:
count += 1
return coun... | e2f3f30af3a39681 | null | null |
code | a11_code_gen | python | write_function | math | w_coprime#0 | coprimes | def coprimes(n):
from math import gcd
return sum(1 for i in range(1, n + 1) if gcd(i, 88) == 1) | [
"assert coprimes(73) == 34",
"assert coprimes(183) == 84",
"assert coprimes(93) == 43",
"assert coprimes(48) == 22",
"assert coprimes(189) == 86",
"assert coprimes(158) == 72",
"assert coprimes(1) == 1"
] | assert coprimes(73) == 34
assert coprimes(183) == 84
assert coprimes(93) == 43
assert coprimes(48) == 22
assert coprimes(189) == 86
assert coprimes(158) == 72
assert coprimes(1) == 1 | def coprimes(n):
from math import gcd
return sum(1 for i in range(1, n + 1) if gcd(i, 88) == 1) | ```python
def coprimes(n):
from math import gcd
return sum(1 for i in range(1, n + 1) if gcd(i, 88) == 1)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة `coprimes(n)` تُرجع عدد الأعداد الصحيحة i في المدى من 1 إلى n (شاملًا) التي تكون أولية نسبيًا مع 88، أي أن القاسم المشترك الأكبر لها مع 88 يساوي 1.
مثال: `coprimes(73)` يجب أن تُرجع `34`.
الجواب: | 1de70330b8e46e6e | null | null |
code | a11_code_gen | python | write_function | math | w_digit_pow#0 | digit_power | def digit_power(n):
return sum(int(d) ** 2 for d in str(n)) % 14 | [
"assert digit_power(16737) == 4",
"assert digit_power(928069) == 0",
"assert digit_power(795932) == 11",
"assert digit_power(511599) == 4",
"assert digit_power(340124) == 4",
"assert digit_power(669027) == 10",
"assert digit_power(765563) == 12",
"assert digit_power(0) == 0"
] | assert digit_power(16737) == 4
assert digit_power(928069) == 0
assert digit_power(795932) == 11
assert digit_power(511599) == 4
assert digit_power(340124) == 4
assert digit_power(669027) == 10
assert digit_power(765563) == 12
assert digit_power(0) == 0 | def digit_power(n):
return sum(int(d) ** 2 for d in str(n)) % 14 | ```python
def digit_power(n):
return sum(int(d) ** 2 for d in str(n)) % 14
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة `digit_power(n)` تأخذ عددًا صحيحًا غير سالب n وتُرجع باقي قسمة (مجموع أرقام n كلٌّ مرفوع للأس 2) على 14.
مثال: `digit_power(16737)` يجب أن تُرجع `4`.
الجواب: | 118cd66f0fbd50d4 | null | null |
code | a11_code_gen | python | complete_function | loops | c_count_div#1 | only_div | def only_div(xs):
count = 0
for x in xs:
if x % 6 == 0 and x % 4 != 0:
count += 1
return count | [
"assert only_div([74, 80, 47, 56, 39, 13, 60, 45, 79]) == 0",
"assert only_div([]) == 0",
"assert only_div([-25, 23, 32, 5, 78, 13, 84, 77, -28]) == 1",
"assert only_div([61, 16, -15, -6]) == 1",
"assert only_div([36, 88, 65, -31, 52, 17]) == 0",
"assert only_div([-37, 79, -39, -40, 19, 63, -34]) == 0",
... | assert only_div([74, 80, 47, 56, 39, 13, 60, 45, 79]) == 0
assert only_div([]) == 0
assert only_div([-25, 23, 32, 5, 78, 13, 84, 77, -28]) == 1
assert only_div([61, 16, -15, -6]) == 1
assert only_div([36, 88, 65, -31, 52, 17]) == 0
assert only_div([-37, 79, -39, -40, 19, 63, -34]) == 0
assert only_div([]) == 0 | def only_div(xs):
count = 0
for x in xs:
if x % 6 == 0 and x % 4 != 0:
count += 1
return count | ```python
def only_div(xs):
count = 0
for x in xs:
if x % 6 == 0 and x % 4 != 0:
count += 1
return count
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: في الدالة الآتية جزء ناقص مكتوب ____. املأه لكي تُرجع الدالة عدد عناصر xs التي تقبل القسمة على 6 ولا تقبل القسمة على 4، واكتب الدالة بعد إكمالها.
```python
def only_div(xs):
count = 0
for x in xs:
if ____:
count += 1
return count
```
للت... | 59fc921ae389cdb4 | null | null |
code | a11_code_gen | python | predict_output | functions | p_func#0 | null | null | null | null | -9
-9
9 | الناتج:
```text
-9
-9
9
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
def calc(x, y=8):
if x > y:
return x * 0 - y
return x + y * 0
print(calc(-9))
print(calc(-9, 16))
print(calc(calc(16), -9))
```
الجواب: | 55ab5ca7ad6d6b13 | def calc(x, y=8):
if x > y:
return x * 0 - y
return x + y * 0
print(calc(-9))
print(calc(-9, 16))
print(calc(calc(16), -9)) | null |
code | a11_code_gen | python | predict_output | recursion | p_rec#1 | null | null | null | null | 35
8 | الناتج:
```text
35
8
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
def calc(n):
if n < 10:
return n
return n % 10 + calc(n // 10)
print(calc(546870122))
print(calc(calc(546870122)))
```
الجواب: | a509facb60f9939f | def calc(n):
if n < 10:
return n
return n % 10 + calc(n // 10)
print(calc(546870122))
print(calc(calc(546870122))) | null |
code | a11_code_gen | python | predict_output | sorting | p_sort#1 | null | null | null | null | [('مريم', 53), ('سعيد', 72), ('يوسف', 85), ('فيصل', 87)]
['فيصل', 'يوسف'] | الناتج:
```text
[('مريم', 53), ('سعيد', 72), ('يوسف', 85), ('فيصل', 87)]
['فيصل', 'يوسف']
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
pairs = [('يوسف', 85), ('فيصل', 87), ('مريم', 53), ('سعيد', 72)]
print(sorted(pairs, key=lambda p: (p[1], p[0])))
print([p[0] for p in sorted(pairs, key=lambda p: (-p[1], p[0]))][:2])
```
الج... | 70d5599e00f65cac | pairs = [('يوسف', 85), ('فيصل', 87), ('مريم', 53), ('سعيد', 72)]
print(sorted(pairs, key=lambda p: (p[1], p[0])))
print([p[0] for p in sorted(pairs, key=lambda p: (-p[1], p[0]))][:2]) | null |
code | a11_code_gen | python | write_function | math | w_poly#0 | quad | def quad(x):
return -1 * x ** 2 + (4) * x + (0) | [
"assert quad(7) == -21",
"assert quad(19) == -285",
"assert quad(-4) == -32",
"assert quad(-5) == -45",
"assert quad(-5) == -45",
"assert quad(-16) == -320",
"assert quad(6) == -12",
"assert quad(0) == 0"
] | assert quad(7) == -21
assert quad(19) == -285
assert quad(-4) == -32
assert quad(-5) == -45
assert quad(-5) == -45
assert quad(-16) == -320
assert quad(6) == -12
assert quad(0) == 0 | def quad(x):
return -1 * x ** 2 + (4) * x + (0) | ```python
def quad(x):
return -1 * x ** 2 + (4) * x + (0)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: اكتب دالة بايثون `quad(x)` تُرجع قيمة كثيرة الحدود -1x² + 4x + 0 عند العدد الصحيح x.
مثال: `quad(7)` يجب أن تُرجع `-21`.
الجواب: | 3fc956d272b086a5 | null | null |
code | a11_code_gen | python | write_function | strings | w_caesar#1 | cipher | def cipher(s):
out = []
for c in s:
if 'a' <= c <= 'z':
out.append(chr((ord(c) - 97 + (4)) % 26 + 97))
else:
out.append(c)
return ''.join(out) | [
"assert cipher('summer desert data') == 'wyqqiv hiwivx hexe'",
"assert cipher('engine vector is') == 'irkmri zigxsv mw'",
"assert cipher('up rocket') == 'yt vsgoix'",
"assert cipher('brain signal by in Hello') == 'fvemr wmkrep fc mr Hipps'",
"assert cipher('brain') == 'fvemr'",
"assert cipher('planet') ==... | assert cipher('summer desert data') == 'wyqqiv hiwivx hexe'
assert cipher('engine vector is') == 'irkmri zigxsv mw'
assert cipher('up rocket') == 'yt vsgoix'
assert cipher('brain signal by in Hello') == 'fvemr wmkrep fc mr Hipps'
assert cipher('brain') == 'fvemr'
assert cipher('planet') == 'tperix'
assert cipher('') ==... | def cipher(s):
out = []
for c in s:
if 'a' <= c <= 'z':
out.append(chr((ord(c) - 97 + (4)) % 26 + 97))
else:
out.append(c)
return ''.join(out) | ```python
def cipher(s):
out = []
for c in s:
if 'a' <= c <= 'z':
out.append(chr((ord(c) - 97 + (4)) % 26 + 97))
else:
out.append(c)
return ''.join(out)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ دالة بايثون `cipher(s)` لتشفير قيصر: المطلوب إزاحة كل حرف إنجليزي صغير (a-z) 4 مواقع إلى الأمام في الأبجدية (مع الالتفاف من z إلى a)، وتبقى بقية المحارف (الأحرف الكبيرة والأرقام والمسافات والرموز) كما هي.
للتوضيح: الاستدعاء `cipher('summer desert data')` يُرجع `'w... | f6a478c546088b33 | null | null |
code | a11_code_gen | python | write_function | arabic_text | w_count_letter#1 | count_in_text | def count_in_text(text):
return text.count('ه') | [
"assert count_in_text('سفينة ليل شجرة جمل شجرة') == 0",
"assert count_in_text('نهر نور سلام دفتر سلام') == 1",
"assert count_in_text('حصان صحراء باب') == 0",
"assert count_in_text('برتقال مكتبة طالب برتقال مكتبة علم') == 0",
"assert count_in_text('دفتر ليل عربية سوق سفينة مدرسة') == 0",
"assert count_in_t... | assert count_in_text('سفينة ليل شجرة جمل شجرة') == 0
assert count_in_text('نهر نور سلام دفتر سلام') == 1
assert count_in_text('حصان صحراء باب') == 0
assert count_in_text('برتقال مكتبة طالب برتقال مكتبة علم') == 0
assert count_in_text('دفتر ليل عربية سوق سفينة مدرسة') == 0
assert count_in_text('') == 0
assert count_in_t... | def count_in_text(text):
return text.count('ه') | ```python
def count_in_text(text):
return text.count('ه')
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ الدالة `count_in_text(text)` بحيث تُعيد عدد مرات ظهور الحرف «ه» في النص، حيث text سلسلة نصية بالعربية.
للتوضيح: الاستدعاء `count_in_text('سفينة ليل شجرة جمل شجرة')` يُرجع `0`.
الجواب: | ad64df2c86c116cd | null | null |
code | a11_code_gen | python | predict_output | while_loop | p_while#0 | null | null | null | null | 10 5 | الناتج:
```text
10 5
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
n = 82205
count = 0
while n > 12:
n = n // 6
count += 1
print(n, count)
```
الجواب: | d98c17bb2f25f6a8 | n = 82205
count = 0
while n > 12:
n = n // 6
count += 1
print(n, count) | null |
code | a11_code_gen | python | fix_bug | arabic_text | f_starts_with#0 | count_initial | def count_initial(text):
count = 0
for w in text.split():
if w.startswith('ا'):
count += 1
return count | [
"assert count_initial('مكتبة مطر') == 0",
"assert count_initial('دفتر طالب امل فجر قلم امل كتاب') == 2",
"assert count_initial('نور حاسوب') == 0",
"assert count_initial('قهوة امل امل مطر فجر') == 2",
"assert count_initial('امل بحر امل حاسوب نهر ميناء تفاحة عمل') == 2",
"assert count_initial('امل قهوة امل ... | assert count_initial('مكتبة مطر') == 0
assert count_initial('دفتر طالب امل فجر قلم امل كتاب') == 2
assert count_initial('نور حاسوب') == 0
assert count_initial('قهوة امل امل مطر فجر') == 2
assert count_initial('امل بحر امل حاسوب نهر ميناء تفاحة عمل') == 2
assert count_initial('امل قهوة امل وردة معلم طالب قهوة') == 2
ass... | def count_initial(text):
count = 0
for w in text.split():
if w.startswith('ا'):
count += 1
return count | ```python
def count_initial(text):
count = 0
for w in text.split():
if w.startswith('ا'):
count += 1
return count
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: الدالة التالية يُفترض أن تُرجع عدد الكلمات (المفصولة بمسافات) في النص العربي text التي تبدأ بالحرف «ا»، لكنها تحتوي على خطأ برمجي. أصلح الخطأ واكتب الدالة الصحيحة كاملة.
```python
def count_initial(text):
count = 0
for w in text:
if w.startswith('ا'):
... | d0b0353ca0e2f475 | null | def count_initial(text):
count = 0
for w in text:
if w.startswith('ا'):
count += 1
return count |
code | a11_code_gen | python | write_function | arabic_text | w_count_letter#1 | how_many | def how_many(text):
return sum(1 for w in text.split() if 'س' in w) | [
"assert how_many('مكتبة جمل حصان نهار') == 0",
"assert how_many('حديقة تفاحة ماء سفينة سفينة') == 2",
"assert how_many('ميناء فجر باب فجر نور نهر') == 0",
"assert how_many('ميناء') == 0",
"assert how_many('سيارة عمل') == 1",
"assert how_many('عمل معلم حديقة') == 0",
"assert how_many('') == 0",
"assert... | assert how_many('مكتبة جمل حصان نهار') == 0
assert how_many('حديقة تفاحة ماء سفينة سفينة') == 2
assert how_many('ميناء فجر باب فجر نور نهر') == 0
assert how_many('ميناء') == 0
assert how_many('سيارة عمل') == 1
assert how_many('عمل معلم حديقة') == 0
assert how_many('') == 0
assert how_many('') == 0 | def how_many(text):
return sum(1 for w in text.split() if 'س' in w) | ```python
def how_many(text):
return sum(1 for w in text.split() if 'س' in w)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ الدالة `how_many(text)` بحيث تُعيد عدد الكلمات (المفصولة بمسافات) التي تحتوي على الحرف «س» مرة واحدة على الأقل، حيث text سلسلة نصية بالعربية.
للتوضيح: الاستدعاء `how_many('مكتبة جمل حصان نهار')` يُرجع `0`.
الجواب: | 5596b73d3cc988f8 | null | null |
code | a11_code_gen | python | predict_output | recursion | p_rec#0 | null | null | null | null | 20 | الناتج:
```text
20
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
def f(n):
if n <= 2:
return 5
return 1 * f(n - 1) + 3
print(f(7))
```
الجواب: | 2f3722a7ff7bfa21 | def f(n):
if n <= 2:
return 5
return 1 * f(n - 1) + 3
print(f(7)) | null |
code | a11_code_gen | python | write_function | math | w_coprime#1 | coprime_count | def coprime_count(n):
from math import gcd
return sum(1 for i in range(1, n + 1) if gcd(i, 52) == 1) | [
"assert coprime_count(82) == 38",
"assert coprime_count(21) == 10",
"assert coprime_count(134) == 62",
"assert coprime_count(173) == 80",
"assert coprime_count(110) == 51",
"assert coprime_count(163) == 76",
"assert coprime_count(1) == 1"
] | assert coprime_count(82) == 38
assert coprime_count(21) == 10
assert coprime_count(134) == 62
assert coprime_count(173) == 80
assert coprime_count(110) == 51
assert coprime_count(163) == 76
assert coprime_count(1) == 1 | def coprime_count(n):
from math import gcd
return sum(1 for i in range(1, n + 1) if gcd(i, 52) == 1) | ```python
def coprime_count(n):
from math import gcd
return sum(1 for i in range(1, n + 1) if gcd(i, 52) == 1)
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: أنشئ دالة بايثون `coprime_count(n)` تعدّ قيم i حيث 1 ≤ i ≤ n و gcd(i, 52) = 1، ثم تُرجع العدد.
للتوضيح: الاستدعاء `coprime_count(82)` يُرجع `38`.
الجواب: | ada1cd995c4843a5 | null | null |
code | a11_code_gen | python | complete_function | lists | c_rotate#1 | turn_list | def turn_list(lst):
if not lst:
return []
k = 14 % len(lst)
return lst[len(lst) - k:] + lst[:len(lst) - k] | [
"assert turn_list([5, 48, 7, 47]) == [7, 47, 5, 48]",
"assert turn_list([33, 26, 18, 8]) == [18, 8, 33, 26]",
"assert turn_list([45, 6, 5]) == [6, 5, 45]",
"assert turn_list([39, 22, 36, 22, -7, -3, -3, 44, 44, 25, 47, -8]) == [47, -8, 39, 22, 36, 22, -7, -3, -3, 44, 44, 25]",
"assert turn_list([11, 7, 30, ... | assert turn_list([5, 48, 7, 47]) == [7, 47, 5, 48]
assert turn_list([33, 26, 18, 8]) == [18, 8, 33, 26]
assert turn_list([45, 6, 5]) == [6, 5, 45]
assert turn_list([39, 22, 36, 22, -7, -3, -3, 44, 44, 25, 47, -8]) == [47, -8, 39, 22, 36, 22, -7, -3, -3, 44, 44, 25]
assert turn_list([11, 7, 30, 12, 48, 26, 46, 8, 9]) ==... | def turn_list(lst):
if not lst:
return []
k = 14 % len(lst)
return lst[len(lst) - k:] + lst[:len(lst) - k] | ```python
def turn_list(lst):
if not lst:
return []
k = 14 % len(lst)
return lst[len(lst) - k:] + lst[:len(lst) - k]
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: في الدالة الآتية جزء ناقص مكتوب ____. املأه لكي تُرجع الدالة القائمة بعد تدويرها 14 مواقع إلى اليمين (العنصر الأخير ينتقل إلى البداية في كل خطوة)، واكتب الدالة بعد إكمالها.
```python
def turn_list(lst):
if not lst:
return []
k = 14 % len(lst)
return... | 7ae4035846c7b709 | null | null |
code | a11_code_gen | python | predict_output | sorting | p_sort#1 | null | null | null | null | [-2, -2, -1, 2, 23, 24, 33]
[33, 24, 23] | الناتج:
```text
[-2, -2, -1, 2, 23, 24, 33]
[33, 24, 23]
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
nums = [-1, 2, 23, 33, -2, -2, 24]
print(sorted(nums, key=lambda x: (abs(x - -7), x)))
print(sorted(nums, reverse=True)[:3])
```
الجواب: | 3c5ff776f427a50a | nums = [-1, 2, 23, 33, -2, -2, 24]
print(sorted(nums, key=lambda x: (abs(x - -7), x)))
print(sorted(nums, reverse=True)[:3]) | null |
code | a11_code_gen | python | predict_output | functions | p_func#1 | null | null | null | null | -12
-36
-28 | الناتج:
```text
-12
-36
-28
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
def g(x, y=4):
if x > y:
return x * -2 - y
return x + y * -2
print(g(-4))
print(g(-4, 16))
print(g(g(16), -4))
```
الجواب: | 83eaa8ad3a968c6d | def g(x, y=4):
if x > y:
return x * -2 - y
return x + y * -2
print(g(-4))
print(g(-4, 16))
print(g(g(16), -4)) | null |
code | a11_code_gen | python | predict_output | list_slicing | p_slice#0 | null | null | null | null | [4, 7, 28, 8]
[18, 8, 28, 7, 4, -4, -6]
28 | الناتج:
```text
[4, 7, 28, 8]
[18, 8, 28, 7, 4, -4, -6]
28
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: ما الذي يطبعه برنامج بايثون التالي؟
```python
lst = [-6, -4, 4, 7, 28, 8, 18]
print(lst[2:6])
print(lst[::-1])
print(max(lst[2:6]))
```
الجواب: | d40a7e34030533aa | lst = [-6, -4, 4, 7, 28, 8, 18]
print(lst[2:6])
print(lst[::-1])
print(max(lst[2:6])) | null |
code | a11_code_gen | python | predict_output | sorting | p_sort#1 | null | null | null | null | ['camel', 'brain', 'winter', 'window', 'rocket']
['winter', 'window', 'rocket'] | الناتج:
```text
['camel', 'brain', 'winter', 'window', 'rocket']
['winter', 'window', 'rocket']
```
| المهمة: حل مهمة البرمجة التالية بلغة بايثون.
سؤال: توقّع ناتج تنفيذ الشيفرة التالية واكتبه كما يظهر على الشاشة تمامًا:
```python
words = ['winter', 'camel', 'window', 'brain', 'rocket']
print(sorted(words, key=len))
print(sorted(words, key=lambda w: (len(w), w), reverse=True)[:3])
```
الجواب: | 3e4b4655be3ad9bd | words = ['winter', 'camel', 'window', 'brain', 'rocket']
print(sorted(words, key=len))
print(sorted(words, key=lambda w: (len(w), w), reverse=True)[:3]) | null |
End of preview. Expand in Data Studio
Arabic Code Packet A11 (verifiable)
Arabic-instruction Python tasks where every answer is machine-checkable. Built by ABUZ8 LLC for the SUPERBRAIN-1 Arabic brain (https://huggingface.co/abuz8studios/SUPERBRAIN-1).
- 6,021 train / 1,026 test, 27 deterministic template generators, seed 11.
- No LLM-generated content: every prompt, reference solution and test comes from code in
tools/build_packet_a11.py.
| Kind | Train | Test | How it is graded |
|---|---|---|---|
| predict-the-output | 2,230 | 380 | exact match with the snippet's real stdout (executed in a subprocess at build time) |
| write-a-function | 2,453 | 418 | 5-8 hidden unit tests |
| fix-the-bug | 669 | 114 | hidden tests; buggy version verified to fail |
| complete-the-function | 669 | 114 | hidden tests |
Verification (tools/check_a11.py, exit 0)
[counts] train=6021 exam=1026 generators train=27 exam=27 missing_fields=0 dup_prompts=0 -> OK
[reference] sample=400 pass=400/400 (100.00%) | fix_bug buggy versions passing=0/67 -> OK
[predict] sample=200 re-executed_match=200/200 -> OK
[negative] other-item completions scored correct: 0/100 -> OK
[leakage] train_vs_exam exact 0, norm 0, qnorm 0, qhash 0, code 0 -> LEAKAGE=0
Test items use a phrasing template never seen in train and parameter combinations disjoint from train.
Fields
task, src, kind, topic, template, prompt, completion, answer, qhash, lang; predict items add code; code items add entry, reference, tests, test_code (fix-the-bug also buggy).
Scoring
python tools/a11_score.py ITEMS.jsonl PREDS.jsonl - runs model code against hidden tests in a subprocess with a 5 s timeout (process isolation, not a security sandbox).
Model scores
None yet. Baselines for SUPERBRAIN-1 will be added here once measured.
- Downloads last month
- 23