Skip to content

Programming Essentials in Python Lecture 1

What is a Computer?

  • A computer is a device capable of performing computations and making logical decisions at speeds exceeding human capabilities.
  • Example:
    • Personal computers perform hundreds of millions or billions of additions per second.
    • Supercomputers can handle hundreds of billions of additions per second.

Components of a Computer:

  1. Hardware: Physical components of a computer, like the keyboard, screen, mouse, and processor.
  2. Software: Programs and instructions that tell the computer what to do.

Types of Software

  1. System Software: Core functions, like operating systems, disk management, and hardware management.
  2. Programming Software: Tools for coding, such as text editors, compilers, and debuggers.
  3. Application Software: Apps that assist users in tasks, like productivity suites and media players.
  4. Embedded Software: Controls devices not typically considered computers (e.g., cars, IoT devices).

Software Development Roles

  • Programmers: Write code for specific tasks (e.g., processing orders, displaying graphics).
  • Software Engineers: Apply engineering principles to build scalable, problem-solving software.
  • Software Developers: Oversee specific project areas, manage teams, and handle the software development lifecycle.

Software Development Life Cycle (SDLC):

  1. Requirements Analysis
  2. Design & Development
  3. Testing
  4. Deployment
  5. Maintenance & Support

Python Language

  • Python is a popular, high-level programming language created by Guido van Rossum in 1991.
  • Known for ease of learning and rich libraries, Python is cross platform and supports object-oriented programming (OOP).

Common Uses for Python:

  • Software & Web Development
  • Data Science & Machine Learning
  • System Scripting & Automation
  • Cybersecurity & Ethical Hacking

Advantages of Python:

  1. Easy to learn with extensive documentation.
  2. Cross-platform compatibility (Windows, Linux, Mac).
  3. Free, open-source, and compatible with other languages (e.g., C, Java).
  4. Supports multitasking, databases, and user interfaces.

Python Interpreter

  • Converts high-level Python code into machine code.
  • Steps:
    1. Analyzes source code.
    2. Generates bytecode (.pyc file).
    3. Uses Python Virtual Machine (PVM) to execute code.

What Is the Difference Between a Python Interpreter and a Compiler?

AspectInterpreterCompiler
TransformationInterpreters translate programs one statement at a time.Compilers scan the entire program first, then translate it into machine code in one go.
Translation ProcessInterprets source code line-by-line.Translates entire source code into machine code before execution.
Time to AnalyzeUsually faster to analyze source code since it translates line-by-line.Typically slower to analyze as it requires processing the entire program at once.
Execution SpeedGenerally slower as it executes code one statement at a time.Generally faster because the entire code is already compiled into machine language.
Memory EfficiencyMore memory efficient as it does not generate object code.Less memory efficient as it creates object code that needs to be stored.

Code Editors vs. IDEs

  • Code Editor: Lightweight tools for writing/editing code with syntax highlighting (e.g., Visual Studio Code).
  • IDE (Integrated Development Environment): Comprehensive tools that include code writing, debugging, testing, and more (e.g., PyCharm).

Popular Python IDEs and Editors:

  1. PyCharm (IDE)
  2. Visual Studio Code (Editor)
  3. Jupyter Notebook (Web-based IDE)
  4. Spyder (IDE)
  5. Sublime Text (Editor)
  6. Thonny (IDE)
  7. Atom (Editor)