Facebook Pixel
Searching...
العربية
EnglishEnglish
EspañolSpanish
简体中文Chinese
FrançaisFrench
DeutschGerman
日本語Japanese
PortuguêsPortuguese
ItalianoItalian
한국어Korean
РусскийRussian
NederlandsDutch
العربيةArabic
PolskiPolish
हिन्दीHindi
Tiếng ViệtVietnamese
SvenskaSwedish
ΕλληνικάGreek
TürkçeTurkish
ไทยThai
ČeštinaCzech
RomânăRomanian
MagyarHungarian
УкраїнськаUkrainian
Bahasa IndonesiaIndonesian
DanskDanish
SuomiFinnish
БългарскиBulgarian
עבריתHebrew
NorskNorwegian
HrvatskiCroatian
CatalàCatalan
SlovenčinaSlovak
LietuviųLithuanian
SlovenščinaSlovenian
СрпскиSerbian
EestiEstonian
LatviešuLatvian
فارسیPersian
മലയാളംMalayalam
தமிழ்Tamil
اردوUrdu
Python Programming for Beginners

Python Programming for Beginners

An Introduction to the Python Computer Language and Computer Programming
بواسطة Jason Cannon 2014 151 صفحات
3.91
100+ تقييمات
استمع
استمع

النقاط الرئيسية

1. أساسيات بايثون: المتغيرات، السلاسل النصية، والأرقام

المتغيرات هي مواقع تخزين لها اسم.

المتغيرات وأنواع البيانات. توفر بايثون عدة أنواع بيانات أساسية، بما في ذلك السلاسل النصية، الأعداد الصحيحة، والأعداد العشرية. يتم إنشاء المتغيرات باستخدام عامل الإسناد (=) ويمكنها تخزين أي من هذه الأنواع. تُحاط السلاسل النصية بعلامات اقتباس وتدعم عمليات مختلفة مثل الدمج والتكرار.

التلاعب بالسلاسل النصية. تقدم بايثون دوال وطرق مدمجة للعمل مع السلاسل النصية:

  • len(): يعيد طول السلسلة النصية
  • upper() و lower(): تحويل السلاسل النصية إلى أحرف كبيرة أو صغيرة
  • format(): يسمح بإدراج القيم داخل السلاسل النصية
  • الفهرسة والتقطيع: الوصول إلى الأحرف الفردية أو الأجزاء الفرعية من السلسلة

العمليات العددية. تدعم بايثون العمليات الحسابية الأساسية (+، -، *، /) بالإضافة إلى العمليات الأكثر تقدمًا مثل الأس (**) والباقي (%). كما توفر اللغة دوال مدمجة لتحويل الأنواع (int()، float()، str()) والعمليات الرياضية (max()، min()).

2. تدفق التحكم: القيم البوليانية، العبارات الشرطية، والدوال

تسمح لك الدوال بكتابة كتلة من كود بايثون مرة واحدة واستخدامها عدة مرات.

المنطق البولياني. تستخدم بايثون True و False كقيم بوليانية. تُستخدم عوامل المقارنة (==، !=، >، <، >=، <=) والعوامل المنطقية (and، or، not) لإنشاء تعبيرات بوليانية.

العبارات الشرطية. يتم إدارة تدفق التحكم باستخدام عبارات if، elif، و else:

  • if condition:

    كتلة الكود

  • elif another_condition:

    كتلة الكود

  • else:

    كتلة الكود

الدوال. تُعرّف الدوال باستخدام الكلمة المفتاحية def، تليها اسم الدالة والمعاملات. يمكنها قبول المعاملات، تنفيذ العمليات، وإرجاع القيم. تعزز الدوال إعادة استخدام الكود وتنظيمه.

3. هياكل البيانات: القوائم، القواميس، والصفوف

القائمة هي نوع بيانات يحتفظ بمجموعة مرتبة من العناصر.

القوائم. القوائم هي مجموعات قابلة للتغيير ومرتبة من العناصر. يتم إنشاؤها باستخدام الأقواس المربعة [] وتدعم عمليات مختلفة:

  • الفهرسة والتقطيع
  • append()، extend()، و insert() لإضافة العناصر
  • remove() و pop() لإزالة العناصر
  • sort() لترتيب العناصر

القواميس. القواميس هي مجموعات غير مرتبة من أزواج المفتاح والقيمة. يتم إنشاؤها باستخدام الأقواس المعقوفة {} والنقطتين لفصل المفاتيح والقيم. توفر القواميس عمليات بحث سريعة وتكون مفيدة لتخزين البيانات المهيكلة.

الصفوف. الصفوف هي مجموعات غير قابلة للتغيير ومرتبة من العناصر. يتم إنشاؤها باستخدام الأقواس () وتُستخدم غالبًا لمجموعات البيانات الثابتة. على الرغم من أن محتوياتها لا يمكن تغييرها بعد الإنشاء، يمكن تفكيك الصفوف إلى متغيرات متعددة.

4. التعامل مع الملفات: القراءة، الكتابة، والأوضاع

لفتح ملف، استخدم الدالة المدمجة open().

فتح الملفات. تُستخدم الدالة open() لفتح الملفات، مع توفر أوضاع مختلفة:

  • 'r': القراءة (الوضع الافتراضي)
  • 'w': الكتابة (يستبدل المحتوى الموجود)
  • 'a': الإلحاق
  • 'b': الوضع الثنائي

القراءة والكتابة. يمكن قراءة الملفات باستخدام دوال مثل read()، readline()، أو readlines(). تتم الكتابة باستخدام دالة write(). يُوصى باستخدام عبارة with لإغلاق الملفات تلقائيًا بعد الاستخدام.

أوضاع الملفات ومعالجة الأخطاء. تسمح أوضاع الملفات المختلفة بعمليات متنوعة، مثل القراءة، الكتابة، أو الإلحاق. من المهم معالجة الأخطاء المحتملة عند العمل مع الملفات باستخدام كتل try/except لالتقاط الاستثناءات مثل FileNotFoundError.

5. البرمجة المعيارية: استيراد وإنشاء الوحدات

وحدات بايثون هي ملفات بامتداد .py ويمكنها تنفيذ مجموعة من السمات (المتغيرات)، الطرق (الدوال)، والفئات (الأنواع).

استيراد الوحدات. يمكن استيراد الوحدات باستخدام عبارة import. يمكن استيراد دوال أو سمات محددة باستخدام from module import function. يتيح ذلك إعادة استخدام الكود وتنظيمه.

إنشاء الوحدات. يمكن إنشاء وحدات مخصصة بحفظ كود بايثون في ملفات .py. يمكن بعد ذلك استيراد هذه الوحدات واستخدامها في سكريبتات بايثون الأخرى. يمكن استخدام المتغير name لتحديد ما إذا كانت الوحدة تُشغل مباشرة أو مستوردة.

مسار البحث عن الوحدات. تستخدم بايثون مسار بحث للعثور على الوحدات. يمكن تعديل هذا المسار باستخدام متغير البيئة PYTHONPATH أو عن طريق التلاعب بـ sys.path في الكود.

6. معالجة الأخطاء: الاستثناءات وكتل Try/Except

الاستثناء هو عادةً إشارة إلى أن شيئًا ما قد حدث خطأ أو حدث غير متوقع في برنامجك.

أنواع الاستثناءات. تحتوي بايثون على العديد من أنواع الاستثناءات المدمجة، مثل ValueError، TypeError، و FileNotFoundError. تساعد هذه الأنواع في تحديد مشكلات محددة في الكود.

كتل Try/Except. يمكن التقاط الاستثناءات ومعالجتها باستخدام كتل try/except:

try:
    # كود قد يثير استثناء
except ExceptionType:
    # كود لمعالجة الاستثناء

الاستثناءات المخصصة. يمكن للمبرمجين إنشاء فئات استثناء مخصصة عن طريق الوراثة من الفئة المدمجة Exception. يتيح ذلك معالجة الأخطاء بشكل أكثر تحديدًا في التطبيقات المعقدة.

7. مكتبة بايثون القياسية: الوحدات والدوال المدمجة

يتم توزيع بايثون مع مكتبة كبيرة من الوحدات التي يمكنك الاستفادة منها.

الوحدات الشائعة في المكتبة القياسية:

  • time: للدوال المتعلقة بالوقت
  • sys: للمعلمات والدوال الخاصة بالنظام
  • os: لواجهات نظام التشغيل
  • json: لترميز وفك ترميز JSON
  • csv: لقراءة وكتابة ملفات CSV
  • random: لتوليد الأرقام العشوائية

الدوال المدمجة. توفر بايثون العديد من الدوال المدمجة التي تكون متاحة دائمًا:

  • print(): للإخراج إلى وحدة التحكم
  • input(): لإدخال المستخدم
  • len(): للحصول على طول التسلسلات
  • range(): لتوليد تسلسلات من الأرقام
  • type(): لتحديد نوع الكائن

استكشاف الوحدات. يمكن استخدام دالة dir() لاستكشاف محتويات الوحدات، مما يعرض الدوال والسمات المتاحة. توفر دالة help() وثائق مفصلة للوحدات، الدوال، والكائنات.

آخر تحديث::

FAQ

What's "Python Programming for Beginners" about?

  • Introduction to Python: The book is designed to introduce beginners to the Python programming language and computer programming concepts.
  • Step-by-step Guidance: It provides a systematic approach to learning Python, assuming no prior knowledge of programming.
  • Practical Examples: The book includes numerous examples and exercises to reinforce learning and provide hands-on experience.
  • Comprehensive Coverage: Topics range from basic concepts like variables and strings to more advanced topics like file handling and modules.

Why should I read "Python Programming for Beginners"?

  • Beginner-Friendly: It's tailored for those new to programming, making it accessible and easy to understand.
  • Practical Focus: The book emphasizes practical skills, allowing readers to apply what they learn immediately.
  • Comprehensive Resource: It covers a wide range of topics, providing a solid foundation in Python programming.
  • Free Resources: Readers can access additional resources and examples online to enhance their learning experience.

What are the key takeaways of "Python Programming for Beginners"?

  • Python Environment Setup: Learn how to install and configure Python on different operating systems.
  • Core Python Concepts: Understand variables, strings, numbers, conditionals, loops, functions, and data structures like lists, dictionaries, and tuples.
  • File Handling: Gain skills in reading from and writing to files, an essential part of many programming tasks.
  • Modules and Libraries: Discover how to use Python's standard library and create your own modules for code reuse.

How does Jason Cannon suggest setting up the Python environment?

  • Choosing Python Version: The author recommends using Python 3 for new projects, as Python 2 is considered legacy.
  • Installation Instructions: Detailed steps are provided for installing Python on Windows, Mac, and Linux systems.
  • Using IDLE: The book explains how to use IDLE, Python's Integrated Development Environment, for writing and running Python code.
  • Command Line Usage: Instructions are given for running Python programs from the command line on different operating systems.

What are the basic concepts of Python covered in the book?

  • Variables and Strings: Learn how to create and manipulate variables and strings, including string methods and formatting.
  • Numbers and Math: Understand numeric operations, type conversion, and the use of comments in code.
  • Booleans and Conditionals: Explore boolean logic, comparators, and conditional statements like if, elif, and else.
  • Functions: Discover how to define and use functions, including parameters, return values, and docstrings.

How does the book explain data structures like lists and dictionaries?

  • Lists: Learn how to create, modify, and access lists, including list methods like append, extend, and sort.
  • Dictionaries: Understand how to work with key-value pairs, adding, removing, and accessing items in a dictionary.
  • Tuples: Explore the concept of immutable lists and how to use tuple assignment for multiple variables.
  • Nesting and Looping: The book covers nesting data structures and looping through lists and dictionaries.

What file handling techniques are taught in "Python Programming for Beginners"?

  • Reading Files: Learn how to open and read files using Python's built-in functions and methods.
  • Writing Files: Understand how to write data to files, including appending and creating new files.
  • File Modes: The book explains different file modes like read, write, append, and binary modes.
  • Exception Handling: Discover how to handle exceptions when working with files to prevent program crashes.

How does Jason Cannon introduce modules and the Python Standard Library?

  • Importing Modules: Learn how to import and use modules in Python, including specific functions and attributes.
  • Standard Library: The book highlights useful modules in Python's standard library, such as time and sys.
  • Creating Modules: Instructions are provided for creating your own modules to organize and reuse code.
  • Module Search Path: Understand how Python searches for modules and how to modify the search path if needed.

What are some practical exercises included in the book?

  • To-Do List Program: Create a program that captures and displays a user's to-do list using lists and loops.
  • Word Game: Develop a fill-in-the-blank word game that uses user input and string formatting.
  • Cost Calculator: Write a program to calculate the cost of cloud hosting, incorporating numeric operations and conditionals.
  • Cat Say Program: Build a program that displays a cat "saying" user input, demonstrating string manipulation and functions.

What are the best quotes from "Python Programming for Beginners" and what do they mean?

  • "Don't Repeat Yourself (DRY):" This principle emphasizes writing reusable code to avoid redundancy and improve maintainability.
  • "Everything in Python is an object:" Highlights Python's object-oriented nature, where even basic data types are treated as objects.
  • "Errors should never pass silently:" Encourages handling exceptions explicitly to ensure robust and reliable code.
  • "Readability counts:" Stresses the importance of writing clear and understandable code, a core philosophy of Python.

How does the book address common Python errors?

  • Troubleshooting Guide: The book offers a guide to common Python errors and how to troubleshoot them effectively.
  • Error Examples: Examples of typical coding mistakes are provided, along with explanations and solutions.
  • Practice Exercises: Readers are encouraged to practice identifying and fixing errors through exercises and examples.
  • Online Resources: Additional resources are available online to help readers further understand and resolve Python errors.

What additional resources does Jason Cannon provide for learning Python?

  • Free Gifts: Readers can download a copy of "Common Python Errors" and a Python cheat sheet for quick reference.
  • Online Courses: The author offers online video training courses for further learning and skill development.
  • Other Books: Jason Cannon has authored other books on related topics, such as Linux and shell scripting, which can complement Python learning.
  • Community Support: The book encourages joining online communities and forums for support and collaboration with other learners.

مراجعات

3.91 من 5
متوسط 100+ التقييمات من Goodreads و Amazon.

يحظى كتاب "برمجة بايثون للمبتدئين" بتقييمات إيجابية في الغالب، حيث يبلغ متوسط تقييمه 3.90 من 5. يقدر القراء وضوحه وبساطته وفعاليته للمبرمجين المبتدئين. يُشيد الكتاب بشرحاته السهلة الفهم، وأمثلةه العملية، وتمارينه. تتضمن بعض الانتقادات وجود أخطاء مطبعية، وأمثلة غير فعالة في بعض الأحيان، ونقص في المحتوى المتقدم. بينما يرى البعض أنه مبالغ في سعره مقارنة بمحتواه، يعتبره الكثيرون نقطة انطلاق جيدة لتعلم أساسيات بايثون. يُوصى بالكتاب بشكل خاص للمبتدئين تمامًا، ولكنه قد يكون أقل فائدة للمبرمجين ذوي الخبرة.

عن المؤلف

جيسون كانون هو مؤلف ومدرب غزير الإنتاج متخصص في مواضيع البرمجة والتكنولوجيا. يشتهر بأسلوبه الكتابي الواضح والموجز وطرق تدريسه العملية. كتب كانون العديد من الكتب حول البرمجة، مع تركيز خاص على بايثون ولينكس. غالبًا ما تُشيد أعماله بنهجها الملائم للمبتدئين وقدرتها على تبسيط المفاهيم المعقدة إلى محتوى سهل الفهم. كما يقوم كانون بإنشاء دورات عبر الإنترنت، وتعتبر دوراته على منصة Udemy شائعة بشكل خاص بين المبرمجين الطموحين. يركز أسلوبه التدريسي على التعلم العملي من خلال الأمثلة والتمارين، مما يجعل محتواه متاحًا لأولئك الجدد في مجال البرمجة.

0:00
-0:00
1x
Dan
Andrew
Michelle
Lauren
Select Speed
1.0×
+
200 words per minute
Create a free account to unlock:
Requests: Request new book summaries
Bookmarks: Save your favorite books
History: Revisit books later
Ratings: Rate books & see your ratings
Try Full Access for 7 Days
Listen, bookmark, and more
Compare Features Free Pro
📖 Read Summaries
All summaries are free to read in 40 languages
🎧 Listen to Summaries
Listen to unlimited summaries in 40 languages
❤️ Unlimited Bookmarks
Free users are limited to 10
📜 Unlimited History
Free users are limited to 10
Risk-Free Timeline
Today: Get Instant Access
Listen to full summaries of 73,530 books. That's 12,000+ hours of audio!
Day 4: Trial Reminder
We'll send you a notification that your trial is ending soon.
Day 7: Your subscription begins
You'll be charged on Feb 27,
cancel anytime before.
Consume 2.8x More Books
2.8x more books Listening Reading
Our users love us
50,000+ readers
"...I can 10x the number of books I can read..."
"...exceptionally accurate, engaging, and beautifully presented..."
"...better than any amazon review when I'm making a book-buying decision..."
Save 62%
Yearly
$119.88 $44.99/year
$3.75/mo
Monthly
$9.99/mo
Try Free & Unlock
7 days free, then $44.99/year. Cancel anytime.
Settings
Appearance
Black Friday Sale 🎉
$20 off Lifetime Access
$79.99 $59.99
Upgrade Now →