WEBVTT

00:00.000 --> 00:16.400
In this video, we will learn how Python modules work, apply math and logic in programming,

00:16.400 --> 00:18.560
what are modules.

00:18.560 --> 00:23.800
Modules are Python toolkits with ready-to-use functions and tools, saving time by providing

00:23.800 --> 00:29.960
pre-built solutions for tasks like math, dates, or random selections.

00:29.960 --> 00:34.760
Let's understand how modules work by developing a real-life program, a water conservation

00:34.760 --> 00:36.280
tracker.

00:36.280 --> 00:41.320
This program will use modules like date time and random to calculate water savings, share

00:41.320 --> 00:47.080
daily tips, and track your family's progress in saving water.

00:47.080 --> 00:49.840
Import libraries and setup.

00:49.840 --> 00:51.080
Import date time.

00:51.080 --> 00:54.560
It provides classes for manipulating dates and times.

00:54.560 --> 00:55.760
Import random.

00:55.760 --> 00:58.760
It generates random numbers and selections.

00:58.760 --> 01:01.760
First we need to collect information from the user.

01:01.760 --> 01:05.480
Family members is equal to int input.

01:05.480 --> 01:10.200
Enter the number of family members.

01:10.200 --> 01:14.800
Time reduced is equal to int input.

01:14.800 --> 01:21.600
Enter the number of minutes each person reduces their shower time.

01:21.600 --> 01:25.880
We ask for the number of family members and how many minutes each person reduces their

01:25.880 --> 01:27.600
shower time.

01:27.600 --> 01:33.960
Now that we have the user's input, we calculate how much water is saved daily.

01:33.960 --> 01:38.520
Let's say that every one minute of reduced shower time saves approximately nine liters

01:38.520 --> 01:40.320
of water.

01:40.320 --> 01:46.200
Multiply the time reduced by nine to get water saved per person.

01:46.200 --> 01:52.040
Water saved per person is equal to time reduced asterisk nine.

01:52.040 --> 01:58.040
Multiply it by the number of family members to get the total daily water savings.

01:58.040 --> 02:04.640
Total water saved is equal to family members asterisk water saved per person.

02:04.640 --> 02:07.320
Print F backslash in.

02:07.320 --> 02:12.000
Your family saves approximately total water saved.

02:12.000 --> 02:15.200
Leaders of water per day.

02:15.200 --> 02:17.200
Randomized tip generation.

02:17.200 --> 02:20.640
This add a random tip that helps people save water.

02:20.640 --> 02:22.400
Create a list of tips.

02:22.400 --> 02:25.440
Tips is equal to open bracket.

02:25.440 --> 02:29.480
Turn off the tap while brushing your teeth.

02:29.480 --> 02:32.920
Fix leaky faucets to save water.

02:32.920 --> 02:35.960
Collect rainwater for watering plants.

02:35.960 --> 02:40.600
Use a bucket instead of a hose to wash your car.

02:40.600 --> 02:44.480
Only run your washing machine with a full load.

02:44.480 --> 02:45.960
Make bracket.

02:45.960 --> 02:53.240
Daily tip is equal to random dot choice tips print F backslash in today's water saving

02:53.240 --> 02:55.640
tip daily tip.

02:55.640 --> 03:01.080
Here we use the random dot choice function to select a tip randomly date manipulation

03:01.080 --> 03:02.760
with date time.

03:02.760 --> 03:07.600
We want to track how long the family has been following their water saving habit so ask

03:07.600 --> 03:13.440
the user to enter the start date start date is equal to input enter the start date of

03:13.440 --> 03:18.240
the initiative year month date.

03:18.240 --> 03:25.200
Start date object is equal to date time dot date time dot stearup time start date percent

03:25.200 --> 03:33.520
why percent M percent D dot date date time dot stearup time converts the users input into

03:33.520 --> 03:35.000
a date format.

03:35.000 --> 03:40.080
So we can calculate the difference between today's date and the start date current date is

03:40.080 --> 03:47.880
equal to date time dot date dot today days elapsed is equal to current date minus start

03:47.880 --> 03:55.160
date object dot days print F backslash in the water conservation initiative has been

03:55.160 --> 04:01.760
running for days elapsed days date time module is used to calculate how many days have passed

04:01.760 --> 04:09.200
since that date output and formatting now we display all the information in a clear

04:09.200 --> 04:19.280
and organized summary print backslash in water conservation tracker summary print F one

04:19.280 --> 04:28.280
total water saved daily by your family total water saved leaders print F two days since

04:28.280 --> 04:38.600
the initiative started days elapsed days print F three today's tip daily tip

04:39.560 --> 04:43.960
this gives the user a final report of their water saving efforts save the program with

04:43.960 --> 04:50.840
a name like water conservation tracker click run button to see your daily water savings

04:50.840 --> 04:59.680
days tracked and a water saving tip now we learned how to take user input perform calculations

04:59.680 --> 05:02.800
use randomization and track days in Python

