Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

LIBRARIES

7080806 - PYTHON PROGRAMMING 2


LIBRARIES
- A Python library is a collection of files, known as modules, that are available for other
programmers to use. These modules contain code for common programmming tasks,
ranging from interacting with hardware to accessing web pages.
BUILT-IN
MODULES
BUILT-IN MODULES
- The library that comes with every installation of Python is called the Python Standard
Library.

- It contains modules, such as Tkinter and turtle, which are available without the need to
download or install any additional code.

- Random, Datetime, Webbrowser, Turtle, Socket, Time, Tkinter


RANDOM

- This
programs
module
to
enables
include
calculations or outputs based
on random numbers.

- This can be useful when a


programmer wants to create
an element of chance.
DATETIME

- The datetime module allows a


program to work with
calendar dates and functions
that can calculate the time
between dates.
WEBBROWSER

- The webbrowser module


allows a Python program to
open a browser on the user’s
computer and display links.
TURTLE

- This Python module recreates


the turtle-shaped robot from
the programming language
Logo.

- The robot draws on the screen


as it moves around.
SOCKET

- The socket module allows a


program to communicate
across networks and the
Internet.

- This module allows programs


to create their own sockets.
TIME

- The functions in this modules


deal with time, such as those
relating to time measured buy
the computer’s processor and
time zones for different
countries.
TKINTER

- The Tkinter module allows a


programmers to create a
graphical user interface (GUI)
for their code, including
elements such as buttons and
menus.
The pygame library contains a huge number of useful modules for
coding games. Since pygame is not part of the Standard Library,
programmer have to download and install it before the can import it to
their code.
pygame is very powerful, but can be challenging for new
programmer.
One solution to this is the Pygame Zero tool, which makes the
function in pygame easier to use.

PYGAME
TEAM ALLOCATOR
TEAM ALLOCATOR
- This project will use Python’s random module to form teams, with
randomly selected players.

- You will use lists to store the player’s names.

- The random module will then shuffle this list into a different order.

- Loops will be used to iterate through the list and display the players.

- Finally, an if statement checks to see if the user is happy with the selection.
TEAM ALLOCATOR
• This project will pick two teams
and a captain for each team.
When you run the program, it will
display the chosen teams and
captains on the screen.
High-level languages
Program design
• The program begins by shuffling the player list.
• It then allocates the first half as Team 1, randomly selects a captain, and
displays the name of the captain along with the names of the rest of the
team.
• The steps are then repeated for the second half of the list – forming Team 2.
If you want to pick the teams again, the program repeats the steps,
otherwise, the program ends.
Program design
Result
HACKS AND TWEAKS
Add more players
More teams
Who starts?

You might also like