Course Content
Introduction to Programming and Python
Overview of Python History and evolution Python’s features and benefits Set-Up Development Environment Installing Python and IDE (e.g., PyCharm, VS Code) Writing and running your first Python program Hands-On Activity Write a simple Python program to display “Hello, World!”
0/3
Structure Of A Python Program
A comprehensive overview of the structure of a Python program, covering essential concepts efficiently.
0/1
Basic Syntax and Control Statements
Basic Syntax Structure of a Python program Data types, variables, and operators
0/3
Object-Oriented Programming (OOP)
0/3
Python Programming For Beginners
About Lesson

Importing and Using Modules

  • Definition: A module is a file containing Python code (functions, classes, variables) that can be imported and used in other Python programs.
  • Built-in Modules: Python comes with a standard library of modules (e.g., mathossys). python
    import math print(math.sqrt(16)) # Output: 4.0
  • Importing Modules:
    • Entire Module: import module_name
    • Specific Function/Class: from module_name import function_name
    • Alias: import module_name as alias

    python

    from math import sqrt print(sqrt(16)) # Output: 4.0 import math as m print(m.sqrt(16)) # Output: 4.0

Creating Your Own Modules

  • Definition: Custom modules can be created by saving Python code in a .py file and importing it into other programs.
  • Example:
    1. Create a module (my_module.py):
      python

      def greet(name): return f"Hello, {name}!"
    2. Import and use the module:
      python

      import my_module print(my_module.greet("Alice")) # Output: Hello, Alice!
PAGE TOP