دخول Python

تثبيت Python

العديد من أجهزة الكمبيوتر PC و Mac قد قاموا بتثبيت Python.

للتحقق من whether تم تثبيت Python على جهاز الكمبيوتر Windows الخاص بك، ابحث عن Python في شريط البداية أو أعد سطر الأوامر (cmd.exe) وأدخل الأمر التالي:

C:\Users\اسمك>python --version

للتحقق من whether لديك Python مثبت على Linux أو Mac، افتح سطر الأوامر في Linux أو افتح الطرفية في Mac وأدخل الأمر التالي:

python --version

إذا كنت تجد أن Python غير مثبت على جهاز الكمبيوتر الخاص بك، يمكنك تنزيله مجانًا من الموقع التالي:

https://www.python.org/

دخول سريع لـ Python

Python لغة برمجة تفسيرية، مما يعني أنك كمطور يمكنك كتابة Python (.py) في محرر النصوص، ثم وضع هذه الملفات في معالج Python لتشغيلها.

طريقة تشغيل ملف Python في سطر الأوامر كالتالي:

C:\Users\Your Name>python helloworld.py

حيث أن "helloworld.py" هو اسم ملف Python.

دعونا نكتب أول ملف Python، يُدعى helloworld.py، يمكن إكماله في أي محرر نصي.

helloworld.py

print(\"مرحبًا، العالم!\")

تشغيل المثال

ببساطة هكذا. احفظ الملف. افتح سطر الأوامر، انتقل إلى مجلد الملف المحفوظ، ثم أعد:

C:\Users\Your Name>python helloworld.py

Output:

مرحبا بالعالم!

Congratulations, you have written and executed your first Python program.

Python Command Line

To test a small amount of code in python, writing code in a file is sometimes not the fastest or simplest. It is possible to run Python as a command line.

Type the following content on the command line in Windows, Mac, or Linux:

C:\Users\Your Name>python

Here, you can write any python, including the hello world example at the beginning of this tutorial:

C:\Users\Your Name>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("مرحبا بالعالم!")

This will output "Hello, World!" in the command line:

C:\Users\Your Name>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("مرحبا بالعالم!")
مرحبا بالعالم!

At any time, you can exit the python command line interface by typing the following command:

exit()