WEBVTT

00:00.000 --> 00:05.000
Parameters and return values and functions.

00:05.000 --> 00:11.000
In this video, we will learn how to use functions with return values.

00:11.000 --> 00:15.000
Display user input effectively.

00:15.000 --> 00:18.000
Functions are a fundamental part of programming.

00:18.000 --> 00:21.000
They can take input parameters and return a result.

00:21.000 --> 00:24.000
Now, let's use them in a practical program.

00:24.000 --> 00:29.000
We'll create an energy saver program that calculates the electricity consumption of a device.

00:30.000 --> 00:36.000
Energy saver program helps you calculate how much energy your device is used daily and monthly.

00:36.000 --> 00:42.000
Just enter the wattage and usage hours, and the program will show the energy consumption in kilowatt hours.

00:42.000 --> 00:47.000
It's a simple way to understand and save energy.

00:47.000 --> 00:50.000
Define a function to calculate energy.

00:50.000 --> 00:53.000
Def calculate energy, wattage hours.

00:53.000 --> 00:58.000
Daily energy is equal to wattage asterisk hours.

00:58.000 --> 01:04.000
Divided by 1000, monthly energy is equal to daily energy asterisk 30.

01:04.000 --> 01:13.000
Return, daily energy, KWH, daily energy, monthly energy, KWH, monthly energy.

01:13.000 --> 01:18.000
This function takes two inputs, wattage and hours.

01:18.000 --> 01:27.000
It calculates, daily energy, wattage asterisk hours, divided by 1000, to convert watts to kilowatt hours.

01:28.000 --> 01:34.000
Monthly energy, daily energy asterisk 30, assuming 30 days in a month.

01:34.000 --> 01:38.000
It returns the results as a dictionary, a labeled list.

01:38.000 --> 01:45.000
Welcome and device setup, print, welcome to the energy saver program.

01:45.000 --> 01:50.000
Devices is equal to lamp, fan, computer.

01:50.000 --> 01:52.000
Results is equal to braces.

01:52.000 --> 01:55.000
The program welcomes the user and lists the devices.

01:55.000 --> 01:59.000
Lamp, fan, and computer.

01:59.000 --> 02:02.000
Take user input.

02:02.000 --> 02:08.000
For device and devices, print F, backslash N, enter details for device.

02:08.000 --> 02:14.000
wattage is equal to float, input, wattage and watts.

02:14.000 --> 02:20.000
Hours is equal to float, input, hours of usage per day.

02:20.000 --> 02:26.000
Results, device is equal to calculate energy, wattage hours.

02:26.000 --> 02:30.000
For each device, it asks for the wattage and hours of usage.

02:30.000 --> 02:34.000
It calculates the energy using the calculate energy function.

02:34.000 --> 02:38.000
It stores the results in the results dictionary.

02:38.000 --> 02:40.000
Display the results.

02:40.000 --> 02:45.000
Print, backslash N, energy consumption report.

02:45.000 --> 02:49.000
For device, consumption and results dot items.

02:49.000 --> 02:53.000
Print, F, backslash N, device.

02:53.000 --> 02:56.000
For key, value and consumption dot items.

02:56.000 --> 03:02.000
Print, F, key, value dot 2F.

03:02.000 --> 03:06.000
The program prints a report showing the energy consumption for each device.

03:06.000 --> 03:13.000
For each device, it shows daily energy in kilowatt hours, monthly energy in kilowatt hours.

03:13.000 --> 03:17.000
The results are rounded to two decimal places for easy reading.

03:17.000 --> 03:22.000
Save the program with a name like, energysaverprogram.py.

03:22.000 --> 03:30.000
Click the Run button and check the energy consumption report to see the daily and monthly energy usage for each device.

03:30.000 --> 03:38.000
This program helps you understand how much energy your device is used and how to save energy.

