Modules in Python (Python Part 6)

This class will teach you the basics of using Modules, Functions and PIP in Python.

  • 00:00 Intro
  • 05:37 PIP
  • 20:19 Hackers and Modules
  • 28:05 Import a Specific Function from a Module
  • 30:56 Import Modules
  • 32:13 Import All Functions from a Module
  • 34:34 Module Aliases
  • 36:25 Module Examples
  • 40:46 Name Space
  • 44:14 Final Thoughts

PyPI.org

https://pypi.org/

Install PIP3 on Ubuntu

sudo apt install python3-pip

PIP3 Commands

pip3 install PACKAGE

pip3 list

pip3 uninstall PACKAGE

function.py

from random import randint

number = randint(0,100)

print(number)

modules.py

import random

number = random.randint(0,100)

print(number)

all-functions.py

from random import *

number = randint(0,100)

print(number)

alias.py

import random as stupid_name

number = stupid_name.randint(0,100)

print(number)

module-example.py

import os
import datetime
import time

while True:
    os.system('clear')
    timestamp = datetime.datetime.now()
    print(timestamp)
    time.sleep(1)

Be the first to comment

Leave a Reply