WEBVTT

00:00.000 --> 00:05.000
Review of Python basics.

00:05.000 --> 00:09.000
In this video, we will learn how to define and use functions in Python.

00:09.000 --> 00:13.000
Take user input and perform calculations.

00:13.000 --> 00:16.000
Imagine you are out shopping, and you see a sign that says,

00:16.000 --> 00:19.000
20% off on all items.

00:19.000 --> 00:24.000
You find a product you like, but now you need to calculate the final price after applying the discount.

00:24.000 --> 00:28.000
This Python program helps you do just that.

00:28.000 --> 00:30.000
Defining the function.

00:30.000 --> 00:34.000
First, we create a function called Calculate Discounted Price.

00:34.000 --> 00:37.000
This function takes two inputs.

00:37.000 --> 00:42.000
The original price of the item, before discount, and the discount percentage being offered.

00:42.000 --> 00:51.000
Inside the function, we calculate the discount amount by multiplying the original price by discount percentage, divided by 100.

00:51.000 --> 00:56.000
Now calculate final price by subtracting the discount amount from the original price.

00:56.000 --> 01:01.000
The function returns the final discounted value.

01:01.000 --> 01:04.000
Taking user input.

01:04.000 --> 01:08.000
Now, the program asks the user to enter two values.

01:08.000 --> 01:13.000
The original price of the item, and the discount percentage they want to apply.

01:13.000 --> 01:19.000
These values are collected using the input function, which takes user input as a string.

01:19.000 --> 01:23.000
Since we are dealing with numbers, we convert these inputs to float.

01:23.000 --> 01:29.000
So, the program can perform calculations correctly.

01:29.000 --> 01:32.000
Calling the function.

01:32.000 --> 01:40.000
Once the user inputs the values, the program calls the function calculate discounted price, and passes the entered values.

01:40.000 --> 01:50.000
The function then returns the final price, which is printed on the screen, displaying the result.

01:50.000 --> 01:56.000
If user enters, original price 500, and discount percentage 20.

01:56.000 --> 02:01.000
The program will calculate, and final price is formatted and printed with a dollar sign.

02:01.000 --> 02:07.000
That is, final price after discount is $400.0.

02:07.000 --> 02:16.000
This simple program helps users quickly determine the final price after applying a discount, making shopping calculations easier.

