الرئيسية chevron_left الأسئلة chevron_left CSS Height chevron_left CSS chevron_left num1 = float(input("please enter the first number: ")) operator = input("please enter the operator: ") num2 = float(input("please enter the second number: ")) if operator == "+": print("num1 + num2") elif operator == "-": print("num1 - num2") elif operator == "/": print("num1 / num2") elif operator == "*": print("num1 * num2") else: print("wrong operator please try again") ما الخطا في هذا الكود بلغة python
num1 = float(input("please enter the first number: ")) operator = input("please enter the operator: ") num2 = float(input("please enter the second number: ")) if operator == "+": print("num1 + num2") elif operator == "-": print("num1 - num2") elif operator == "/": print("num1 / num2") elif operator == "*": print("num1 * num2") else: print("wrong operator please try again") ما الخطا في هذا الكود بلغة python
لا يوجد خطأ صرفي في الكود، لكن هناك خطأ منطقي في الجمل الشرطية، إذ أنه يجب استخدام قيم المتغيرات num1 وnum2 داخل عمليات الجمع والطرح والقسمة والضرب، ولكن الجمل الشرطية تقوم بطباعة نصوص ثابتة بدلاً من القيم الفعلية. لذلك يجب استخدام قيم المتغيرات في هذه الجمل بدلاً من كتابة النص الثابت.
الكود الصحيح هو كالتالي:
num1 = float(input("please enter the first number: "))
operator = input("please enter the operator: ")
num2 = float(input("please enter the second number: "))
if operator == "+":
print(num1 + num2)
elif operator == "-":
print(num1 - num2)
elif operator == "/":
print(num1 / num2)
elif operator == "*":
print(num1 * num2)
else:
print("wrong operator please try again")
تم إنشاء هذه الإجابة آلياً بواسطة منصتنا، وسيقوم فريقنا التقني في أقرب وقت بتحديث ومراجعة الإجابة.
لا يوجد خطأ صرفي في الكود، لكن هناك خطأ منطقي في الجمل الشرطية، إذ أنه يجب استخدام قيم المتغيرات num1 وnum2 داخل عمليات الجمع والطرح والقسمة والضرب، ولكن الجمل الشرطية تقوم بطباعة نصوص ثابتة بدلاً من القيم الفعلية. لذلك يجب استخدام قيم المتغيرات في هذه الجمل بدلاً من كتابة النص الثابت. الكود الصحيح هو كالتالي: num1 = float(input("please enter the first number: ")) operator = input("please enter the operator: ") num2 = float(input("please enter the second number: ")) if operator == "+": print(num1 + num2) elif operator == "-": print(num1 - num2) elif operator == "/": print(num1 / num2) elif operator == "*": print(num1 * num2) else: print("wrong operator please try again")
num1 = float(input("please enter the first number: ")) operator = input("please enter the operator: ") num2 = float(input("please enter the second number: ")) if operator == "+": print("num1 + num2") elif operator == "-": print("num1 - num2") elif operator == "/": print("num1 / num2") elif operator == "*": print("num1 * num2") else: print("wrong operator please try again") ما الخطا في هذا الكود بلغة python ؟
الرد التلقائي
من
CLOSETAG
19 يونيو 2023
لا يوجد خطأ صرفي في الكود، لكن هناك خطأ منطقي في الجمل الشرطية، إذ أنه يجب استخدام قيم المتغيرات num1 وnum2 داخل عمليات الجمع والطرح والقسمة والضرب، ولكن الجمل الشرطية تقوم بطباعة نصوص ثابتة بدلاً من القيم الفعلية. لذلك يجب استخدام قيم المتغيرات في هذه الجمل بدلاً من كتابة النص الثابت. الكود الصحيح هو كالتالي: num1 = float(input("please enter the first number: ")) operator = input("please enter the operator: ") num2 = float(input("please enter the second number: ")) if operator == "+": print(num1 + num2) elif operator == "-": print(num1 - num2) elif operator == "/": print(num1 / num2) elif operator == "*": print(num1 * num2) else: print("wrong operator please try again")
الاختبارات و الشهادات
سجل الدخول لكي تتمكن من اجتياز جميع الاختبارات والحصول علي الشهادات
في ( الدورات - الدروس - المعسكرات )
مجانًا
هل لديك حساب؟ دخول