حسام عبده
رابط
انقر للعرض
انقر للعرض
درس اليوم في بايثون
Type Conversion
In Python, it s impossible to complete certain operations due to the types involved. For instance, you can t add two strings containing the numbers 2 and 3 together to produce the integer 5, as the operation will be performed on strings, making the result 23 .
The solution to this is type conversion.
In that example, you would use the int function.
>>> "2" + "3"
23
>>> int("2") + int("3")
5
تحويل النوع
في بيثون ، من المستحيل إتمام بعض العمليات بسبب الأنواع المعنية. على سبيل المثال ، لا يمكنك إضافة سلسلتين تحتويان على الأعداد 2 و 3 معاً لإنتاج العدد الصحيح 5 ، حيث سيتم تنفيذ العملية على السلاسل ، مما يجعل النتيجة 23 .
الحل لهذا هو نوع التحويل.
في هذا المثال ، ستستخدم الدالة int.
>>> "2" + "3"
23
>>> int("2") + int("3")
5
📱📱📱📱📱
In Python, the types we have used so far have been integers, floats, and strings. The functions used to convert to these are int, float and str, respectively.
في بايثون ، كانت الأنواع التي استخدمناها حتى الآن عبارة عن أعداد صحيحة ، وعوامات ، وسلاسل. الدوال المستخدمة للتحويل إلى هذه هي int و float و str ، على التوالي.
قناة خـــطــــوات بـــرمـــجــيــة📱
Teleg: @programmerst
🖥 🌐: https://programmerst.blogspot.com
14 · 3.2K ·