All language subtitles for [SubtitleTools.com] Python Tutorial for Beginners - Learn Python in 5 Hours [FULL COURSE]

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

hello and welcome to this python course

hello and welcome to this python course in this full course you'll learn

in this full course you'll learn

in this full course you'll learn everything you need to get started with

everything you need to get started with

everything you need to get started with python

python

python python is the most popular programming

python is the most popular programming

python is the most popular programming language out there

language out there

language out there and is used for so many different

and is used for so many different

and is used for so many different industries

industries

industries like web development data science

like web development data science

like web development data science machine learning

machine learning

machine learning or generally for writing automation

or generally for writing automation

or generally for writing automation programs to automate repetitive tasks

programs to automate repetitive tasks

programs to automate repetitive tasks so learning python is definitely a good

so learning python is definitely a good

so learning python is definitely a good idea

idea

idea let me give you a short overview of all

let me give you a short overview of all

let me give you a short overview of all the topics i'll cover

the topics i'll cover

the topics i'll cover in this course after giving a short

in this course after giving a short

in this course after giving a short introduction to python

introduction to python

introduction to python we will start with the basic building

we will start with the basic building

we will start with the basic building blocks of programming

blocks of programming

blocks of programming the most important data types like

the most important data types like

the most important data types like strings

strings

strings numbers lists sets dictionaries

numbers lists sets dictionaries

numbers lists sets dictionaries boolean data types etc and how to work

boolean data types etc and how to work

boolean data types etc and how to work with them

with them

with them learn about variables and functions and

learn about variables and functions and

learn about variables and functions and why we need them

why we need them

why we need them write a program that accepts user input

write a program that accepts user input

write a program that accepts user input and learn how to validate the user input

and learn how to validate the user input

and learn how to validate the user input using conditionals

using conditionals

using conditionals error handling with try accept

error handling with try accept

error handling with try accept and also learn loops with while and for

and also learn loops with while and for

and also learn loops with while and for loops

loops

loops and again why we actually need them you

and again why we actually need them you

and again why we actually need them you will learn all these concepts

will learn all these concepts

will learn all these concepts with hands-on examples as a next step

with hands-on examples as a next step

with hands-on examples as a next step you will learn how to modularize your

you will learn how to modularize your

you will learn how to modularize your program by writing

program by writing

program by writing your own modules and then see how to use

your own modules and then see how to use

your own modules and then see how to use some

some

some built-in python modules with all this

built-in python modules with all this

built-in python modules with all this knowledge we can then

knowledge we can then

knowledge we can then build our next demo project to write a

build our next demo project to write a

build our next demo project to write a small program

small program

small program that accepts a goal and a deadline

that accepts a goal and a deadline

that accepts a goal and a deadline as user input and then outputs the

as user input and then outputs the

as user input and then outputs the number of days

number of days

number of days remaining till the goal deadline

remaining till the goal deadline

remaining till the goal deadline within this exercise you will learn how

within this exercise you will learn how

within this exercise you will learn how to use the date

to use the date

to use the date time module to work with dates

time module to work with dates

time module to work with dates after that you will learn about packages

after that you will learn about packages

after that you will learn about packages and comparison of package

and comparison of package

and comparison of package versus module and we will use an

versus module and we will use an

versus module and we will use an external python package in our next demo

external python package in our next demo

external python package in our next demo project

project

project in which we will automate some tasks for

in which we will automate some tasks for

in which we will automate some tasks for working with a spreadsheet file

working with a spreadsheet file

working with a spreadsheet file finally we dive into object-oriented

finally we dive into object-oriented

finally we dive into object-oriented programming

programming

programming you will learn what classes and objects

you will learn what classes and objects

you will learn what classes and objects are in programming

are in programming

are in programming and python specifically and why this

and python specifically and why this

and python specifically and why this concept is

concept is

concept is so useful in the final demo project you

so useful in the final demo project you

so useful in the final demo project you will learn another common use case with

will learn another common use case with

will learn another common use case with python

python

python which is communicating with other

which is communicating with other

which is communicating with other applications

applications

applications over the internet by making a request

over the internet by making a request

over the internet by making a request to fetch some data from gitlab api

to fetch some data from gitlab api

to fetch some data from gitlab api in this specific case we will list the

in this specific case we will list the

in this specific case we will list the gitlab projects

gitlab projects

gitlab projects of a specific user so that's what we're

of a specific user so that's what we're

of a specific user so that's what we're gonna learn

gonna learn

gonna learn if you like this course don't forget to

if you like this course don't forget to

if you like this course don't forget to give this video a thumbs up

give this video a thumbs up

give this video a thumbs up i'm really excited to teach you all of

i'm really excited to teach you all of

i'm really excited to teach you all of these so

these so

these so let's get started

first of all python is a programming

first of all python is a programming language

language

language just like java or javascript python

just like java or javascript python

just like java or javascript python compared to other languages

compared to other languages

compared to other languages has two very big advantages first of all

has two very big advantages first of all

has two very big advantages first of all it's easy to learn it has a simple

it's easy to learn it has a simple

it's easy to learn it has a simple syntax

syntax

syntax and it's very easy to set up and get

and it's very easy to set up and get

and it's very easy to set up and get started with

started with

started with for example compared to java where you

for example compared to java where you

for example compared to java where you need

need

need some initial configuration before you

some initial configuration before you

some initial configuration before you can even start your application

can even start your application

can even start your application but it's equally or even more powerful

but it's equally or even more powerful

but it's equally or even more powerful than java

than java

than java now what makes a language powerful or

now what makes a language powerful or

now what makes a language powerful or how can i say that python is more

how can i say that python is more

how can i say that python is more powerful

powerful

powerful well that comes from the ecosystem which

well that comes from the ecosystem which

well that comes from the ecosystem which means

means

means libraries and modules that python

libraries and modules that python

libraries and modules that python developers themselves develop

developers themselves develop

developers themselves develop but also external developers create and

but also external developers create and

but also external developers create and maintain

maintain

maintain so the more people adopt the language

so the more people adopt the language

so the more people adopt the language the more powerful it gets because

the more powerful it gets because

the more powerful it gets because new libraries and so new functionalities

new libraries and so new functionalities

new libraries and so new functionalities get added to it

get added to it

get added to it and the second advantage is that it's

and the second advantage is that it's

and the second advantage is that it's flexible now what does a

flexible now what does a

flexible now what does a flexible mean in this case what makes a

flexible mean in this case what makes a

flexible mean in this case what makes a language flexible

language flexible

language flexible it is easy to mold to your wishes

it is easy to mold to your wishes

it is easy to mold to your wishes so you are not limited or restricted by

so you are not limited or restricted by

so you are not limited or restricted by the language specifics like

the language specifics like

the language specifics like syntax or data types or some other

syntax or data types or some other

syntax or data types or some other constraints

constraints

constraints or even library functionalities you can

or even library functionalities you can

or even library functionalities you can extend

extend

extend python widely and as one of the results

python widely and as one of the results

python widely and as one of the results of this flexibility

of this flexibility

of this flexibility python also became a multi-purpose

python also became a multi-purpose

python also became a multi-purpose language

language

language meaning it is used for many different

meaning it is used for many different

meaning it is used for many different categories

categories

categories so let's see what these categories are

first you can use it to write web

first you can use it to write web applications the popular libraries for

applications the popular libraries for

applications the popular libraries for that are django

that are django

that are django or more lightweight flask python became

or more lightweight flask python became

or more lightweight flask python became extremely popular because of the rise of

extremely popular because of the rise of

extremely popular because of the rise of data science

data science

data science machine learning and artificial

machine learning and artificial

machine learning and artificial intelligence

intelligence

intelligence industries and more and more libraries

industries and more and more libraries

industries and more and more libraries were created

were created

were created and are still being added for python for

and are still being added for python for

and are still being added for python for all these categories

all these categories

all these categories they are very popular and highly used

they are very popular and highly used

they are very popular and highly used libraries for

libraries for

libraries for data analysis and data visualization

data analysis and data visualization

data analysis and data visualization libraries for

libraries for

libraries for artificial intelligence projects for

artificial intelligence projects for

artificial intelligence projects for things like

things like

things like face recognition voice recognition and a

face recognition voice recognition and a

face recognition voice recognition and a bunch of very powerful

bunch of very powerful

bunch of very powerful and widely used machine learning

and widely used machine learning

and widely used machine learning libraries

libraries

libraries python is also often used for data

python is also often used for data

python is also often used for data collection

collection

collection like scraping the web creating web

like scraping the web creating web

like scraping the web creating web crawlers

crawlers

crawlers that are basically programs that collect

that are basically programs that collect

that are basically programs that collect data from internet

data from internet

data from internet which you can save and then process

which you can save and then process

which you can save and then process later again

later again

later again many different powerful libraries to do

many different powerful libraries to do

many different powerful libraries to do all of that

all of that

all of that and finally automation with python

and finally automation with python

and finally automation with python python has many great libraries to

python has many great libraries to

python has many great libraries to automate

automate

automate devops tasks for example starting from

devops tasks for example starting from

devops tasks for example starting from ci cd

ci cd

ci cd pipelines to cloud platforms and

pipelines to cloud platforms and

pipelines to cloud platforms and monitoring your infrastructure

monitoring your infrastructure

monitoring your infrastructure etc you can also write python scripts to

etc you can also write python scripts to

etc you can also write python scripts to do

do

do automated backups cleanups on the

automated backups cleanups on the

automated backups cleanups on the servers etc

servers etc

servers etc in addition to devops tasks you can also

in addition to devops tasks you can also

in addition to devops tasks you can also automate

automate

automate just general tasks with python like when

just general tasks with python like when

just general tasks with python like when working with

working with

working with excel sheets which is a common use case

excel sheets which is a common use case

excel sheets which is a common use case in many big companies

in many big companies

in many big companies or automating some tasks on your own

or automating some tasks on your own

or automating some tasks on your own laptop

laptop

laptop and there are also libraries for mobile

and there are also libraries for mobile

and there are also libraries for mobile development

development

development gaming desktop applications but

gaming desktop applications but

gaming desktop applications but these are less likely use cases for

these are less likely use cases for

these are less likely use cases for python because there are better

python because there are better

python because there are better alternatives

alternatives

alternatives for that so you see that the use cases

for that so you see that the use cases

for that so you see that the use cases for python are pretty vast and it

for python are pretty vast and it

for python are pretty vast and it actually spans

actually spans

actually spans several industries and it's mostly

several industries and it's mostly

several industries and it's mostly concentrated

concentrated

concentrated around data analytics machine learning

around data analytics machine learning

around data analytics machine learning and automation

and automation

and automation areas and note that this isn't the case

areas and note that this isn't the case

areas and note that this isn't the case for many other programming languages

for many other programming languages

for many other programming languages usually one programming language is good

usually one programming language is good

usually one programming language is good for just

for just

for just few things and you should use something

few things and you should use something

few things and you should use something else

else

else for other use cases so now you see how

for other use cases so now you see how

for other use cases so now you see how useful

useful

useful python knowledge could be and how it can

python knowledge could be and how it can

python knowledge could be and how it can help you

help you

help you in your job but also make you more

in your job but also make you more

in your job but also make you more valuable at your work and for your

valuable at your work and for your

valuable at your work and for your entire team

entire team

entire team i hope you are already excited to learn

i hope you are already excited to learn

i hope you are already excited to learn python so let's get started

python so let's get started

python so let's get started as a first step we're going to configure

as a first step we're going to configure

as a first step we're going to configure our local

our local

our local python development environment so the

python development environment so the

python development environment so the first thing we need

first thing we need

first thing we need is install python locally

is install python locally

is install python locally on our laptop so first we

on our laptop so first we

on our laptop so first we install or download python package

install or download python package

install or download python package for your specific operating system and

for your specific operating system and

for your specific operating system and then basically just click through the

then basically just click through the

then basically just click through the installer

installer

installer wizard to install python

wizard to install python

wizard to install python locally on your laptop

locally on your laptop

locally on your laptop and note that if you're doing this on

and note that if you're doing this on

and note that if you're doing this on windows

windows

windows very important step in the installation

very important step in the installation

very important step in the installation process would be to

process would be to

process would be to check the ed python to

check the ed python to

check the ed python to path option basically that you see here

path option basically that you see here

path option basically that you see here because by default it is unchecked and

because by default it is unchecked and

because by default it is unchecked and you have to

you have to

you have to check mark it so that after the

check mark it so that after the

check mark it so that after the installation

installation

installation you'll be able to execute python

you'll be able to execute python

you'll be able to execute python commands in your terminal

commands in your terminal

commands in your terminal now an interesting note here if you're

now an interesting note here if you're

now an interesting note here if you're using mac os

using mac os

using mac os like i do is that by default

like i do is that by default

like i do is that by default on mac os there is python already

on mac os there is python already

on mac os there is python already installed

installed

installed so if i do python version

so if i do python version

so if i do python version and execute i see that python version

and execute i see that python version

and execute i see that python version 2.7

2.7

2.7 10 is installed and that is actually

10 is installed and that is actually

10 is installed and that is actually python

python

python that mac os the operating system itself

that mac os the operating system itself

that mac os the operating system itself is using

is using

is using however for our tutorial and generally

however for our tutorial and generally

however for our tutorial and generally when working with python

when working with python

when working with python we want to be using the newest version

we want to be using the newest version

we want to be using the newest version which is

which is

which is python 3. so we're going to leave that

python 3. so we're going to leave that

python 3. so we're going to leave that default python installation

default python installation

default python installation alone we're not going to use that or

alone we're not going to use that or

alone we're not going to use that or touched it and instead we're going to be

touched it and instead we're going to be

touched it and instead we're going to be using

using

using the python version 3 that we just

the python version 3 that we just

the python version 3 that we just installed locally

installed locally

installed locally so now if i clean this up and we want to

so now if i clean this up and we want to

so now if i clean this up and we want to execute

execute

execute python version 3 commands we're going to

python version 3 commands we're going to

python version 3 commands we're going to do python 3 instead

do python 3 instead

do python 3 instead and version and that will give us the

and version and that will give us the

and version and that will give us the version so that's how we can

version so that's how we can

version so that's how we can differentiate between

differentiate between

differentiate between the already installed python and

the already installed python and

the already installed python and the newest version that we just

the newest version that we just

the newest version that we just installed so just be

installed so just be

installed so just be aware of that difference

now that we have python available

now that we have python available locally it's time to

locally it's time to

locally it's time to download a code editor for python

download a code editor for python

download a code editor for python because we're going to be writing files

because we're going to be writing files

because we're going to be writing files with python code

with python code

with python code so we need a proper editor for writing

so we need a proper editor for writing

so we need a proper editor for writing python code

python code

python code and actually the best python code editor

and actually the best python code editor

and actually the best python code editor available

available

available out there currently is pycharm which is

out there currently is pycharm which is

out there currently is pycharm which is from jetbrains

from jetbrains

from jetbrains so that's what we're going to be using

so that's what we're going to be using

so that's what we're going to be using throughout our tutorial

throughout our tutorial

throughout our tutorial so let's go to pycharm it is an

so let's go to pycharm it is an

so let's go to pycharm it is an intelligent code editor which makes it

intelligent code editor which makes it

intelligent code editor which makes it much easier to write code so it makes

much easier to write code so it makes

much easier to write code so it makes you actually very productive when

you actually very productive when

you actually very productive when writing code

writing code

writing code and we will see why throughout the

and we will see why throughout the

and we will see why throughout the course as you can see there are two

course as you can see there are two

course as you can see there are two versions

versions

versions we have the community version and

we have the community version and

we have the community version and professional one community version is

professional one community version is

professional one community version is free and

free and

free and already has a lot of powerful features

already has a lot of powerful features

already has a lot of powerful features but the professional edition

but the professional edition

but the professional edition gives you additional very useful

gives you additional very useful

gives you additional very useful features especially if you're creating

features especially if you're creating

features especially if you're creating web applications

web applications

web applications or scientific projects in python so with

or scientific projects in python so with

or scientific projects in python so with professional

professional

professional version additionally you will get

version additionally you will get

version additionally you will get scientific tools that you can use

scientific tools that you can use

scientific tools that you can use in scientific projects with python but

in scientific projects with python but

in scientific projects with python but also you get support for

also you get support for

also you get support for python web frameworks and database

python web frameworks and database

python web frameworks and database integration which can be of course

integration which can be of course

integration which can be of course very helpful if you're developing web

very helpful if you're developing web

very helpful if you're developing web applications if you want to get the

applications if you want to get the

applications if you want to get the professional edition jetbrains actually

professional edition jetbrains actually

professional edition jetbrains actually provided me with a code

provided me with a code

provided me with a code for my channel to try it out for three

for my channel to try it out for three

for my channel to try it out for three months for free

months for free

months for free just use my code when you install it but

just use my code when you install it but

just use my code when you install it but for this demo

for this demo

for this demo community version is absolutely fine so

community version is absolutely fine so

community version is absolutely fine so i will go with this one and

i will go with this one and

i will go with this one and install it and just click download

install it and just click download

install it and just click download and once the pycharm installer is

and once the pycharm installer is

and once the pycharm installer is fully downloaded we can just click on it

move it to the application and now i can

move it to the application and now i can actually use it

actually use it

actually use it locally so i'm just gonna open the

locally so i'm just gonna open the

locally so i'm just gonna open the application

application

application and we're gonna take a quick tour around

and we're gonna take a quick tour around

and we're gonna take a quick tour around pychar

it's actually pretty simple to set it up

it's actually pretty simple to set it up and there you go

and there you go

and there you go we have our pycharm and we can now

we have our pycharm and we can now

we have our pycharm and we can now create

create

create a new project and let's call it

a new project and let's call it

a new project and let's call it my python project

my python project

my python project and that's it basically we don't need to

and that's it basically we don't need to

and that's it basically we don't need to change anything else

change anything else

change anything else and here you see the location basically

and here you see the location basically

and here you see the location basically of where this application

of where this application

of where this application folder will be created you see pycharm

folder will be created you see pycharm

folder will be created you see pycharm projects

projects

projects folder got created in my users directory

folder got created in my users directory

folder got created in my users directory so this is basically very convenient

so this is basically very convenient

so this is basically very convenient because all my

because all my

because all my pycharm projects or my python projects

pycharm projects or my python projects

pycharm projects or my python projects that i create using pycharm

that i create using pycharm

that i create using pycharm will be created in one location and here

will be created in one location and here

will be created in one location and here you also see that python

you also see that python

you also see that python version 3 that we installed is

version 3 that we installed is

version 3 that we installed is automatically

automatically

automatically being used for this project which is

being used for this project which is

being used for this project which is exactly what we want

exactly what we want

exactly what we want and you see it says base interpreter

and you see it says base interpreter

and you see it says base interpreter and python interpreter is basically

and python interpreter is basically

and python interpreter is basically a program that knows how to execute

a program that knows how to execute

a program that knows how to execute python code it will know how to

python code it will know how to

python code it will know how to interpret or translate

interpret or translate

interpret or translate our python code into instructions

our python code into instructions

our python code into instructions that computer can understand so with

that computer can understand so with

that computer can understand so with this configuration we don't have to

this configuration we don't have to

this configuration we don't have to change anything

change anything

change anything we're gonna create our project so first

we're gonna create our project so first

we're gonna create our project so first of all i'm going to

of all i'm going to

of all i'm going to make all this a little bit bigger so

make all this a little bit bigger so

make all this a little bit bigger so that you can see

that you can see

that you can see the menu here on the side and the code

the menu here on the side and the code

the menu here on the side and the code a little bit better so in preferences

a little bit better so in preferences

a little bit better so in preferences editor font we're going to set the size

editor font we're going to set the size

editor font we're going to set the size to 20. if i apply this

to 20. if i apply this

to 20. if i apply this right here you see that this code editor

right here you see that this code editor

right here you see that this code editor font basically got bigger and i also

font basically got bigger and i also

font basically got bigger and i also want to

want to

want to increase the size of this menu font here

increase the size of this menu font here

increase the size of this menu font here so in

so in

so in appearance i'm going to

appearance i'm going to

appearance i'm going to set it to maybe 18 and there you go

set it to maybe 18 and there you go

set it to maybe 18 and there you go so basically everything is bigger now so

so basically everything is bigger now so

so basically everything is bigger now so you can follow along and see exactly

you can follow along and see exactly

you can follow along and see exactly what i'm typing

what i'm typing

what i'm typing and also another note here if you want

and also another note here if you want

and also another note here if you want to configure

to configure

to configure your theme basically so if you don't

your theme basically so if you don't

your theme basically so if you don't want it to be dark

want it to be dark

want it to be dark or maybe you want some other color

or maybe you want some other color

or maybe you want some other color scheme then you can select it here

scheme then you can select it here

scheme then you can select it here in appearance you have four themes

in appearance you have four themes

in appearance you have four themes available

available

available let's actually try this one out

let's actually try this one out

let's actually try this one out and apply and there you go you have a

and apply and there you go you have a

and apply and there you go you have a different theme i actually prefer this

different theme i actually prefer this

different theme i actually prefer this one so

one so

one so let's leave it at that so as you see we

let's leave it at that so as you see we

let's leave it at that so as you see we have a very simple

have a very simple

have a very simple project with one

project with one

project with one main main.pi file the extension is for

main main.pi file the extension is for

main main.pi file the extension is for python files

python files

python files which basically contains very simple

which basically contains very simple

which basically contains very simple code

code

code and we're gonna basically just remove

and we're gonna basically just remove

and we're gonna basically just remove all of these

all of these

all of these and start from a clean python

and start from a clean python

and start from a clean python file state and in the next section we're

file state and in the next section we're

file state and in the next section we're gonna

gonna

gonna dive right in and write our first

dive right in and write our first

dive right in and write our first simple python application

we're gonna start with the simplest

we're gonna start with the simplest example in python

example in python

example in python to basically learn python syntax and

to basically learn python syntax and

to basically learn python syntax and get started as simply as possible so

get started as simply as possible so

get started as simply as possible so first of all

first of all

first of all we're gonna write a very simple

we're gonna write a very simple

we're gonna write a very simple application that just

application that just

application that just prints some output and in python when we

prints some output and in python when we

prints some output and in python when we want to print

want to print

want to print basically display results of what we

basically display results of what we

basically display results of what we wrote

wrote

wrote we use this syntax where we say print

we use this syntax where we say print

we use this syntax where we say print and

and

and here we can pass in basically whatever

here we can pass in basically whatever

here we can pass in basically whatever we want to display

we want to display

we want to display and now if i want to see whether this

and now if i want to see whether this

and now if i want to see whether this super simple application works

super simple application works

super simple application works i can run it or execute it

i can run it or execute it

i can run it or execute it with this triangle here and i have the

with this triangle here and i have the

with this triangle here and i have the output so the basically the output

output so the basically the output

output so the basically the output is displayed or printed right here and i

is displayed or printed right here and i

is displayed or printed right here and i see

see

see the output is 1. i can display some

the output is 1. i can display some

the output is 1. i can display some other values

other values

other values like 200 and run it and there you go

like 200 and run it and there you go

like 200 and run it and there you go let's say we want to display some text

basically whatever some sentence and

basically whatever some sentence and again

again

again triangle and we have that output here

triangle and we have that output here

triangle and we have that output here right

right

right so again very simple example of

so again very simple example of

so again very simple example of writing python code that basically

writing python code that basically

writing python code that basically displays some information when we

displays some information when we

displays some information when we execute it

one thing that i want to note here is

one thing that i want to note here is you see that we write some code

you see that we write some code

you see that we write some code basically

basically

basically in this window right here so in our

in this window right here so in our

in this window right here so in our main.pi

main.pi

main.pi file and when we run it

file and when we run it

file and when we run it or execute it our code we see some

or execute it our code we see some

or execute it our code we see some display in this window so you may be

display in this window so you may be

display in this window so you may be wondering what is this window and why do

wondering what is this window and why do

wondering what is this window and why do we see

we see

we see some output right here the answer to

some output right here the answer to

some output right here the answer to that is that whenever you're working

that is that whenever you're working

that is that whenever you're working with

with

with tools like pycharm which basically

tools like pycharm which basically

tools like pycharm which basically have all the functionality that you need

have all the functionality that you need

have all the functionality that you need to

to

to write your code and then execute your

write your code and then execute your

write your code and then execute your code you basically have everything in

code you basically have everything in

code you basically have everything in one place

one place

one place so whatever we write we can execute or

so whatever we write we can execute or

so whatever we write we can execute or run

run

run right away now without such tool how

right away now without such tool how

right away now without such tool how would we

would we

would we write code and how would we execute that

write code and how would we execute that

write code and how would we execute that code and this will help you understand

code and this will help you understand

code and this will help you understand what's going on

what's going on

what's going on here and to show that i'm going to go

here and to show that i'm going to go

here and to show that i'm going to go back to my terminal

back to my terminal

back to my terminal and i'm going to create a new file and

and i'm going to create a new file and

and i'm going to create a new file and i'm going to call it

i'm going to call it

i'm going to call it test dot py

code basically in this file

code basically in this file you can do it in a file editor i'm just

you can do it in a file editor i'm just

you can do it in a file editor i'm just doing it directly in the command line

doing it directly in the command line

doing it directly in the command line and save it so now we have the same

and save it so now we have the same

and save it so now we have the same identical

identical

identical file as here

file as here

file as here but not inside our code editor right

but not inside our code editor right

but not inside our code editor right not inside this pycharm tool and we have

not inside this pycharm tool and we have

not inside this pycharm tool and we have python 3 available locally so

python 3 available locally so

python 3 available locally so now how do i actually execute a python

now how do i actually execute a python

now how do i actually execute a python file outside this pie chart

file outside this pie chart

file outside this pie chart i can do that using python 3 test

i can do that using python 3 test

i can do that using python 3 test dot p y and if i do that

dot p y and if i do that

dot p y and if i do that i get the same output in the command

i get the same output in the command

i get the same output in the command line

line

line so basically what you see right here

so basically what you see right here

so basically what you see right here this whole thing

this whole thing

this whole thing is integrated so basically all

is integrated so basically all

is integrated so basically all in one place where you can write your

in one place where you can write your

in one place where you can write your code

code

code the editor right here where you can

the editor right here where you can

the editor right here where you can navigate

navigate

navigate your files in your project so basically

your files in your project so basically

your files in your project so basically this is just a folder

this is just a folder

this is just a folder on your laptop and you can navigate the

on your laptop and you can navigate the

on your laptop and you can navigate the files here

files here

files here and you have the execution environment

and you have the execution environment

and you have the execution environment at the same time so you have to go to

at the same time so you have to go to

at the same time so you have to go to terminal and execute python 3

terminal and execute python 3

terminal and execute python 3 whatever you have everything in one

whatever you have everything in one

whatever you have everything in one place and

place and

place and tools that provide you with this type of

tools that provide you with this type of

tools that provide you with this type of environment for different programming

environment for different programming

environment for different programming languages

languages

languages for python it happens to be pycharm

for python it happens to be pycharm

for python it happens to be pycharm these are called

these are called

these are called ides which stand for integrated

ides which stand for integrated

ides which stand for integrated development environment integrated

development environment integrated

development environment integrated because you have

because you have

because you have everything in one place so you don't

everything in one place so you don't

everything in one place so you don't need to

need to

need to use terminal but in addition to this

use terminal but in addition to this

use terminal but in addition to this integration you get more cool features

integration you get more cool features

integration you get more cool features which helps you in writing python code

which helps you in writing python code

which helps you in writing python code for example

for example

for example syntax highlighting highlighting errors

syntax highlighting highlighting errors

syntax highlighting highlighting errors or

or

or code suggestions autocomplete

code suggestions autocomplete

code suggestions autocomplete suggestions

suggestions

suggestions and we will see those cool features

and we will see those cool features

and we will see those cool features actually also throughout this course

actually also throughout this course

actually also throughout this course so basically just makes your life as a

so basically just makes your life as a

so basically just makes your life as a developer easier

developer easier

developer easier however it's good to understand that

however it's good to understand that

however it's good to understand that connection

connection

connection between executing your files on the

between executing your files on the

between executing your files on the terminal

terminal

terminal when you don't have such a tool versus

when you don't have such a tool versus

when you don't have such a tool versus executing and working on your

executing and working on your

executing and working on your application inside that tool

awesome so let's get back to our code

awesome so let's get back to our code editor

editor

editor a file where we write our code and till

a file where we write our code and till

a file where we write our code and till now we have done something really simple

now we have done something really simple

now we have done something really simple like print

like print

like print a text basically and print

a text basically and print

a text basically and print a number right and this leads to

a number right and this leads to

a number right and this leads to the first concept in programming

the first concept in programming

the first concept in programming languages which

languages which

languages which are data types so in python

are data types so in python

are data types so in python just like in any other programming

just like in any other programming

just like in any other programming language you have data types

language you have data types

language you have data types for text and numbers the text data types

for text and numbers the text data types

for text and numbers the text data types are called

are called

are called strings so everything within the double

strings so everything within the double

strings so everything within the double quotes is basically a string

quotes is basically a string

quotes is basically a string but note that in python you can also use

but note that in python you can also use

but note that in python you can also use single quotes

single quotes

single quotes for strings so double quotes or single

for strings so double quotes or single

for strings so double quotes or single quotes

quotes

quotes they both work the same and there's

they both work the same and there's

they both work the same and there's actually no difference between them

actually no difference between them

actually no difference between them and for numbers we actually have

and for numbers we actually have

and for numbers we actually have different data types

different data types

different data types so for whole numbers like 2 20

so for whole numbers like 2 20

so for whole numbers like 2 20 but also 0 and negative numbers as well

but also 0 and negative numbers as well

but also 0 and negative numbers as well we have

we have

we have a data type called integer and that's

a data type called integer and that's

a data type called integer and that's also how it's called in most programming

also how it's called in most programming

also how it's called in most programming languages

languages

languages however you also have numbers for

however you also have numbers for

however you also have numbers for currency for example how much

currency for example how much

currency for example how much a product costs right so if you have an

a product costs right so if you have an

a product costs right so if you have an online shop you would have

online shop you would have

online shop you would have prices like this for example so these

prices like this for example so these

prices like this for example so these are basically

are basically

are basically numbers with precision this could also

numbers with precision this could also

numbers with precision this could also be

be

be for example when you're shipping

for example when you're shipping

for example when you're shipping something you could have

something you could have

something you could have a weight of a package that is also

a weight of a package that is also

a weight of a package that is also not a whole number but has a precision

not a whole number but has a precision

not a whole number but has a precision so this type of numbers

so this type of numbers

so this type of numbers in python and many other programming

in python and many other programming

in python and many other programming languages are

languages are

languages are represented as float data type

represented as float data type

represented as float data type so again you have integers

so again you have integers

so again you have integers and float data types and if we execute

and float data types and if we execute

and float data types and if we execute that

that

that you basically see all of that printed as

you basically see all of that printed as

you basically see all of that printed as we wrote them

now obviously printing values like

now obviously printing values like numbers and text like this doesn't make

numbers and text like this doesn't make

numbers and text like this doesn't make much sense unless we're getting some

much sense unless we're getting some

much sense unless we're getting some useful information

useful information

useful information from our simple program right here right

from our simple program right here right

from our simple program right here right so let's do something more useful with

so let's do something more useful with

so let's do something more useful with python now

python now

python now let's clean all this up and let's say we

let's clean all this up and let's say we

let's clean all this up and let's say we want to do some

want to do some

want to do some calculations very simple logic that

calculations very simple logic that

calculations very simple logic that basically calculates

basically calculates

basically calculates how many minutes there are in 20 days

so we have 20 days which have 24 hours

so we have 20 days which have 24 hours per day

per day

per day which have 60 minutes per hour

which have 60 minutes per hour

which have 60 minutes per hour so this line will give us basically

so this line will give us basically

so this line will give us basically calculation of

calculation of

calculation of minutes for 20 days and there you go

minutes for 20 days and there you go

minutes for 20 days and there you go that's our number now this makes a

that's our number now this makes a

that's our number now this makes a little bit more sense

little bit more sense

little bit more sense because now we have a program that

because now we have a program that

because now we have a program that actually does something for us

actually does something for us

actually does something for us so basically as you see you can do any

so basically as you see you can do any

so basically as you see you can do any math operations on numbers

math operations on numbers

math operations on numbers in python and again in many other

in python and again in many other

in python and again in many other programming languages

programming languages

programming languages you can do plus minus division whatever

you can do plus minus division whatever

you can do plus minus division whatever just like you know it from basic math

just like you know it from basic math

just like you know it from basic math however i want to note right here

however i want to note right here

however i want to note right here something that many people think about

something that many people think about

something that many people think about programming

programming

programming and maybe are misinformed about

and maybe are misinformed about

and maybe are misinformed about which is if you're doing web development

which is if you're doing web development

which is if you're doing web development or maybe devops automation with python

or maybe devops automation with python

or maybe devops automation with python and not something like data science or

and not something like data science or

and not something like data science or data analytics

data analytics

data analytics this is probably an example of the

this is probably an example of the

this is probably an example of the highest

highest

highest math knowledge that you need for

math knowledge that you need for

math knowledge that you need for programming in python

programming in python

programming in python because even though we're going to use

because even though we're going to use

because even though we're going to use some calculation

some calculation

some calculation examples because they're just good as

examples because they're just good as

examples because they're just good as examples to

examples to

examples to show you the basic concepts of python

show you the basic concepts of python

show you the basic concepts of python you do not

you do not

you do not really need any advanced or even

really need any advanced or even

really need any advanced or even intermediate

intermediate

intermediate knowledge of mathematics when

knowledge of mathematics when

knowledge of mathematics when programming

programming

programming because it's really not about meth

because it's really not about meth

because it's really not about meth however what you need is

however what you need is

however what you need is logical thinking and we're going to be

logical thinking and we're going to be

logical thinking and we're going to be doing some of that and

doing some of that and

doing some of that and see that as examples so just bear that

see that as examples so just bear that

see that as examples so just bear that in mind

in mind

in mind in case you are misinformed about that

so back to our example we have this

so back to our example we have this number that is displayed here

number that is displayed here

number that is displayed here as a result however maybe if we use this

as a result however maybe if we use this

as a result however maybe if we use this program

program

program we don't remember or we don't know what

we don't remember or we don't know what

we don't remember or we don't know what this number stands for

this number stands for

this number stands for if somebody else is using so we want to

if somebody else is using so we want to

if somebody else is using so we want to add some descriptive

add some descriptive

add some descriptive information about this number that says

information about this number that says

information about this number that says this is how many

this is how many

this is how many minutes there are in 20 days so

minutes there are in 20 days so

minutes there are in 20 days so basically we need a line that says 20

basically we need a line that says 20

basically we need a line that says 20 days

days

days are this many minutes

and this should basically be exactly

and this should basically be exactly this calculation

this calculation

this calculation right here so how do we put this

right here so how do we put this

right here so how do we put this calculation basically right here in the

calculation basically right here in the

calculation basically right here in the middle

middle

middle so that we end up with this whole phrase

so that we end up with this whole phrase

so that we end up with this whole phrase displayed right here so how do we

displayed right here so how do we

displayed right here so how do we combine text

combine text

combine text and numbers basically or calculation

and numbers basically or calculation

and numbers basically or calculation of numbers and in programming languages

of numbers and in programming languages

of numbers and in programming languages again this is not specific

again this is not specific

again this is not specific to python we would do that using

to python we would do that using

to python we would do that using something called

something called

something called string concatenation and string

string concatenation and string

string concatenation and string concatenation is basically a fancy word

concatenation is basically a fancy word

concatenation is basically a fancy word for

for

for gluing together or combining multiple

gluing together or combining multiple

gluing together or combining multiple strings

strings

strings now how does the syntax for that look

now how does the syntax for that look

now how does the syntax for that look like

like

like we combine the strings using plus sign

we combine the strings using plus sign

we combine the strings using plus sign so apart from adding numbers obviously

so apart from adding numbers obviously

so apart from adding numbers obviously using plus

using plus

using plus plus is also used in programming for

plus is also used in programming for

plus is also used in programming for combining

combining

combining multiple strings so in our example we

multiple strings so in our example we

multiple strings so in our example we have

have

have three string values and we want to put

three string values and we want to put

three string values and we want to put them all together

them all together

them all together in one string or one sentence we have

in one string or one sentence we have

in one string or one sentence we have the first string 20 days r

the first string 20 days r

the first string 20 days r and then we have the second string

and then we have the second string

and then we have the second string minutes and in the middle the third

minutes and in the middle the third

minutes and in the middle the third string

string

string which will be the value of the

which will be the value of the

which will be the value of the calculation

calculation

calculation however if we just put a number here

however if we just put a number here

however if we just put a number here python

python

python interpreter tells us it's not a string

interpreter tells us it's not a string

interpreter tells us it's not a string it's a number so we need to turn it into

it's a number so we need to turn it into

it's a number so we need to turn it into a string

a string

a string other programming languages do that

other programming languages do that

other programming languages do that automatically in python we need to do

automatically in python we need to do

automatically in python we need to do that

that

that explicitly so we need to tell python

explicitly so we need to tell python

explicitly so we need to tell python take this number but not as a number but

take this number but not as a number but

take this number but not as a number but as

as

as a string and we do that using a syntax

that looks exactly like that so

that looks exactly like that so basically we

basically we

basically we have a non-string value but we're

have a non-string value but we're

have a non-string value but we're telling python we want it as a string

telling python we want it as a string

telling python we want it as a string because it needs to be printed out as a

because it needs to be printed out as a

because it needs to be printed out as a text basically

text basically

text basically so if i execute this line

so if i execute this line

so if i execute this line let's see what happened and there you go

let's see what happened and there you go

let's see what happened and there you go we have our output

we have our output

we have our output just like we wrote it here but you see

just like we wrote it here but you see

just like we wrote it here but you see that there

that there

that there are no spaces around so basically 50

are no spaces around so basically 50

are no spaces around so basically 50 is just really glued together without

is just really glued together without

is just really glued together without any space

any space

any space around and how do we put spaces around

around and how do we put spaces around

around and how do we put spaces around these 50

these 50

these 50 basically add a space here add a space

basically add a space here add a space

basically add a space here add a space here

here

here now why does that work because this

now why does that work because this

now why does that work because this whole thing for python is a string again

whole thing for python is a string again

whole thing for python is a string again because we are

because we are

because we are putting it within these quotes so

putting it within these quotes so

putting it within these quotes so basically any character

basically any character

basically any character that you see on your keyboard right now

that you see on your keyboard right now

that you see on your keyboard right now if you put it

if you put it

if you put it between those quotes is

between those quotes is

between those quotes is interpreted by python as a string

interpreted by python as a string

interpreted by python as a string including this space character right so

including this space character right so

including this space character right so if we execute it again

if we execute it again

if we execute it again we have spaces around 50 and our

we have spaces around 50 and our

we have spaces around 50 and our sentence our phrase looks fine and if

sentence our phrase looks fine and if

sentence our phrase looks fine and if you're thinking right now this is

you're thinking right now this is

you're thinking right now this is actually kind of annoying because

actually kind of annoying because

actually kind of annoying because first of all it looks ugly and also

first of all it looks ugly and also

first of all it looks ugly and also there's a high chance you're gonna

there's a high chance you're gonna

there's a high chance you're gonna forget it

forget it

forget it that is absolutely right so in python

that is absolutely right so in python

that is absolutely right so in python again

again

again specifically there is a way to do it

specifically there is a way to do it

specifically there is a way to do it in a more elegant way using a different

in a more elegant way using a different

in a more elegant way using a different syntax and the more elegant syntax

syntax and the more elegant syntax

syntax and the more elegant syntax for that let's actually close this is

for that let's actually close this is

for that let's actually close this is print

and let's write that again and

and let's write that again and instead of having these plus

instead of having these plus

instead of having these plus we have curly braces and we write

we have curly braces and we write

we have curly braces and we write our number inside or whatever

our number inside or whatever

our number inside or whatever non-textual

non-textual

non-textual value and at the beginning right here

value and at the beginning right here

value and at the beginning right here basically

basically

basically before we start writing a string which

before we start writing a string which

before we start writing a string which starts with

starts with

starts with quotes we just write the letter f

quotes we just write the letter f

quotes we just write the letter f and you see the syntax highlighting as

and you see the syntax highlighting as

and you see the syntax highlighting as well basically

well basically

well basically sees that this is not part of the text

sees that this is not part of the text

sees that this is not part of the text this is non-text value and if i

this is non-text value and if i

this is non-text value and if i execute it i should see the same output

execute it i should see the same output

execute it i should see the same output from the second line and this is really

from the second line and this is really

from the second line and this is really a way cooler way

a way cooler way

a way cooler way to write this instead of using plus

to write this instead of using plus

to write this instead of using plus but this is something very common and

but this is something very common and

but this is something very common and also something that

also something that

also something that you would encounter in most programming

you would encounter in most programming

you would encounter in most programming languages so just

languages so just

languages so just important to know that this is a syntax

important to know that this is a syntax

important to know that this is a syntax for

for

for string concatenation as well so we can

string concatenation as well so we can

string concatenation as well so we can basically just

basically just

basically just remove it and use this syntax for our

remove it and use this syntax for our

remove it and use this syntax for our examples

examples

examples and also note that this syntax is

and also note that this syntax is

and also note that this syntax is actually a new addition to python

actually a new addition to python

actually a new addition to python so it only works if you have a latest

so it only works if you have a latest

so it only works if you have a latest python version

python version

python version in our project if you remember we

in our project if you remember we

in our project if you remember we actually

actually

actually configured and chose version 3.9

configured and chose version 3.9

configured and chose version 3.9 and that's why it works for us if you

and that's why it works for us if you

and that's why it works for us if you use

use

use python 2 for example python version 2

python 2 for example python version 2

python 2 for example python version 2 this syntax is not going to work for you

this syntax is not going to work for you

this syntax is not going to work for you we can actually demonstrate it

we can actually demonstrate it

we can actually demonstrate it so i'm going to copy that line

so i'm going to copy that line

so i'm going to copy that line and i'm going to change our test.pi

and now if i execute it using my python

and now if i execute it using my python 3

you see it works fine if i do it with

you see it works fine if i do it with python which is version

python which is version

python which is version two point something

let's see what happens there you go

let's see what happens there you go syntax error invalid syntax because

syntax error invalid syntax because

syntax error invalid syntax because python version

python version

python version 2.7.10 so older version basically

2.7.10 so older version basically

2.7.10 so older version basically doesn't recognize this syntax so just be

doesn't recognize this syntax so just be

doesn't recognize this syntax so just be aware of that

aware of that

aware of that so this syntax actually only works for

so this syntax actually only works for

so this syntax actually only works for python versions

python versions

python versions starting from 3.6 so everything

starting from 3.6 so everything

starting from 3.6 so everything below that every python version

below that every python version

below that every python version basically will not recognize this syntax

basically will not recognize this syntax

basically will not recognize this syntax as we see right here so again back to

as we see right here so again back to

as we see right here so again back to our code

our code

our code and now we just have a number here

and now we just have a number here

and now we just have a number here but what we actually want is the

but what we actually want is the

but what we actually want is the calculation

calculation

calculation for getting the correct result right so

for getting the correct result right so

for getting the correct result right so we want again

we want again

we want again 20 days

in hours and then in minutes and if i

in hours and then in minutes and if i execute it

execute it

execute it you see that the calculation was done

you see that the calculation was done

you see that the calculation was done and here we have

and here we have

and here we have the full complete sentence with the

the full complete sentence with the

the full complete sentence with the result in it

result in it

result in it and if you're curious this f actually

and if you're curious this f actually

and if you're curious this f actually stands

stands

stands for format so this is basically

for format so this is basically

for format so this is basically formatting

formatting

formatting our text or our string in a correct way

awesome so we have this line of code

awesome so we have this line of code here that basically

here that basically

here that basically calculates for us how many minutes there

calculates for us how many minutes there

calculates for us how many minutes there are in 20 days

are in 20 days

are in 20 days let's say we want to do the same for 35

let's say we want to do the same for 35

let's say we want to do the same for 35 days

days

days right what we can do is basically copy

right what we can do is basically copy

right what we can do is basically copy that line

that line

that line and replace the values

and replace the values

and replace the values for 20 with 35 and if i execute it

for 20 with 35 and if i execute it

for 20 with 35 and if i execute it i get the same calculation but for 35

i get the same calculation but for 35

i get the same calculation but for 35 days

days

days and we can do that basically multiple

and we can do that basically multiple

and we can do that basically multiple times

times

times for different values so let's say we

for different values so let's say we

for different values so let's say we want it

want it

want it for 50 days and we want the same

for 50 days and we want the same

for 50 days and we want the same calculation

calculation

calculation for i don't know let's say 110 days

for i don't know let's say 110 days

for i don't know let's say 110 days doesn't really matter

doesn't really matter

doesn't really matter and we have obviously different

and we have obviously different

and we have obviously different number of minutes for each of these

number of minutes for each of these

number of minutes for each of these values

values

values and now let's say we wrote this program

and now let's say we wrote this program

and now let's say we wrote this program it's ready

it's ready

it's ready and we're using it and at some point we

and we're using it and at some point we

and we're using it and at some point we decide you know what i want

decide you know what i want

decide you know what i want this program to actually calculate

this program to actually calculate

this program to actually calculate how many seconds there are for these

how many seconds there are for these

how many seconds there are for these provided days

provided days

provided days instead of minutes so what we would need

instead of minutes so what we would need

instead of minutes so what we would need to do in that case

to do in that case

to do in that case is basically change the calculation in

is basically change the calculation in

is basically change the calculation in all those four lines

all those four lines

all those four lines so instead of minutes it should actually

so instead of minutes it should actually

so instead of minutes it should actually calculate

calculate

calculate number of seconds in a day right so we

number of seconds in a day right so we

number of seconds in a day right so we have the hours

have the hours

have the hours minutes and seconds and we would have to

minutes and seconds and we would have to

minutes and seconds and we would have to change the text as well here and we

change the text as well here and we

change the text as well here and we would need to do that

would need to do that

would need to do that for each one of those lines right

for each one of those lines right

for each one of those lines right so we would have it here

like this and again if we need to modify

like this and again if we need to modify this for hours or milliseconds or

this for hours or milliseconds or

this for hours or milliseconds or whatever

whatever

whatever we basically have to do these changes

we basically have to do these changes

we basically have to do these changes multiple times

multiple times

multiple times right even though if you actually look

right even though if you actually look

right even though if you actually look at that this is

at that this is

at that this is the same exact calculation for each line

the same exact calculation for each line

the same exact calculation for each line that doesn't change right if you want

that doesn't change right if you want

that doesn't change right if you want seconds then this is the calculation

seconds then this is the calculation

seconds then this is the calculation that you need to do

that you need to do

that you need to do so how can we actually avoid repeating

so how can we actually avoid repeating

so how can we actually avoid repeating the same calculation

the same calculation

the same calculation and the same text in our code and the

and the same text in our code and the

and the same text in our code and the answer to that is variables so in

answer to that is variables so in

answer to that is variables so in programming languages we have

programming languages we have

programming languages we have variables that basically hold values

variables that basically hold values

variables that basically hold values that will repeat throughout your code

that will repeat throughout your code

that will repeat throughout your code that you can set once and

that you can set once and

that you can set once and use it in multiple different places so

use it in multiple different places so

use it in multiple different places so instead of

instead of

instead of basically repeating this calculation

basically repeating this calculation

basically repeating this calculation four times we basically do this

four times we basically do this

four times we basically do this calculation

calculation

calculation once like this

once like this

once like this and we basically save this value

and we basically save this value

and we basically save this value in a variable so that we can use it

in a variable so that we can use it

in a variable so that we can use it whenever we need right

whenever we need right

whenever we need right and the way that variables are defined

and the way that variables are defined

and the way that variables are defined in python

in python

in python is variable name let's call it

equals and whatever that value is that

equals and whatever that value is that repeats itself and that we want to save

repeats itself and that we want to save

repeats itself and that we want to save into a variable

into a variable

into a variable now i want to make two notes here

now i want to make two notes here

now i want to make two notes here regarding the variables

regarding the variables

regarding the variables in python first of all in python

in python first of all in python

in python first of all in python defining or creating a variable and

defining or creating a variable and

defining or creating a variable and giving it a value like this

giving it a value like this

giving it a value like this syntax for that is actually very simple

syntax for that is actually very simple

syntax for that is actually very simple compared to other languages because you

compared to other languages because you

compared to other languages because you just have the variable name

just have the variable name

just have the variable name and the value in many programming

and the value in many programming

and the value in many programming languages you actually have to define

languages you actually have to define

languages you actually have to define here

here

here some kind of data type for that variable

some kind of data type for that variable

some kind of data type for that variable for example if it's a number

for example if it's a number

for example if it's a number like float or integer or string

like float or integer or string

like float or integer or string etc in python you don't have to define

etc in python you don't have to define

etc in python you don't have to define that

that

that you just have name of the variable

you just have name of the variable

you just have name of the variable simple as that

simple as that

simple as that the second one is the naming

the second one is the naming

the second one is the naming convention or standard for the variables

convention or standard for the variables

convention or standard for the variables so we have two words for example if we

so we have two words for example if we

so we have two words for example if we name

name

name our variable calculation to seconds

our variable calculation to seconds

our variable calculation to seconds right

right

right we have actually three words here so

we have actually three words here so

we have actually three words here so variables that are descriptive so

variables that are descriptive so

variables that are descriptive so basically they tell you

basically they tell you

basically they tell you what this value actually is about so

what this value actually is about so

what this value actually is about so they have multiple

they have multiple

they have multiple words in them you can separate them

words in them you can separate them

words in them you can separate them using these

using these

using these underlines again in different languages

underlines again in different languages

underlines again in different languages the

the

the naming for variables can be different in

naming for variables can be different in

naming for variables can be different in python this is actually

python this is actually

python this is actually one of the standard ways of defining

one of the standard ways of defining

one of the standard ways of defining variable with underscores

variable with underscores

variable with underscores which i find pretty nice and easy to

which i find pretty nice and easy to

which i find pretty nice and easy to read

read

read so we're gonna use this syntax basically

so we're gonna use this syntax basically

so we're gonna use this syntax basically throughout the course

throughout the course

throughout the course it will be totally and absolutely okay

it will be totally and absolutely okay

it will be totally and absolutely okay if we wrote it like this

if we wrote it like this

if we wrote it like this or if we used capital letters instead

or if we used capital letters instead

or if we used capital letters instead but again this is probably the most

but again this is probably the most

but again this is probably the most readable form

readable form

readable form and this is what we're going to use now

and this is what we're going to use now

and this is what we're going to use now here

here

here note that we can decide whatever name we

note that we can decide whatever name we

note that we can decide whatever name we want to give

want to give

want to give our variable but in python there are

our variable but in python there are

our variable but in python there are some specific words

some specific words

some specific words that have special meaning to python

that have special meaning to python

that have special meaning to python these are called reserved words

these are called reserved words

these are called reserved words so you can't use these words as variable

so you can't use these words as variable

so you can't use these words as variable names

names

names and we will use some of these reserved

and we will use some of these reserved

and we will use some of these reserved words

words

words throughout the course so you will see

throughout the course so you will see

throughout the course so you will see some examples

some examples

some examples great so we have our variable defined

great so we have our variable defined

great so we have our variable defined here and

here and

here and this is the value that this variable

this is the value that this variable

this is the value that this variable gives us so how do we replace now

gives us so how do we replace now

gives us so how do we replace now these repeating values with this

these repeating values with this

these repeating values with this variable

variable

variable so we're going to delete that and again

so we're going to delete that and again

so we're going to delete that and again inside we're simply going to copy

inside we're simply going to copy

inside we're simply going to copy the name of the variable so let's

the name of the variable so let's

the name of the variable so let's execute

execute

execute and as you see we have our

and as you see we have our

and as you see we have our value printed just fine and we're going

value printed just fine and we're going

value printed just fine and we're going to do the same

to do the same

to do the same for all those

values and again execute

values and again execute everything works just like before now

everything works just like before now

everything works just like before now you may be thinking

you may be thinking

you may be thinking if we change this to minutes

if we change this to minutes

if we change this to minutes we would have to change the variable in

we would have to change the variable in

we would have to change the variable in all these places

all these places

all these places so that's our case we can basically just

so that's our case we can basically just

so that's our case we can basically just rename our variable something more

rename our variable something more

rename our variable something more generic so let's say calculation

generic so let's say calculation

generic so let's say calculation to units and this could be

to units and this could be

to units and this could be now any unit that we want second meaning

now any unit that we want second meaning

now any unit that we want second meaning it doesn't matter

it doesn't matter

it doesn't matter and this is exactly the advantage of

and this is exactly the advantage of

and this is exactly the advantage of variable

variable

variable because you can name it whatever you

because you can name it whatever you

because you can name it whatever you want

which basically just describes what this

which basically just describes what this variable is about

variable is about

variable is about and now you won't have to change that

and now you won't have to change that

and now you won't have to change that again

again

again and we can also replace this one here

and we can also replace this one here

and we can also replace this one here accordingly since it's a text we can

accordingly since it's a text we can

accordingly since it's a text we can call it a name

call it a name

call it a name of unit we can also call it unit doesn't

of unit we can also call it unit doesn't

of unit we can also call it unit doesn't really matter

really matter

really matter we're the ones deciding what that

we're the ones deciding what that

we're the ones deciding what that variable name is

variable name is

variable name is and once we have that variable we can

and once we have that variable we can

and once we have that variable we can now

now

now replace it here how do we do this

replace it here how do we do this

replace it here how do we do this because this is actually

because this is actually

because this is actually part of a text a string the same way we

part of a text a string the same way we

part of a text a string the same way we did

did

did right here we're gonna delete that

right here we're gonna delete that

right here we're gonna delete that and create an expression create a syntax

and create an expression create a syntax

and create an expression create a syntax that basically tells python

that basically tells python

that basically tells python hey this is not a string this is a

hey this is not a string this is a

hey this is not a string this is a non-string

non-string

non-string value and you already know this could be

value and you already know this could be

value and you already know this could be either number

either number

either number or variable itself and so we're going to

or variable itself and so we're going to

or variable itself and so we're going to use the curly braces

use the curly braces

use the curly braces and the name of the variable and just

and the name of the variable and just

and the name of the variable and just like that

like that

like that we have substituted these values here

we have substituted these values here

we have substituted these values here and if i execute it works perfectly fine

and if i execute it works perfectly fine

and if i execute it works perfectly fine and we can do that

in all four lines and our code is still

in all four lines and our code is still working

working

working and this syntax right here with this

and this syntax right here with this

and this syntax right here with this format

format

format at the beginning basically prevents us

at the beginning basically prevents us

at the beginning basically prevents us or avoids

or avoids

or avoids basically saves us from having a bunch

basically saves us from having a bunch

basically saves us from having a bunch of

of

of plus signs here and then space

plus signs here and then space

plus signs here and then space characters etc

characters etc

characters etc this all looks way elegant now and now

this all looks way elegant now and now

this all looks way elegant now and now if

if

if at some point we actually decide you

at some point we actually decide you

at some point we actually decide you know what i want

know what i want

know what i want this program to calculate how many hours

this program to calculate how many hours

this program to calculate how many hours there are in the given days instead of

there are in the given days instead of

there are in the given days instead of seconds

seconds

seconds and we want to change the program to do

and we want to change the program to do

and we want to change the program to do that we could basically

that we could basically

that we could basically just change the calculation here and

just change the calculation here and

just change the calculation here and instead of seconds we have hours and if

instead of seconds we have hours and if

instead of seconds we have hours and if i execute

i execute

i execute there you go we see the changes right

there you go we see the changes right

there you go we see the changes right away so

away so

away so this is why when you're programming

this is why when you're programming

this is why when you're programming doesn't matter in which language

doesn't matter in which language

doesn't matter in which language including python using variables will be

including python using variables will be

including python using variables will be probably some of the most frequent thing

probably some of the most frequent thing

probably some of the most frequent thing that you do

that you do

that you do because you always have values that are

because you always have values that are

because you always have values that are repeating themselves

repeating themselves

repeating themselves and you want to write clean code so you

and you want to write clean code so you

and you want to write clean code so you create

create

create variables and one of the best practices

variables and one of the best practices

variables and one of the best practices when

when

when creating and using variables is as we're

creating and using variables is as we're

creating and using variables is as we're using actually here is to name your

using actually here is to name your

using actually here is to name your variables

variables

variables so that you later and also other

so that you later and also other

so that you later and also other programmers who are working with you

programmers who are working with you

programmers who are working with you understand what this variable actually

understand what this variable actually

understand what this variable actually does or what type of value

does or what type of value

does or what type of value it actually has because if you just look

it actually has because if you just look

it actually has because if you just look at 24 you would probably not know

at 24 you would probably not know

at 24 you would probably not know what this 24 is about right but with

what this 24 is about right but with

what this 24 is about right but with variable

variable

variable you actually know that this actually

you actually know that this actually

you actually know that this actually represents a number that is used

represents a number that is used

represents a number that is used for calculating units right it could

for calculating units right it could

for calculating units right it could also be more descriptive

also be more descriptive

also be more descriptive like units for days but generally

like units for days but generally

like units for days but generally another advantage of variable is to

another advantage of variable is to

another advantage of variable is to basically describe that value

basically describe that value

basically describe that value as well that you're using in your code

now another thing you probably also

now another thing you probably also noticed is that

noticed is that

noticed is that even though we're using variables here

even though we're using variables here

even though we're using variables here so that we don't have to change

so that we don't have to change

so that we don't have to change those values in four different places a

those values in four different places a

those values in four different places a lot of

lot of

lot of these four lines are actually pretty

these four lines are actually pretty

these four lines are actually pretty similar the only difference

similar the only difference

similar the only difference in those four lines are actually these

in those four lines are actually these

in those four lines are actually these numbers

numbers

numbers right here everything else is exactly

right here everything else is exactly

right here everything else is exactly the same

the same

the same so what if instead we wanted to

so what if instead we wanted to

so what if instead we wanted to make this code cleaner and basically

make this code cleaner and basically

make this code cleaner and basically avoid

avoid

avoid this type of duplication in our code

this type of duplication in our code

this type of duplication in our code right so for example if we did this for

right so for example if we did this for

right so for example if we did this for 10 different values

10 different values

10 different values we would have the same line this long

we would have the same line this long

we would have the same line this long line basically 10 times right

line basically 10 times right

line basically 10 times right so how do we avoid this type of

so how do we avoid this type of

so how do we avoid this type of duplication

duplication

duplication so right here we actually avoided

so right here we actually avoided

so right here we actually avoided duplication

duplication

duplication for specific values right piece of

for specific values right piece of

for specific values right piece of string here

string here

string here a whole calculation here but how do we

a whole calculation here but how do we

a whole calculation here but how do we actually

actually

actually avoid duplicating a whole line right the

avoid duplicating a whole line right the

avoid duplicating a whole line right the whole

whole

whole piece of code basically which has

piece of code basically which has

piece of code basically which has multiple different stuff in it

multiple different stuff in it

multiple different stuff in it not just a value and we do that using

not just a value and we do that using

not just a value and we do that using functions so functions are basically

functions so functions are basically

functions so functions are basically blocks of code

blocks of code

blocks of code like this right or basically logic in

like this right or basically logic in

like this right or basically logic in code

code

code that does something it's not just simply

that does something it's not just simply

that does something it's not just simply a value but actually does something more

a value but actually does something more

a value but actually does something more complex

complex

complex that is again used in order to avoid

that is again used in order to avoid

that is again used in order to avoid repeating the same logic or most of the

repeating the same logic or most of the

repeating the same logic or most of the same logic

same logic

same logic in your code so how do we create

in your code so how do we create

in your code so how do we create functions just like we created variables

functions just like we created variables

functions just like we created variables here

here

here we create functions and the way we do

we create functions and the way we do

we create functions and the way we do that

that

that is using following syntax

is using following syntax

is using following syntax right here let's create our first

right here let's create our first

right here let's create our first function

function

function we start with def so we define

we start with def so we define

we start with def so we define a function just like we define a

a function just like we define a

a function just like we define a variable

variable

variable but for function we need this keyword

but for function we need this keyword

but for function we need this keyword basically called def

basically called def

basically called def and now we can give our function a name

and now we can give our function a name

and now we can give our function a name just like we gave name to our variable

just like we gave name to our variable

just like we gave name to our variable we can give our function a name

we can give our function a name

we can give our function a name and here we can use the same standards

and here we can use the same standards

and here we can use the same standards like for variable

like for variable

like for variable we can name the function something

we can name the function something

we can name the function something descriptive something that actually says

descriptive something that actually says

descriptive something that actually says what this function does and let's call

what this function does and let's call

what this function does and let's call our function days

our function days

our function days to units and then we have the brackets

to units and then we have the brackets

to units and then we have the brackets and a column so this line basically

and a column so this line basically

and a column so this line basically defines a function it tells python hey

defines a function it tells python hey

defines a function it tells python hey whatever

whatever

whatever comes after this is actually going to be

comes after this is actually going to be

comes after this is actually going to be a block of code that is going to be

a block of code that is going to be

a block of code that is going to be referred

referred

referred to or is going to be named these two

to or is going to be named these two

to or is going to be named these two units and how do you write a function

units and how do you write a function

units and how do you write a function i'm just going to copy this one actually

i'm just going to copy this one actually

i'm just going to copy this one actually here and let's give us some space

here and let's give us some space

here and let's give us some space and again this is very specific to

and again this is very specific to

and again this is very specific to python

python

python we need to indent here with spaces

we need to indent here with spaces

we need to indent here with spaces and i'm going to paste in what i copied

and i'm going to paste in what i copied

and i'm going to paste in what i copied inside these two lines basically tell

inside these two lines basically tell

inside these two lines basically tell python

python

python this piece of code or this line of code

this piece of code or this line of code

this piece of code or this line of code because we just have one line here

because we just have one line here

because we just have one line here belongs to a function called these two

belongs to a function called these two

belongs to a function called these two units

units

units and again we just have one line but this

and again we just have one line but this

and again we just have one line but this could be function with hundreds of lines

could be function with hundreds of lines

could be function with hundreds of lines right

right

right so i can write whatever i want the next

so i can write whatever i want the next

so i can write whatever i want the next line

line

line all good and then i can do some

all good and then i can do some

all good and then i can do some calculations and i can basically write

calculations and i can basically write

calculations and i can basically write whatever logic i want

whatever logic i want

whatever logic i want here and all these will belong to

here and all these will belong to

here and all these will belong to this function so now this

this function so now this

this function so now this logic is inside a function that is

logic is inside a function that is

logic is inside a function that is called

called

called these two units and we can actually get

these two units and we can actually get

these two units and we can actually get rid of this

rid of this

rid of this and test our function and here if you

and test our function and here if you

and test our function and here if you noticed

noticed

noticed we have this yellow line under the

we have this yellow line under the

we have this yellow line under the function name that's actually a warning

function name that's actually a warning

function name that's actually a warning for our code style

for our code style

for our code style it says we need two blank lines before

it says we need two blank lines before

it says we need two blank lines before so pycharm has a

so pycharm has a

so pycharm has a built-in official style guide for python

built-in official style guide for python

built-in official style guide for python that tells you how to style your code or

that tells you how to style your code or

that tells you how to style your code or how to write your code correctly

how to write your code correctly

how to write your code correctly now why is code style important well

now why is code style important well

now why is code style important well just like you write code you need to

just like you write code you need to

just like you write code you need to read code from other developers or

read code from other developers or

read code from other developers or your own code to understand what the

your own code to understand what the

your own code to understand what the code is actually doing

code is actually doing

code is actually doing so it's important that code is easily

so it's important that code is easily

so it's important that code is easily readable

readable

readable and this is just another example of how

and this is just another example of how

and this is just another example of how an editor like pycharm

an editor like pycharm

an editor like pycharm helps you to write code so to fix the

helps you to write code so to fix the

helps you to write code so to fix the warning

warning

warning we're just going to add a new blank line

we're just going to add a new blank line

we're just going to add a new blank line before the function definition

before the function definition

before the function definition so now what happens if i execute this

so now what happens if i execute this

so now what happens if i execute this block of code i have the variables

block of code i have the variables

block of code i have the variables defined here that i'm using in the

defined here that i'm using in the

defined here that i'm using in the function and then we have these two

function and then we have these two

function and then we have these two print statements

print statements

print statements so what happens if i execute now and as

so what happens if i execute now and as

so what happens if i execute now and as you see in the

you see in the

you see in the output here there is no output right

output here there is no output right

output here there is no output right nothing

nothing

nothing actually got printed so what actually

actually got printed so what actually

actually got printed so what actually happened because we have

happened because we have

happened because we have those two print statements that we

those two print statements that we

those two print statements that we defined in the function

defined in the function

defined in the function but we don't see anything in the output

but we don't see anything in the output

but we don't see anything in the output and the way it works is whenever you

and the way it works is whenever you

and the way it works is whenever you create a function or define a function

create a function or define a function

create a function or define a function like this

like this

like this you actually have to use that function

you actually have to use that function

you actually have to use that function right again this is a similar concept to

right again this is a similar concept to

right again this is a similar concept to variables we have

variables we have

variables we have created variables here and we're using

created variables here and we're using

created variables here and we're using that

that

that variable in our code the same way we

variable in our code the same way we

variable in our code the same way we create a function and we

create a function and we

create a function and we need to use that function how do we use

need to use that function how do we use

need to use that function how do we use a function

a function

a function or in programming languages it's called

or in programming languages it's called

or in programming languages it's called calling a function or executing a

calling a function or executing a

calling a function or executing a function

function

function and we do that using the name of the

and we do that using the name of the

and we do that using the name of the function

function

function like this and as you see in the

like this and as you see in the

like this and as you see in the suggestion as well

suggestion as well

suggestion as well using brackets like this so

using brackets like this so

using brackets like this so this syntax here basically is

this syntax here basically is

this syntax here basically is what we call calling the function that

what we call calling the function that

what we call calling the function that we defined right here or using that

we defined right here or using that

we defined right here or using that function

function

function so now if we execute it there you go you

so now if we execute it there you go you

so now if we execute it there you go you see

see

see that those two lines got executed and we

that those two lines got executed and we

that those two lines got executed and we have the results here

have the results here

have the results here so we're creating variables and we're

so we're creating variables and we're

so we're creating variables and we're using that here

using that here

using that here we're creating a function and we're

we're creating a function and we're

we're creating a function and we're using that function here

using that function here

using that function here and note the difference between using a

and note the difference between using a

and note the difference between using a variable and using a function

variable and using a function

variable and using a function python knows this is a function because

python knows this is a function because

python knows this is a function because we are providing these

we are providing these

we are providing these brackets at the end right that tells us

brackets at the end right that tells us

brackets at the end right that tells us we're making a function

we're making a function

we're making a function call basically

but as you see now we have these 20 days

but as you see now we have these 20 days so this

so this

so this only works for 20 days right what about

only works for 20 days right what about

only works for 20 days right what about other

other

other values that we had what about 35 days

values that we had what about 35 days

values that we had what about 35 days and 100

and 100

and 100 days we haven't de-duplicated that right

days we haven't de-duplicated that right

days we haven't de-duplicated that right we have

we have

we have just one case here so how do we use

just one case here so how do we use

just one case here so how do we use functions so that everything else

functions so that everything else

functions so that everything else except for these two values right here

except for these two values right here

except for these two values right here actually stay the same and we do that in

actually stay the same and we do that in

actually stay the same and we do that in programming

programming

programming by giving our functions some kind of

by giving our functions some kind of

by giving our functions some kind of input value which are also called

input value which are also called

input value which are also called parameters

parameters

parameters so instead of having this 20 basically

so instead of having this 20 basically

so instead of having this 20 basically here hard coded as we said here

here hard coded as we said here

here hard coded as we said here and here we provide that value of 20 or

and here we provide that value of 20 or

and here we provide that value of 20 or 35 or whatever that value is

35 or whatever that value is

35 or whatever that value is basically whenever we use the function

basically whenever we use the function

basically whenever we use the function so we are

so we are

so we are telling python use these days to units

telling python use these days to units

telling python use these days to units function

function

function with a value of 20 or use that

with a value of 20 or use that

with a value of 20 or use that function with a value of 35 and way we

function with a value of 35 and way we

function with a value of 35 and way we define this

define this

define this input parameter in functions

input parameter in functions

input parameter in functions is very simply by defining this

is very simply by defining this

is very simply by defining this parameter

parameter

parameter between those brackets right so

between those brackets right so

between those brackets right so this is where the input we as

this is where the input we as

this is where the input we as programmers

programmers

programmers define the input parameters so right

define the input parameters so right

define the input parameters so right here

here

here how do we define that using our already

how do we define that using our already

how do we define that using our already familiar

familiar

familiar variables so basically right here i'm

variables so basically right here i'm

variables so basically right here i'm going to

going to

going to define a variable and i'm going to call

define a variable and i'm going to call

define a variable and i'm going to call it whatever i want

it whatever i want

it whatever i want i'm going to call it days or number of

i'm going to call it days or number of

i'm going to call it days or number of days

but i'm not assigning a value to that

but i'm not assigning a value to that variable right like

variable right like

variable right like i did here because i want it to be

i did here because i want it to be

i did here because i want it to be assigned

assigned

assigned whenever i use the function so this

whenever i use the function so this

whenever i use the function so this basically

basically

basically tells python that a function these two

tells python that a function these two

tells python that a function these two units

units

units can be used using one input parameter

can be used using one input parameter

can be used using one input parameter which is called num of dates right

which is called num of dates right

which is called num of dates right number of days

number of days

number of days so now the last part which is remaining

so now the last part which is remaining

so now the last part which is remaining is

is

is replacing these values using this

replacing these values using this

replacing these values using this variable right

variable right

variable right and just like we do it in these two

and just like we do it in these two

and just like we do it in these two places where we're

places where we're

places where we're also using variables defined here

also using variables defined here

also using variables defined here exactly the same way

exactly the same way

exactly the same way we're gonna remove this and

we're gonna remove this and

we're gonna remove this and define a block for non-textual value

define a block for non-textual value

define a block for non-textual value and we're gonna put our

and we're gonna put our

and we're gonna put our variable num updates here and

also here so you see now that our

also here so you see now that our function

function

function actually doesn't have any fixed numbers

actually doesn't have any fixed numbers

actually doesn't have any fixed numbers in it

in it

in it instead we're using variables we're

instead we're using variables we're

instead we're using variables we're using two variables that are defined

using two variables that are defined

using two variables that are defined outside that function and we're using

outside that function and we're using

outside that function and we're using one variable that is defined within that

one variable that is defined within that

one variable that is defined within that function right

function right

function right this variable actually belongs to that

this variable actually belongs to that

this variable actually belongs to that function

function

function and now as you see whenever we want to

and now as you see whenever we want to

and now as you see whenever we want to use

use

use that function we're telling python hey

that function we're telling python hey

that function we're telling python hey call this function called days to units

call this function called days to units

call this function called days to units with a parameter an input basically

with a parameter an input basically

with a parameter an input basically of 35. so now if we execute it

of 35. so now if we execute it

of 35. so now if we execute it by the way we can also do it here you

by the way we can also do it here you

by the way we can also do it here you see 35 days

see 35 days

see 35 days are and the calculation was done here

are and the calculation was done here

are and the calculation was done here and

and

and hours and now if we go back to

hours and now if we go back to

hours and now if we go back to our previous example where we wanted to

our previous example where we wanted to

our previous example where we wanted to calculate these for

calculate these for

calculate these for four different values right for

four different values right for

four different values right for different number of days

different number of days

different number of days we can actually do the same

we can actually do the same

we can actually do the same so we had 20 then we had

so we had 20 then we had

so we had 20 then we had 50 and we had 110

50 and we had 110

50 and we had 110 right so this basically gives us exactly

right so this basically gives us exactly

right so this basically gives us exactly the same logic that we had previously

the same logic that we had previously

the same logic that we had previously but with different syntax right so you

but with different syntax right so you

but with different syntax right so you see the difference

see the difference

see the difference that instead of having this basically

that instead of having this basically

that instead of having this basically four times

four times

four times we have much cleaner syntax where we

we have much cleaner syntax where we

we have much cleaner syntax where we actually see what this logic is doing

actually see what this logic is doing

actually see what this logic is doing which is days to units and then

which is days to units and then

which is days to units and then we have the number of days that we pass

we have the number of days that we pass

we have the number of days that we pass or

or

or give our function as parameter and if i

give our function as parameter and if i

give our function as parameter and if i execute this you see that

execute this you see that

execute this you see that it was printed four times for all

it was printed four times for all

it was printed four times for all different values

different values

different values we can actually remove this line

we can actually remove this line

we can actually remove this line and now if we make some change in

and now if we make some change in

and now if we make some change in our function for example we change the

our function for example we change the

our function for example we change the name of this

name of this

name of this variable we want it to be hours instead

variable we want it to be hours instead

variable we want it to be hours instead of units

of units

of units we just do it once in one place

we just do it once in one place

we just do it once in one place and that's basically it so whatever

and that's basically it so whatever

and that's basically it so whatever changes we make

changes we make

changes we make inside that function and that is

inside that function and that is

inside that function and that is actually

actually

actually the big advantage of using functions in

the big advantage of using functions in

the big advantage of using functions in code

code

code whatever change we make inside here

whatever change we make inside here

whatever change we make inside here it doesn't affect how we use the

it doesn't affect how we use the

it doesn't affect how we use the function because

function because

function because for using the function we only need the

for using the function we only need the

for using the function we only need the name of that function

name of that function

name of that function and the input parameter now probably

and the input parameter now probably

and the input parameter now probably you're wondering

you're wondering

you're wondering what happens if i do not give my

what happens if i do not give my

what happens if i do not give my function a value

function a value

function a value let's delete those lines and let's say

let's delete those lines and let's say

let's delete those lines and let's say we do not provide any value here

we do not provide any value here

we do not provide any value here and we try to execute or

and we try to execute or

and we try to execute or call our function without the parameter

call our function without the parameter

call our function without the parameter and let's execute

and let's execute

and let's execute and you see that python interpreter is

and you see that python interpreter is

and you see that python interpreter is complaining because we have told python

complaining because we have told python

complaining because we have told python here is a function called these two

here is a function called these two

here is a function called these two units

units

units and whenever i want to use that or my

and whenever i want to use that or my

and whenever i want to use that or my colleague another programmer wants to

colleague another programmer wants to

colleague another programmer wants to use that function

use that function

use that function they have to provide an input value here

they have to provide an input value here

they have to provide an input value here right so now whenever python sees

right so now whenever python sees

right so now whenever python sees the usage of that function and there is

the usage of that function and there is

the usage of that function and there is no input

no input

no input parameter that we are giving that

parameter that we are giving that

parameter that we are giving that function it cannot

function it cannot

function it cannot execute that function right because

execute that function right because

execute that function right because basically this

basically this

basically this value is missing here right and that's

value is missing here right and that's

value is missing here right and that's why we get

why we get

why we get an error which also says missing one

an error which also says missing one

an error which also says missing one required

required

required argument so as you see whenever we

argument so as you see whenever we

argument so as you see whenever we define a function with a parameter

define a function with a parameter

define a function with a parameter with input parameter we have to also

with input parameter we have to also

with input parameter we have to also provide that input parameter

provide that input parameter

provide that input parameter another thing that you may be also

another thing that you may be also

another thing that you may be also wondering is

wondering is

wondering is what if i want to provide multiple input

what if i want to provide multiple input

what if i want to provide multiple input parameters to functions

parameters to functions

parameters to functions how do i do that it's actually very

how do i do that it's actually very

how do i do that it's actually very simple you can do that by

simple you can do that by

simple you can do that by simply defining here another input

simply defining here another input

simply defining here another input parameter

parameter

parameter separated by comma and let's say we want

separated by comma and let's say we want

separated by comma and let's say we want to pass

to pass

to pass here something that we want to print out

here something that we want to print out

here something that we want to print out additionally like a custom message

additionally like a custom message

additionally like a custom message doesn't really matter and the same way

doesn't really matter and the same way

doesn't really matter and the same way exactly the same way as the first one we

exactly the same way as the first one we

exactly the same way as the first one we can actually

can actually

can actually use it in here we can even create a new

use it in here we can even create a new

use it in here we can even create a new line

line

line and basically just print out that

and basically just print out that

and basically just print out that message right

message right

message right and note that if you are using a

and note that if you are using a

and note that if you are using a variable without

variable without

variable without stream so basically it's just the

stream so basically it's just the

stream so basically it's just the variable itself we're not using any text

variable itself we're not using any text

variable itself we're not using any text in that case you don't need this format

in that case you don't need this format

in that case you don't need this format right

right

right so you can basically just print it out

so you can basically just print it out

so you can basically just print it out directly

directly

directly and now again we have told python

and now again we have told python

and now again we have told python i have this function and two input

i have this function and two input

i have this function and two input parameters are required

parameters are required

parameters are required so i also need to pass to input

so i also need to pass to input

so i also need to pass to input values whenever i use that function so

values whenever i use that function so

values whenever i use that function so now let me just pass in some custom

now let me just pass in some custom

now let me just pass in some custom message

message

message let's say i'm happy about the

let's say i'm happy about the

let's say i'm happy about the calculation or i know i'm going to be

calculation or i know i'm going to be

calculation or i know i'm going to be happy so

happy so

happy so let's say awesome and

let's say awesome and

let's say awesome and let's do another calculation and this

let's do another calculation and this

let's do another calculation and this time

time

time i say looks good

i say looks good

i say looks good and if i execute it you see that i get

and if i execute it you see that i get

and if i execute it you see that i get awesome the first time and then for 35 i

awesome the first time and then for 35 i

awesome the first time and then for 35 i get

get

get looks good so you can basically define

looks good so you can basically define

looks good so you can basically define and provide as many

and provide as many

and provide as many input parameters as you want common

input parameters as you want common

input parameters as you want common practice

practice

practice and also what you will see in just

and also what you will see in just

and also what you will see in just normal code basically

normal code basically

normal code basically is just a handful of input parameters

is just a handful of input parameters

is just a handful of input parameters maybe one or two

maybe one or two

maybe one or two so it's not actually overloaded with 10

so it's not actually overloaded with 10

so it's not actually overloaded with 10 parameters

cool now that we know functions and

cool now that we know functions and variables

variables

variables why they're used or why are they useful

why they're used or why are they useful

why they're used or why are they useful and how we use them

and how we use them

and how we use them there is one point that i want to

there is one point that i want to

there is one point that i want to mention

mention

mention which is variable scopes in functions

which is variable scopes in functions

which is variable scopes in functions what does it mean as i mentioned

what does it mean as i mentioned

what does it mean as i mentioned previously in this function we're using

previously in this function we're using

previously in this function we're using multiple variables right we're using two

multiple variables right we're using two

multiple variables right we're using two variables

variables

variables that are part of the input right that

that are part of the input right that

that are part of the input right that we provide when using a function and

we provide when using a function and

we provide when using a function and we're using two variables that are

we're using two variables that are

we're using two variables that are defined outside the function right

defined outside the function right

defined outside the function right somewhere else in the code

somewhere else in the code

somewhere else in the code so variable scope basically means where

so variable scope basically means where

so variable scope basically means where is the variable that function uses

is the variable that function uses

is the variable that function uses defined and variable has a global scope

defined and variable has a global scope

defined and variable has a global scope for a function

for a function

for a function if it is defined outside the function

if it is defined outside the function

if it is defined outside the function like

like

like these two variables right here could be

these two variables right here could be

these two variables right here could be completely

completely

completely in a different file not even in the same

in a different file not even in the same

in a different file not even in the same file where the function is

file where the function is

file where the function is so these are global variables so all the

so these are global variables so all the

so these are global variables so all the functions that you have

functions that you have

functions that you have in your python code can use those global

in your python code can use those global

in your python code can use those global variables and then you have

variables and then you have

variables and then you have local variables local variables are

local variables local variables are

local variables local variables are variables that are

variables that are

variables that are created within that function right

created within that function right

created within that function right so these two variables are basically

so these two variables are basically

so these two variables are basically only

only

only available inside that function

available inside that function

available inside that function because it was created within that

because it was created within that

because it was created within that function

function

function so internal scope and global scope

so internal scope and global scope

so internal scope and global scope so that means that when we create

so that means that when we create

so that means that when we create another function

another function

another function let's call it scope check because that's

let's call it scope check because that's

let's call it scope check because that's what we're going to do

what we're going to do

what we're going to do we want to test the scope

in this function i can access

in this function i can access the global variables like

the global variables like

the global variables like name of units

name of units

name of units but i cannot access the internal

but i cannot access the internal

but i cannot access the internal variables

variables

variables like number of days and let's actually

like number of days and let's actually

like number of days and let's actually test that

so i have num of units which is a global

so i have num of units which is a global variable defined here

variable defined here

variable defined here outside the function and the second one

outside the function and the second one

outside the function and the second one i have a variable that is defined

i have a variable that is defined

i have a variable that is defined inside another function right

inside another function right

inside another function right so as i said internal and as you see

so as i said internal and as you see

so as i said internal and as you see right here

right here

right here we already get a red line underneath

we already get a red line underneath

we already get a red line underneath that says

that says

that says unresolved reference num of days

unresolved reference num of days

unresolved reference num of days so for this function basically that

so for this function basically that

so for this function basically that variable

variable

variable is not visible it's not accessible it

is not visible it's not accessible it

is not visible it's not accessible it doesn't exist basically at all

doesn't exist basically at all

doesn't exist basically at all and we can even test it out actually

and we can even test it out actually

and we can even test it out actually so again if we want to see the results

so again if we want to see the results

so again if we want to see the results we have to actually use that

we have to actually use that

we have to actually use that function like this run the function and

function like this run the function and

function like this run the function and if i execute it

if i execute it

if i execute it you see that we get an error that says

you see that we get an error that says

you see that we get an error that says name num of days is not defined right it

name num of days is not defined right it

name num of days is not defined right it doesn't know that there is a function

doesn't know that there is a function

doesn't know that there is a function like that

like that

like that anywhere in code however it does

anywhere in code however it does

anywhere in code however it does recognize

recognize

recognize the global variable and that means that

the global variable and that means that

the global variable and that means that variables defined outside function

variables defined outside function

variables defined outside function itself global variables are accessible

itself global variables are accessible

itself global variables are accessible to all the functions

to all the functions

to all the functions and if you have variables defined inside

and if you have variables defined inside

and if you have variables defined inside the function then they're only

the function then they're only

the function then they're only accessible for that specific function

accessible for that specific function

accessible for that specific function and not for other ones and that means

and not for other ones and that means

and not for other ones and that means actually that if

actually that if

actually that if num of days variable does not exist for

num of days variable does not exist for

num of days variable does not exist for scope check variable

scope check variable

scope check variable we can actually create a variable

we can actually create a variable

we can actually create a variable inside scope check with the same name

inside scope check with the same name

inside scope check with the same name and we would have basically

and we would have basically

and we would have basically no problem at all so this is not going

no problem at all so this is not going

no problem at all so this is not going to be a duplicate

to be a duplicate

to be a duplicate because this function doesn't know about

because this function doesn't know about

because this function doesn't know about this variable the number of days here

this variable the number of days here

this variable the number of days here and scope check doesn't know anything

and scope check doesn't know anything

and scope check doesn't know anything about variable

about variable

about variable num of days right here and if we

num of days right here and if we

num of days right here and if we want to use that function now we have to

want to use that function now we have to

want to use that function now we have to put provide the value

put provide the value

put provide the value let's do 20 and if i execute

let's do 20 and if i execute

let's do 20 and if i execute there you go you have name of units and

there you go you have name of units and

there you go you have name of units and the 20 that we provided so global

the 20 that we provided so global

the 20 that we provided so global variable

variable

variable local variable defined here another

local variable defined here another

local variable defined here another interesting thing is that

interesting thing is that

interesting thing is that as i said inside the function

as i said inside the function

as i said inside the function body so to say so this is basically

body so to say so this is basically

body so to say so this is basically whatever

whatever

whatever is part of the function right in this

is part of the function right in this

is part of the function right in this indentation

indentation

indentation is called function body so we can

is called function body so we can

is called function body so we can create whatever logic we want inside

create whatever logic we want inside

create whatever logic we want inside that function body

that function body

that function body so whatever i can do in python

so whatever i can do in python

so whatever i can do in python generally i can do inside the function

generally i can do inside the function

generally i can do inside the function body

body

body so one of those things is actually

so one of those things is actually

so one of those things is actually creating variables

creating variables

creating variables right just like we created variables

right just like we created variables

right just like we created variables here we can create variables

here we can create variables

here we can create variables here like this let's call it

here like this let's call it

here like this let's call it myvariable and

myvariable and

myvariable and variable inside function

variable inside function

variable inside function and we can print that out as well

so now we have three types of variables

so now we have three types of variables that we are

that we are

that we are using in this function we have a global

using in this function we have a global

using in this function we have a global variable

variable

variable we have internal variable that is passed

we have internal variable that is passed

we have internal variable that is passed in as a parameter and we have internal

in as a parameter and we have internal

in as a parameter and we have internal variable again

variable again

variable again that is basically defined so the

that is basically defined so the

that is basically defined so the variable isn't

variable isn't

variable isn't provided when we use the function but

provided when we use the function but

provided when we use the function but it's basically just

it's basically just

it's basically just defined inside the variable and again if

defined inside the variable and again if

defined inside the variable and again if i

i

i execute this

see hours num updates and variable

see hours num updates and variable inside function

inside function

inside function text printed out like this

text printed out like this

text printed out like this and obviously this is just for

and obviously this is just for

and obviously this is just for demonstration but we're going to see

demonstration but we're going to see

demonstration but we're going to see more realistic examples of that in our

more realistic examples of that in our

more realistic examples of that in our projects

projects

projects so i'm going to clean this up and

so i'm going to clean this up and

so i'm going to clean this up and we can move on to the next concept

so now let's go back to the example

so now let's go back to the example where we calculate

where we calculate

where we calculate number of hours and we do that for four

number of hours and we do that for four

number of hours and we do that for four different values now if you want this

different values now if you want this

different values now if you want this application to be really useful

application to be really useful

application to be really useful for us or somebody else it doesn't help

for us or somebody else it doesn't help

for us or somebody else it doesn't help that we have to

that we have to

that we have to fixate here just four different values

fixate here just four different values

fixate here just four different values right

right

right the application should be able to take

the application should be able to take

the application should be able to take any value that we basically

any value that we basically

any value that we basically fit it right so we should be able to

fit it right so we should be able to

fit it right so we should be able to provide any number of days and the

provide any number of days and the

provide any number of days and the program should calculate

program should calculate

program should calculate the number of hours in those days so

the number of hours in those days so

the number of hours in those days so what we need here

what we need here

what we need here is user input so when we give this

is user input so when we give this

is user input so when we give this application

application

application program to somebody else or use it

program to somebody else or use it

program to somebody else or use it ourselves

ourselves

ourselves it should allow some user input so

it should allow some user input so

it should allow some user input so how do we write a program that asks for

how do we write a program that asks for

how do we write a program that asks for and accepts

and accepts

and accepts a user input and then does something

a user input and then does something

a user input and then does something some kind of

some kind of

some kind of calculation some kind of other logic

calculation some kind of other logic

calculation some kind of other logic based on that

based on that

based on that user input accepting a user input

user input accepting a user input

user input accepting a user input from a python application is actually

from a python application is actually

from a python application is actually pretty easy

pretty easy

pretty easy let's get rid of all of these lines

let's get rid of all of these lines

let's get rid of all of these lines first

first

first and we can do that by writing input

and we can do that by writing input

and we can do that by writing input and this will basically give a user a

and this will basically give a user a

and this will basically give a user a prompt

prompt

prompt to enter some input value now

to enter some input value now

to enter some input value now you probably already see from the syntax

you probably already see from the syntax

you probably already see from the syntax that this looks very much like

that this looks very much like

that this looks very much like using our days to units function

using our days to units function

using our days to units function right in this case with the parameter so

right in this case with the parameter so

right in this case with the parameter so input is

input is

input is actually a function that python provides

actually a function that python provides

actually a function that python provides us with

us with

us with so we didn't have to write this input

so we didn't have to write this input

so we didn't have to write this input function right we wrote the days to

function right we wrote the days to

function right we wrote the days to units function

units function

units function but input function is available in

but input function is available in

but input function is available in python

python

python so that we can use it whenever we want

so that we can use it whenever we want

so that we can use it whenever we want and this parenthesis here tells python

and this parenthesis here tells python

and this parenthesis here tells python we want to call

we want to call

we want to call an input function and we're calling it

an input function and we're calling it

an input function and we're calling it or using a function without a parameter

or using a function without a parameter

or using a function without a parameter so now we know that we can write

so now we know that we can write

so now we know that we can write functions

functions

functions ourselves for logic that we need

ourselves for logic that we need

ourselves for logic that we need but python has tons of functions

but python has tons of functions

but python has tons of functions that python developers already wrote and

that python developers already wrote and

that python developers already wrote and is

is

is part of python and we can use it in our

part of python and we can use it in our

part of python and we can use it in our code so that not everybody

code so that not everybody

code so that not everybody has to write their own input function

has to write their own input function

has to write their own input function logic

logic

logic and the code or the functions that

and the code or the functions that

and the code or the functions that python provides

python provides

python provides are again part of this python that we

are again part of this python that we

are again part of this python that we use in a project

use in a project

use in a project and obviously if you're using the latest

and obviously if you're using the latest

and obviously if you're using the latest version

version

version of python you will get the latest code

of python you will get the latest code

of python you will get the latest code and latest

and latest

and latest functions that python basically provides

functions that python basically provides

functions that python basically provides so back to our function execution

so back to our function execution

so back to our function execution and let's see what happens when we

and let's see what happens when we

and let's see what happens when we execute this program

execute this program

execute this program i'm going to run it and in the outputs

i'm going to run it and in the outputs

i'm going to run it and in the outputs you actually do not see anything

you actually do not see anything

you actually do not see anything other than my cursor is blinking here

other than my cursor is blinking here

other than my cursor is blinking here so it's actually waiting for user input

so it's actually waiting for user input

so it's actually waiting for user input so i can actually type in

so i can actually type in

so i can actually type in something here so i can do 20 and enter

something here so i can do 20 and enter

something here so i can do 20 and enter and process finished with exit code so i

and process finished with exit code so i

and process finished with exit code so i was able to

was able to

was able to input something doesn't really matter

input something doesn't really matter

input something doesn't really matter it could also be a string actually

it could also be a string actually

it could also be a string actually doesn't

doesn't

doesn't really matter and program basically

really matter and program basically

really matter and program basically finishes so that's the simplest usage of

finishes so that's the simplest usage of

finishes so that's the simplest usage of input however as you noticed here

input however as you noticed here

input however as you noticed here running this program and basically

running this program and basically

running this program and basically having this blank

having this blank

having this blank output here is a little bit confusing so

output here is a little bit confusing so

output here is a little bit confusing so if another user

if another user

if another user is using our program they will probably

is using our program they will probably

is using our program they will probably be wondering what's happening here

be wondering what's happening here

be wondering what's happening here so what we can do is in input function

so what we can do is in input function

so what we can do is in input function we can provide a parameter that actually

we can provide a parameter that actually

we can provide a parameter that actually tells a user something right like

tells a user something right like

tells a user something right like enter a value for number of days or

enter a value for number of days or

enter a value for number of days or something similar so that it's not just

something similar so that it's not just

something similar so that it's not just a

a

a blank prompt right so we can do that by

blank prompt right so we can do that by

blank prompt right so we can do that by passing in a parameter a string which is

passing in a parameter a string which is

passing in a parameter a string which is going to be our message

going to be our message

going to be our message so we can do a user

so we can do a user

so we can do a user enter a number of days

and i will convert it to

and i will convert it to hours and here you see right now that

hours and here you see right now that

hours and here you see right now that the program wasn't finished because we

the program wasn't finished because we

the program wasn't finished because we didn't enter

didn't enter

didn't enter anything so this program finished line

anything so this program finished line

anything so this program finished line wasn't output yet and that means the

wasn't output yet and that means the

wasn't output yet and that means the program is still running

program is still running

program is still running it is still waiting for our input

it is still waiting for our input

it is still waiting for our input and in pycharm in this ide

and in pycharm in this ide

and in pycharm in this ide if you want to terminate the program

if you want to terminate the program

if you want to terminate the program manually yourself

manually yourself

manually yourself you can click this stop button

you can click this stop button

you can click this stop button and as you see process finished so

and as you see process finished so

and as you see process finished so now we can run the program again and as

now we can run the program again and as

now we can run the program again and as you see here we

you see here we

you see here we already have a message that we're

already have a message that we're

already have a message that we're displaying to the user

displaying to the user

displaying to the user so that they can enter the hours right

so that they can enter the hours right

so that they can enter the hours right and here we can provide our input

and here we can provide our input

and here we can provide our input 30 and there you go however

30 and there you go however

30 and there you go however this doesn't look nice here we actually

this doesn't look nice here we actually

this doesn't look nice here we actually want the user

want the user

want the user to get a prompt on the next line how do

to get a prompt on the next line how do

to get a prompt on the next line how do we do that

we do that

we do that as part of a string we can actually add

as part of a string we can actually add

as part of a string we can actually add a new line

a new line

a new line or newline character basically and

or newline character basically and

or newline character basically and that in programming is actually

that in programming is actually

that in programming is actually represented

represented

represented by backslash n and you see

by backslash n and you see

by backslash n and you see a special highlighting for that one now

a special highlighting for that one now

a special highlighting for that one now let's execute

let's execute

let's execute and you see that my cursor is on the

and you see that my cursor is on the

and you see that my cursor is on the next line now

next line now

next line now and again let's provide a value enter

and again let's provide a value enter

and again let's provide a value enter and program ended so we have

and program ended so we have

and program ended so we have now a more user-friendly way of asking

now a more user-friendly way of asking

now a more user-friendly way of asking program user for their input

program user for their input

program user for their input instead of just showing an empty prompt

instead of just showing an empty prompt

instead of just showing an empty prompt and we're getting user input

and we're getting user input

and we're getting user input now we're not doing anything with that

now we're not doing anything with that

now we're not doing anything with that user input right

user input right

user input right that input basically just finishes the

that input basically just finishes the

that input basically just finishes the program and that's it

program and that's it

program and that's it we're not doing any calculation for that

we're not doing any calculation for that

we're not doing any calculation for that input

input

input so how do we use the value that user

so how do we use the value that user

so how do we use the value that user enters here

enters here

enters here when input function gets executed we do

when input function gets executed we do

when input function gets executed we do that and this is a very important

that and this is a very important

that and this is a very important concept

concept

concept by assigning whatever result

by assigning whatever result

by assigning whatever result this function usage gives us which is

this function usage gives us which is

this function usage gives us which is in this case user input assigning that

in this case user input assigning that

in this case user input assigning that result to a variable so right now it's

result to a variable so right now it's

result to a variable so right now it's basically

basically

basically executed and it's just wasted right it

executed and it's just wasted right it

executed and it's just wasted right it just disappears

just disappears

just disappears so instead we want to save that value

so instead we want to save that value

so instead we want to save that value that entered

that entered

that entered input value in a variable so that we can

input value in a variable so that we can

input value in a variable so that we can access it later and we do that by

access it later and we do that by

access it later and we do that by let's call it user input variable

let's call it user input variable

let's call it user input variable equals so just like we created variables

equals so just like we created variables

equals so just like we created variables here

here

here with variable name and a value right or

with variable name and a value right or

with variable name and a value right or even an expression right if we did a

even an expression right if we did a

even an expression right if we did a calculation here that will be

calculation here that will be

calculation here that will be basically a whole expression whole

basically a whole expression whole

basically a whole expression whole calculation

calculation

calculation the same way we can use values

the same way we can use values

the same way we can use values that function execution gives

that function execution gives

that function execution gives us to assign it to a variable so now

us to assign it to a variable so now

us to assign it to a variable so now what i'm going to do

what i'm going to do

what i'm going to do is i'm just going to print the user

is i'm just going to print the user

is i'm just going to print the user input

input

input so that we can see what value that

so that we can see what value that

so that we can see what value that user input variable has so let's execute

user input variable has so let's execute

user input variable has so let's execute again

again

again it asks for our input let's put 20

it asks for our input let's put 20

it asks for our input let's put 20 and print user input gives us 20.

and print user input gives us 20.

and print user input gives us 20. so user input variable value basically

so user input variable value basically

so user input variable value basically becomes

becomes

becomes whatever we provide as an input

now that's a new concept and it could be

now that's a new concept and it could be a little bit confusing

a little bit confusing

a little bit confusing so let's see another example with our

so let's see another example with our

so let's see another example with our own function

own function

own function what would happen if we

assigned value of this

assigned value of this to a variable

we get a warning as you see here in the

we get a warning as you see here in the editor

editor

editor which is one of the great things about

which is one of the great things about

which is one of the great things about ides that it basically gives you

ides that it basically gives you

ides that it basically gives you warnings when something is not correct

warnings when something is not correct

warnings when something is not correct and the warning says function doesn't

and the warning says function doesn't

and the warning says function doesn't return anything

return anything

return anything so basically if we want to have some

so basically if we want to have some

so basically if we want to have some value

value

value as a result of function execution we

as a result of function execution we

as a result of function execution we have to return

have to return

have to return some value in the function and how we do

some value in the function and how we do

some value in the function and how we do that

that

that instead of printing the value right away

instead of printing the value right away

instead of printing the value right away we can actually return that value

we can actually return that value

we can actually return that value using return keyword again you see

using return keyword again you see

using return keyword again you see special highlighting here just like here

special highlighting here just like here

special highlighting here just like here because return

because return

because return is a special word that python

is a special word that python

is a special word that python understands

understands

understands that you want to basically give back

that you want to basically give back

that you want to basically give back a value this value right here as a

a value this value right here as a

a value this value right here as a result

result

result of using the function right so you could

of using the function right so you could

of using the function right so you could have

have

have some logic here doing the calculation

some logic here doing the calculation

some logic here doing the calculation whatever

whatever

whatever and then as the last line you can return

and then as the last line you can return

and then as the last line you can return that calculated value and now

that calculated value and now

that calculated value and now the warning is gone because we're

the warning is gone because we're

the warning is gone because we're actually returning something

actually returning something

actually returning something from the function and when we return

from the function and when we return

from the function and when we return value from a function again we can

value from a function again we can

value from a function again we can assign it

assign it

assign it to a variable so that we can use that

to a variable so that we can use that

to a variable so that we can use that value whatever function

value whatever function

value whatever function returned by referencing the variable and

returned by referencing the variable and

returned by referencing the variable and one of the usages will be basically just

one of the usages will be basically just

one of the usages will be basically just to print it

to print it

to print it just like we did before like this let's

just like we did before like this let's

just like we did before like this let's delete it temporarily and

delete it temporarily and

delete it temporarily and test our program

test our program

test our program and there you go you see that this

and there you go you see that this

and there you go you see that this function

function

function got executed with input 20

got executed with input 20

got executed with input 20 this text this display text basically

this text this display text basically

this text this display text basically was put together in the function and was

was put together in the function and was

was put together in the function and was returned or was given back

returned or was given back

returned or was given back as a result and we saved that

as a result and we saved that

as a result and we saved that this whole string basically this whole

this whole string basically this whole

this whole string basically this whole sentence in a variable called myvar

sentence in a variable called myvar

sentence in a variable called myvar and when we print that myvar we see that

and when we print that myvar we see that

and when we print that myvar we see that value

value

value printed out here and again if we enter

printed out here and again if we enter

printed out here and again if we enter some other value we would get different

some other value we would get different

some other value we would get different text

text

text and again that is actually a very

and again that is actually a very

and again that is actually a very important concept

important concept

important concept of giving back some results from a

of giving back some results from a

of giving back some results from a function execution and you saw in our

function execution and you saw in our

function execution and you saw in our examples that

examples that

examples that you can have a function that doesn't

you can have a function that doesn't

you can have a function that doesn't return a value just print something on

return a value just print something on

return a value just print something on maybe does something else

maybe does something else

maybe does something else or function that returns some value you

or function that returns some value you

or function that returns some value you can have

can have

can have both types

so back to our example of

so back to our example of user input so now hopefully it makes

user input so now hopefully it makes

user input so now hopefully it makes sense

sense

sense that input function returns

that input function returns

that input function returns whatever value the user entered as a

whatever value the user entered as a

whatever value the user entered as a result and we can

result and we can

result and we can save it in a variable and then access it

save it in a variable and then access it

save it in a variable and then access it later again let's

later again let's

later again let's get rid of this line and now let's

get rid of this line and now let's

get rid of this line and now let's actually do the calculation

actually do the calculation

actually do the calculation on the user input number of days how do

on the user input number of days how do

on the user input number of days how do we calculate number of days

we calculate number of days

we calculate number of days very simple by calling our function that

very simple by calling our function that

very simple by calling our function that actually

actually

actually does that so we're going to call our

does that so we're going to call our

does that so we're going to call our function

function

function to calculate the number of hours for

to calculate the number of hours for

to calculate the number of hours for an input and the parameter that we

an input and the parameter that we

an input and the parameter that we passed

passed

passed in is going to be whatever the user

in is going to be whatever the user

in is going to be whatever the user provided

provided

provided so instead of basically hard coding a

so instead of basically hard coding a

so instead of basically hard coding a value here

value here

value here ourselves we give it a value that user

ourselves we give it a value that user

ourselves we give it a value that user provided instead so the num of days will

provided instead so the num of days will

provided instead so the num of days will be

be

be the user input and now again because

the user input and now again because

the user input and now again because this function

this function

this function returns the whole string it doesn't

returns the whole string it doesn't

returns the whole string it doesn't print it

print it

print it remember it just returns it so when i

remember it just returns it so when i

remember it just returns it so when i execute this and i provide in

execute this and i provide in

execute this and i provide in some value that's to 200 you see that

some value that's to 200 you see that

some value that's to 200 you see that i don't have any output here because we

i don't have any output here because we

i don't have any output here because we didn't print anything we

didn't print anything we

didn't print anything we basically just returned the value here

basically just returned the value here

basically just returned the value here we didn't do

we didn't do

we didn't do anything with it so the last piece

anything with it so the last piece

anything with it so the last piece missing here is

missing here is

missing here is to display the text the string that

to display the text the string that

to display the text the string that function returns so we save that

function returns so we save that

function returns so we save that return value first let's do calculated

return value first let's do calculated

return value first let's do calculated value so we save this thing

value so we save this thing

value so we save this thing in calculated value variable and

in calculated value variable and

in calculated value variable and finally we can print it and now let's

finally we can print it and now let's

finally we can print it and now let's execute it and

execute it and

execute it and let's see what happens i'm going to type

let's see what happens i'm going to type

let's see what happens i'm going to type in

in

in 10 10 days and let's see what we get now

10 10 days and let's see what we get now

10 10 days and let's see what we get now and you see we have this weird value

and you see we have this weird value

and you see we have this weird value here

here

here as a result of the calculation so what

as a result of the calculation so what

as a result of the calculation so what exactly happened

exactly happened

exactly happened so this part of calculation basically

so this part of calculation basically

so this part of calculation basically which represents this number didn't do a

which represents this number didn't do a

which represents this number didn't do a proper calculation

proper calculation

proper calculation and the reason for that is because the

and the reason for that is because the

and the reason for that is because the input value that we get

input value that we get

input value that we get with inputs function is always

with inputs function is always

with inputs function is always treated as a string and not a number so

treated as a string and not a number so

treated as a string and not a number so basically

basically

basically at this place here number of days inputs

at this place here number of days inputs

at this place here number of days inputs 10 here is actually treated as a

10 here is actually treated as a

10 here is actually treated as a text and not a number and where this

text and not a number and where this

text and not a number and where this weird result comes from is basically

weird result comes from is basically

weird result comes from is basically number 10 printed out 24

number 10 printed out 24

number 10 printed out 24 times so instead of doing the actual

times so instead of doing the actual

times so instead of doing the actual calculation 10 times 24

calculation 10 times 24

calculation 10 times 24 10 is printed 24 times and that's what

10 is printed 24 times and that's what

10 is printed 24 times and that's what happens when this is interpreted as

happens when this is interpreted as

happens when this is interpreted as a string so how do we make python

a string so how do we make python

a string so how do we make python see that number see that input value as

see that number see that input value as

see that number see that input value as a number as an integer and not a

a number as an integer and not a

a number as an integer and not a text or not as a string and it's

text or not as a string and it's

text or not as a string and it's actually pretty easy to do

actually pretty easy to do

actually pretty easy to do on the next line the user inputs again

on the next line the user inputs again

on the next line the user inputs again we saw

we saw

we saw right here it is a string so we have to

right here it is a string so we have to

right here it is a string so we have to make it into a number and we're going to

make it into a number and we're going to

make it into a number and we're going to do that

do that

do that using int and user input

using int and user input

using int and user input and that process of turning a value from

and that process of turning a value from

and that process of turning a value from one data type into another

one data type into another

one data type into another is called casting if you remember we

is called casting if you remember we

is called casting if you remember we already saw an example of it when we

already saw an example of it when we

already saw an example of it when we turned

turned

turned a number into a string in the string

a number into a string in the string

a number into a string in the string concatenation example

concatenation example

concatenation example again from the syntax you should already

again from the syntax you should already

again from the syntax you should already know that this is a function

know that this is a function

know that this is a function call so we're calling a function called

call so we're calling a function called

call so we're calling a function called int again

int again

int again that python itself provides us with

that python itself provides us with

that python itself provides us with because we didn't write that function

because we didn't write that function

because we didn't write that function and we're passing in

and we're passing in

and we're passing in one parameter which is a string and we

one parameter which is a string and we

one parameter which is a string and we should

should

should get an integer from that string as a

get an integer from that string as a

get an integer from that string as a result

result

result and we can save that number into a

and we can save that number into a

and we can save that number into a variable and let's call it user

variable and let's call it user

variable and let's call it user input number and

input number and

input number and now we have 10 as a number instead of as

now we have 10 as a number instead of as

now we have 10 as a number instead of as a string

a string

a string and instead of passing in that string

and instead of passing in that string

and instead of passing in that string user input we can

user input we can

user input we can now give our function number

now give our function number

now give our function number that it expects let's save it and

that it expects let's save it and

that it expects let's save it and execute

execute

execute let's put in 10 and there you go now the

let's put in 10 and there you go now the

let's put in 10 and there you go now the calculation

calculation

calculation is correct what i want to show you now

is correct what i want to show you now

is correct what i want to show you now is how this user input actually works

is how this user input actually works

is how this user input actually works without

without

without a code editor like pycharm so i'm gonna

a code editor like pycharm so i'm gonna

a code editor like pycharm so i'm gonna copy all this code and let's go back to

copy all this code and let's go back to

copy all this code and let's go back to our terminal

i'm going to paste in our code

i'm going to paste in our code and save and let's now actually

and save and let's now actually

and save and let's now actually see how the user input works when we

see how the user input works when we

see how the user input works when we execute it

execute it

execute it in a simple terminal window and as you

in a simple terminal window and as you

in a simple terminal window and as you see here we have the message first

see here we have the message first

see here we have the message first and the prompt is right here so we can

and the prompt is right here so we can

and the prompt is right here so we can enter a value

enter a value

enter a value let's do 25 enter

let's do 25 enter

let's do 25 enter and we have a result 25 days are

and we have a result 25 days are

and we have a result 25 days are 600 hours

great so our program is working it is

great so our program is working it is converting

converting

converting the number of days to number of hours

the number of days to number of hours

the number of days to number of hours and accepts a user input now what

and accepts a user input now what

and accepts a user input now what happens

happens

happens if a user enters an invalid value here

if a user enters an invalid value here

if a user enters an invalid value here so for example instead of a positive

so for example instead of a positive

so for example instead of a positive value for number of days

value for number of days

value for number of days maybe they enter a negative value like

maybe they enter a negative value like

maybe they enter a negative value like -10 for example and obviously

-10 for example and obviously

-10 for example and obviously that input value doesn't make any sense

that input value doesn't make any sense

that input value doesn't make any sense but we are still

but we are still

but we are still calculating and giving a value right and

calculating and giving a value right and

calculating and giving a value right and this is another

this is another

this is another important concept in programming

important concept in programming

important concept in programming generally

generally

generally that when we allow users to give our

that when we allow users to give our

that when we allow users to give our program

program

program some input value we also want to

some input value we also want to

some input value we also want to restrict them

restrict them

restrict them and basically validate that what they

and basically validate that what they

and basically validate that what they provided as input is a valid value for

provided as input is a valid value for

provided as input is a valid value for our program specifically

our program specifically

our program specifically one that it makes sense like in our case

one that it makes sense like in our case

one that it makes sense like in our case -10 program still does a calculation but

-10 program still does a calculation but

-10 program still does a calculation but it doesn't really make sense

it doesn't really make sense

it doesn't really make sense and second it doesn't crash our program

and second it doesn't crash our program

and second it doesn't crash our program right

right

right so now let's see what happens if we

so now let's see what happens if we

so now let's see what happens if we enter

enter

enter some text here you see

some text here you see

some text here you see that the calculation didn't happen

that the calculation didn't happen

that the calculation didn't happen because

because

because we basically crashed the program

we basically crashed the program

we basically crashed the program application

application

application using that invalid user input does make

using that invalid user input does make

using that invalid user input does make sense

sense

sense or an input that crashes our application

or an input that crashes our application

or an input that crashes our application because the calculation isn't even

because the calculation isn't even

because the calculation isn't even possible

possible

possible and we want to avoid users basically

and we want to avoid users basically

and we want to avoid users basically either providing a nonsense value or a

either providing a nonsense value or a

either providing a nonsense value or a value that will crash our application

value that will crash our application

value that will crash our application so we need to validate user input

so we need to validate user input

so we need to validate user input and this is again important concept in

and this is again important concept in

and this is again important concept in program because

program because

program because whenever you allow user input you always

whenever you allow user input you always

whenever you allow user input you always have to validate it so in this part

have to validate it so in this part

have to validate it so in this part we're going to learn

we're going to learn

we're going to learn concept called conditionals and we're

concept called conditionals and we're

concept called conditionals and we're going to learn this concept

going to learn this concept

going to learn this concept with an example of validating a user

with an example of validating a user

with an example of validating a user input so

input so

input so where are we going to do the user input

where are we going to do the user input

where are we going to do the user input validation we can do it

validation we can do it

validation we can do it in our function right before we

in our function right before we

in our function right before we actually do the calculation we can first

actually do the calculation we can first

actually do the calculation we can first validate

validate

validate is it a positive number and not a

is it a positive number and not a

is it a positive number and not a negative one

negative one

negative one so user gives us their input we

so user gives us their input we

so user gives us their input we convert it to a number and then we pass

convert it to a number and then we pass

convert it to a number and then we pass that number

that number

that number to our function so negative 10

to our function so negative 10

to our function so negative 10 positive 10 that is a number basically

positive 10 that is a number basically

positive 10 that is a number basically will be

will be

will be passed on to our function and right here

passed on to our function and right here

passed on to our function and right here we can check whether this

we can check whether this

we can check whether this variable value here is a negative number

variable value here is a negative number

variable value here is a negative number or not

or not

or not how do we do that we do that using

how do we do that we do that using

how do we do that we do that using if else conditional statements so

if else conditional statements so

if else conditional statements so very simple and intuitive to understand

very simple and intuitive to understand

very simple and intuitive to understand we say if number of days

we say if number of days

we say if number of days is greater than 0

is greater than 0

is greater than 0 means it is a positive number

means it is a positive number

means it is a positive number then we want to do the calculation and

then we want to do the calculation and

then we want to do the calculation and return

return

return all of this but you see that we have a

all of this but you see that we have a

all of this but you see that we have a red line here

red line here

red line here so basically whenever we use if

so basically whenever we use if

so basically whenever we use if condition we have to have a proper

condition we have to have a proper

condition we have to have a proper indentation so all of this line

indentation so all of this line

indentation so all of this line basically goes

basically goes

basically goes indented for this line kind of the same

indented for this line kind of the same

indented for this line kind of the same way as we indented

way as we indented

way as we indented the whole function body inside the

the whole function body inside the

the whole function body inside the function

function

function whatever logic and whatever code is

whatever logic and whatever code is

whatever logic and whatever code is right here

right here

right here indented below the if condition

indented below the if condition

indented below the if condition will be executed if number of days

will be executed if number of days

will be executed if number of days is really greater than zero so let's try

is really greater than zero so let's try

is really greater than zero so let's try that again

that again

that again i'm going to execute it let's put a

i'm going to execute it let's put a

i'm going to execute it let's put a positive 10

positive 10

positive 10 you see 10 days are 240 hours

you see 10 days are 240 hours

you see 10 days are 240 hours got calculated now let's put

got calculated now let's put

got calculated now let's put -10 as an input and you see none

-10 as an input and you see none

-10 as an input and you see none basically no output for us because

basically no output for us because

basically no output for us because this line didn't actually get executed

this line didn't actually get executed

this line didn't actually get executed for -10 input value now what if we want

for -10 input value now what if we want

for -10 input value now what if we want to tell a user

to tell a user

to tell a user hey this was an invalid value and that's

hey this was an invalid value and that's

hey this was an invalid value and that's why we didn't do the calculation

why we didn't do the calculation

why we didn't do the calculation instead of just showing none we can do

instead of just showing none we can do

instead of just showing none we can do that

that

that by returning this feedback message or

by returning this feedback message or

by returning this feedback message or error message

error message

error message whenever this is not true so whenever

whenever this is not true so whenever

whenever this is not true so whenever number of days is not

number of days is not

number of days is not greater than zero we want to return

greater than zero we want to return

greater than zero we want to return something else right another message

something else right another message

something else right another message and we can do that using else

and we can do that using else

and we can do that using else and the same way as for if we have the

and the same way as for if we have the

and the same way as for if we have the indentation

indentation

indentation and whatever we write here will be

and whatever we write here will be

and whatever we write here will be executed if number of days is not

executed if number of days is not

executed if number of days is not greater than zero

greater than zero

greater than zero so here we are gonna return

so here we are gonna return

so here we are gonna return you entered a negative

you entered a negative

you entered a negative value so no

value so no

value so no conversion for you

conversion for you

conversion for you and here it's time for another special

and here it's time for another special

and here it's time for another special term in programming that greater than

term in programming that greater than

term in programming that greater than sign

sign

sign is called a comparison operator and we

is called a comparison operator and we

is called a comparison operator and we have three of them we have greater than

have three of them we have greater than

have three of them we have greater than less than and equals and these are

less than and equals and these are

less than and equals and these are called comparison operators because

called comparison operators because

called comparison operators because they are used in an operation to compare

they are used in an operation to compare

they are used in an operation to compare two values

two values

two values and before in this course we learned

and before in this course we learned

and before in this course we learned arithmetic operations

arithmetic operations

arithmetic operations like plus minus divide multiply so again

like plus minus divide multiply so again

like plus minus divide multiply so again fancy words for

fancy words for

fancy words for simple concepts but these are the

simple concepts but these are the

simple concepts but these are the official terms for these

official terms for these

official terms for these so now if someone mentions them you will

so now if someone mentions them you will

so now if someone mentions them you will know what they're talking about

know what they're talking about

know what they're talking about so now let's execute the application

so now let's execute the application

so now let's execute the application and let's provide -10 and you see that

and let's provide -10 and you see that

and let's provide -10 and you see that this line was printed

this line was printed

this line was printed as a feedback to the user

as a feedback to the user

as a feedback to the user so let's go through the flow again user

so let's go through the flow again user

so let's go through the flow again user gives us their input

gives us their input

gives us their input in this case -10 we convert it to

in this case -10 we convert it to

in this case -10 we convert it to integer

integer

integer so now it's -10 integer and we pass it

so now it's -10 integer and we pass it

so now it's -10 integer and we pass it on to our days to units

on to our days to units

on to our days to units function and these two units function

function and these two units function

function and these two units function basically has this if else statement

basically has this if else statement

basically has this if else statement that's how it's called in programming

that's how it's called in programming

that's how it's called in programming and our if else

and our if else

and our if else statement validates or checks

statement validates or checks

statement validates or checks whether this input is greater than zero

whether this input is greater than zero

whether this input is greater than zero if it is then the function will return

if it is then the function will return

if it is then the function will return this as a result so basically the

this as a result so basically the

this as a result so basically the calculation with a proper message

calculation with a proper message

calculation with a proper message else so basically if this is not

else so basically if this is not

else so basically if this is not the case then it will return basically

the case then it will return basically

the case then it will return basically just

just

just a feedback message for the user and note

a feedback message for the user and note

a feedback message for the user and note that

that

that else doesn't have such a check here we

else doesn't have such a check here we

else doesn't have such a check here we don't check

don't check

don't check num of days is less than zero and the

num of days is less than zero and the

num of days is less than zero and the reason for that

reason for that

reason for that is because it doesn't check for less

is because it doesn't check for less

is because it doesn't check for less than zero

than zero

than zero because it basically just decides if

because it basically just decides if

because it basically just decides if this is not true

this is not true

this is not true else or in that case just do this

else or in that case just do this

else or in that case just do this so we don't need additional check here

so we don't need additional check here

so we don't need additional check here now this segment right here

now this segment right here

now this segment right here where we're doing the check is called a

where we're doing the check is called a

where we're doing the check is called a conditional

conditional

conditional so basically we're providing our program

so basically we're providing our program

so basically we're providing our program a condition

a condition

a condition if this condition is correct

if this condition is correct

if this condition is correct then do something otherwise do something

then do something otherwise do something

then do something otherwise do something else

else

else and that conditional can be true

and that conditional can be true

and that conditional can be true or false if we enter 10 then this

or false if we enter 10 then this

or false if we enter 10 then this conditional will be true

conditional will be true

conditional will be true because it's greater than 0 if we enter

because it's greater than 0 if we enter

because it's greater than 0 if we enter -10 then this conditional will be

-10 then this conditional will be

-10 then this conditional will be negative it's not greater than 0

negative it's not greater than 0

negative it's not greater than 0 and those true and false values in

and those true and false values in

and those true and false values in programming

programming

programming actually are represented by its own data

actually are represented by its own data

actually are represented by its own data type which is called

type which is called

type which is called boolean and in order to show it to you

boolean and in order to show it to you

boolean and in order to show it to you that this conditional either gives true

that this conditional either gives true

that this conditional either gives true or false

or false

or false what i'm going to do is i'm going to

what i'm going to do is i'm going to

what i'm going to do is i'm going to print

print

print this conditional right before i do the

this conditional right before i do the

this conditional right before i do the check

check

check so for a positive number input this

so for a positive number input this

so for a positive number input this should print

should print

should print true and if it's negative so it's not

true and if it's negative so it's not

true and if it's negative so it's not greater than 0 this should print false

greater than 0 this should print false

greater than 0 this should print false so let's test it out

so let's test it out

so let's test it out first i'm going to provide positive 10

first i'm going to provide positive 10

first i'm going to provide positive 10 and right here you see true

and right here you see true

and right here you see true because this condition is indeed true

because this condition is indeed true

because this condition is indeed true and note that this is not a string

and note that this is not a string

and note that this is not a string that's why we don't need the quotes here

that's why we don't need the quotes here

that's why we don't need the quotes here so we can basically just put in the

so we can basically just put in the

so we can basically just put in the whole expression in a print

whole expression in a print

whole expression in a print function and now let's do the same with

function and now let's do the same with

function and now let's do the same with negative 10 and you see

negative 10 and you see

negative 10 and you see false and as i said true and false

false and as i said true and false

false and as i said true and false values belong to its own data type in

values belong to its own data type in

values belong to its own data type in programming

programming

programming which is called a boolean and again we

which is called a boolean and again we

which is called a boolean and again we can demonstrate that

can demonstrate that

can demonstrate that instead of printing it out

instead of printing it out

instead of printing it out we can save it into a variable let's

we can save it into a variable let's

we can save it into a variable let's call it

call it

call it conditional check

conditional check

conditional check and in python there is a function called

and in python there is a function called

and in python there is a function called type which checks or prints out

type which checks or prints out

type which checks or prints out basically

basically

basically a type data type of a variable or

a type data type of a variable or

a type data type of a variable or a single value so if we

a single value so if we

a single value so if we pass it so this will give us data type

pass it so this will give us data type

pass it so this will give us data type of conditional check

of conditional check

of conditional check and obviously if you want to see that

and obviously if you want to see that

and obviously if you want to see that result we need to print it

result we need to print it

result we need to print it so print the whole thing so it doesn't

so print the whole thing so it doesn't

so print the whole thing so it doesn't matter what we pass in

matter what we pass in

matter what we pass in this point and right here you see

this point and right here you see

this point and right here you see class boolean so this

class boolean so this

class boolean so this conditional check here which has a value

conditional check here which has a value

conditional check here which has a value of

of

of true or false is of type boolean

true or false is of type boolean

true or false is of type boolean now there are two things that i want to

now there are two things that i want to

now there are two things that i want to note here

note here

note here the first one is that you see that

the first one is that you see that

the first one is that you see that i am calling a function here which is

i am calling a function here which is

i am calling a function here which is type

type

type and then whatever that function type

and then whatever that function type

and then whatever that function type returns

returns

returns which is basically this output here we

which is basically this output here we

which is basically this output here we are printing it

are printing it

are printing it so we have two function calls that are

so we have two function calls that are

so we have two function calls that are basically

basically

basically nested and that is absolutely fine you

nested and that is absolutely fine you

nested and that is absolutely fine you can nest

can nest

can nest function calls another example of doing

function calls another example of doing

function calls another example of doing this

this

this nested function called would be for

nested function called would be for

nested function called would be for example right here

example right here

example right here instead of assigning these to a variable

instead of assigning these to a variable

instead of assigning these to a variable and then passing it here

and then passing it here

and then passing it here we can actually save us that step

we can actually save us that step

we can actually save us that step and in the days to units function call

and in the days to units function call

and in the days to units function call pass it as a value so this is a

pass it as a value so this is a

pass it as a value so this is a perfectly

perfectly

perfectly valid syntax and you can do that you can

valid syntax and you can do that you can

valid syntax and you can do that you can nest in the function calls and you would

nest in the function calls and you would

nest in the function calls and you would not need this additional step

not need this additional step

not need this additional step and you can do that as many times as you

and you can do that as many times as you

and you can do that as many times as you want it just looks cleaner when you have

want it just looks cleaner when you have

want it just looks cleaner when you have that syntax a little bit separated and

that syntax a little bit separated and

that syntax a little bit separated and not have two three

not have two three

not have two three four function calls nested so that's one

four function calls nested so that's one

four function calls nested so that's one thing

thing

thing and another thing is we just saw a class

and another thing is we just saw a class

and another thing is we just saw a class boolean type here

boolean type here

boolean type here and let's actually see the same output

and let's actually see the same output

and let's actually see the same output for

for

for string and number so just for the

string and number so just for the

string and number so just for the demonstration let's actually

demonstration let's actually

demonstration let's actually see the type of string and integer

see the type of string and integer

see the type of string and integer let's get rid of this for a second

let's get rid of this for a second

let's get rid of this for a second because we just want to test

because we just want to test

because we just want to test so we're going to print the type of

so we're going to print the type of

so we're going to print the type of a string which says this should be a

a string which says this should be a

a string which says this should be a string

string

string type and execute

type and execute

type and execute and you see class string and

and you see class string and

and you see class string and now let's provide an integer

now let's provide an integer

now let's provide an integer you see class int and let's provide

you see class int and let's provide

you see class int and let's provide a float and there you go we have float

a float and there you go we have float

a float and there you go we have float so this is a very handy way of checking

so this is a very handy way of checking

so this is a very handy way of checking the type and we're going to need that

the type and we're going to need that

the type and we're going to need that actually in a later example

actually in a later example

actually in a later example so back to our

so back to our

so back to our application and one note about booleans

application and one note about booleans

application and one note about booleans and conditionals

and conditionals

and conditionals is that you're going to be using a lot

is that you're going to be using a lot

is that you're going to be using a lot of those

of those

of those in programming because they're really

in programming because they're really

in programming because they're really the major or the core part of writing

the major or the core part of writing

the major or the core part of writing any kind of logic in programming so

any kind of logic in programming so

any kind of logic in programming so you're going to need

you're going to need

you're going to need if else conditions and statements and

if else conditions and statements and

if else conditions and statements and booleans

booleans

booleans in your application so it is a very core

in your application so it is a very core

in your application so it is a very core concept and we're going to be using a

concept and we're going to be using a

concept and we're going to be using a lot of them

lot of them

lot of them in our coming examples so let's get rid

in our coming examples so let's get rid

in our coming examples so let's get rid of

of

of this code right here and one note before

this code right here and one note before

this code right here and one note before we move on

we move on

we move on here is that the negative numbers are

here is that the negative numbers are

here is that the negative numbers are not

not

not being calculated because of this

being calculated because of this

being calculated because of this condition

condition

condition now what about zero let's actually try

now what about zero let's actually try

now what about zero let's actually try that out

that out

that out so i'm gonna enter zero which is

so i'm gonna enter zero which is

so i'm gonna enter zero which is actually

actually

actually also valued that doesn't make sense

also valued that doesn't make sense

also valued that doesn't make sense because

because

because zero days input obviously will give zero

zero days input obviously will give zero

zero days input obviously will give zero of any units

of any units

of any units so enter and

so enter and

so enter and right here you see a feedback to user

right here you see a feedback to user

right here you see a feedback to user that says you entered a negative value

that says you entered a negative value

that says you entered a negative value so no conversion for you

so no conversion for you

so no conversion for you and the reason for that is because this

and the reason for that is because this

and the reason for that is because this condition here number of days checks

condition here number of days checks

condition here number of days checks greater than zero

greater than zero

greater than zero which means that negative numbers and

which means that negative numbers and

which means that negative numbers and zero

zero

zero will not match this condition so they

will not match this condition so they

will not match this condition so they will

will

will basically give you this feedback but our

basically give you this feedback but our

basically give you this feedback but our message says you entered a negative

message says you entered a negative

message says you entered a negative value

value

value right when we entered zero what if we

right when we entered zero what if we

right when we entered zero what if we wanted to

wanted to

wanted to have a specific message for a user if

have a specific message for a user if

have a specific message for a user if they enter

they enter

they enter zero and a specific one if they enter

zero and a specific one if they enter

zero and a specific one if they enter negative value

negative value

negative value right we want to differentiate between

right we want to differentiate between

right we want to differentiate between those two how can we do that

those two how can we do that

those two how can we do that in the if else statement in programming

in the if else statement in programming

in the if else statement in programming we can have multiple conditionals so

we can have multiple conditionals so

we can have multiple conditionals so basically we can have multiple ifs so

basically we can have multiple ifs so

basically we can have multiple ifs so how do we do that first we check number

how do we do that first we check number

how do we do that first we check number of days is greater than zero

of days is greater than zero

of days is greater than zero okay great now we want to check whether

okay great now we want to check whether

okay great now we want to check whether number of days

number of days

number of days is equal to zero and we can do that

is equal to zero and we can do that

is equal to zero and we can do that using another if here and in python

using another if here and in python

using another if here and in python the syntax for that is el if

the syntax for that is el if

the syntax for that is el if which basically is a combination of else

which basically is a combination of else

which basically is a combination of else and

and

and if so if this is not true

if so if this is not true

if so if this is not true then we want to check another condition

then we want to check another condition

then we want to check another condition number of days equals 0.

number of days equals 0.

number of days equals 0. now you know the equation sign generally

now you know the equation sign generally

now you know the equation sign generally is this one right here

is this one right here

is this one right here however when we're checking whether

however when we're checking whether

however when we're checking whether something

something

something equals to something else in programming

equals to something else in programming

equals to something else in programming that

that

that equation check is represented with two

equation check is represented with two

equation check is represented with two equal signs and the reason is because

equal signs and the reason is because

equal signs and the reason is because one equal sign is already

one equal sign is already

one equal sign is already used to represent assigning a value to a

used to represent assigning a value to a

used to represent assigning a value to a variable

variable

variable so not to confuse those two actions

so not to confuse those two actions

so not to confuse those two actions in programming we have two equation

in programming we have two equation

in programming we have two equation signs

signs

signs when we want to check whether something

when we want to check whether something

when we want to check whether something equals a certain value

equals a certain value

equals a certain value and just like here we

and just like here we

and just like here we execute some logic whenever this

execute some logic whenever this

execute some logic whenever this condition is

condition is

condition is true so in our case we want to

true so in our case we want to

true so in our case we want to tell the user you entered

tell the user you entered

tell the user you entered a zero please enter

a zero please enter

a zero please enter a valid positive number

a valid positive number

a valid positive number so now again to go through this logic

so now again to go through this logic

so now again to go through this logic flow if the input value is

flow if the input value is

flow if the input value is a positive number then function will

a positive number then function will

a positive number then function will return

return

return the calculation and the message if it's

the calculation and the message if it's

the calculation and the message if it's not a positive number then we will check

not a positive number then we will check

not a positive number then we will check additionally

additionally

additionally whether it's zero if it's not zero

whether it's zero if it's not zero

whether it's zero if it's not zero then this is a last condition basically

then this is a last condition basically

then this is a last condition basically then we know that it has to be a

then we know that it has to be a

then we know that it has to be a negative number right

negative number right

negative number right so let's test this out

so let's test this out

so let's test this out let's enter a positive number there you

let's enter a positive number there you

let's enter a positive number there you go

go

go let's enter zero you entered

let's enter zero you entered

let's enter zero you entered zero please enter a valley positive

zero please enter a valley positive

zero please enter a valley positive number and

number and

number and let's enter negative one and everything

let's enter negative one and everything

let's enter negative one and everything works

works

works perfectly note that you can have

perfectly note that you can have

perfectly note that you can have multiple alif's

multiple alif's

multiple alif's between if and else statements and again

between if and else statements and again

between if and else statements and again note that el

note that el

note that el if has a condition just like if

if has a condition just like if

if has a condition just like if statement

statement

statement else does not have any condition so this

else does not have any condition so this

else does not have any condition so this is like the fallback so if

is like the fallback so if

is like the fallback so if everything previously stated all the

everything previously stated all the

everything previously stated all the previous conditions did not

previous conditions did not

previous conditions did not match so they were all false basically

match so they were all false basically

match so they were all false basically then

then

then this is the logic that will get executed

this is the logic that will get executed

this is the logic that will get executed in that case

great so we have validated input value

great so we have validated input value for

for

for users and we may feel pretty good about

users and we may feel pretty good about

users and we may feel pretty good about our

our

our program because it doesn't calculate

program because it doesn't calculate

program because it doesn't calculate anything for values that don't make any

anything for values that don't make any

anything for values that don't make any sense

sense

sense however we still have a problem what

however we still have a problem what

however we still have a problem what happens if

happens if

happens if a user enters a text instead of a number

a user enters a text instead of a number

a user enters a text instead of a number so basically anything that is not

so basically anything that is not

so basically anything that is not a number value doesn't really matter

a number value doesn't really matter

a number value doesn't really matter basically some text if i enter

basically some text if i enter

basically some text if i enter you see that our program actually

you see that our program actually

you see that our program actually crashed and this is

crashed and this is

crashed and this is actually a user input that we want to

actually a user input that we want to

actually a user input that we want to protect our programs from

protect our programs from

protect our programs from because we don't want to allow users to

because we don't want to allow users to

because we don't want to allow users to blow up our application right so let's

blow up our application right so let's

blow up our application right so let's see what happened

see what happened

see what happened it actually says that we provided an

it actually says that we provided an

it actually says that we provided an invalid

invalid

invalid literal literal basically means the text

literal literal basically means the text

literal literal basically means the text itself or

itself or

itself or a number so basically a value that we

a number so basically a value that we

a number so basically a value that we entered

entered

entered for int function that's the problem

for int function that's the problem

for int function that's the problem so this function call basically just

so this function call basically just

so this function call basically just blew up

blew up

blew up because in function expects a value

because in function expects a value

because in function expects a value which is a string representation of a

which is a string representation of a

which is a string representation of a number

number

number so basically ind expects something like

so basically ind expects something like

so basically ind expects something like this or something like

this or something like

this or something like this it doesn't expect

this it doesn't expect

this it doesn't expect my text or some text so our application

my text or some text so our application

my text or some text so our application crashed on some text input now let's see

crashed on some text input now let's see

crashed on some text input now let's see what happens

what happens

what happens if i provide a number

if i provide a number

if i provide a number but a float number instead of integer

but a float number instead of integer

but a float number instead of integer let's enter 19.99

let's enter 19.99

let's enter 19.99 and enter and you see the same error

and enter and you see the same error

and enter and you see the same error this function basically returns an error

this function basically returns an error

this function basically returns an error because it cannot

because it cannot

because it cannot convert float into integer as well

convert float into integer as well

convert float into integer as well so we have a problem here that whenever

so we have a problem here that whenever

so we have a problem here that whenever user enters

user enters

user enters anything which is not an integer our

anything which is not an integer our

anything which is not an integer our program

program

program will blow up so how do we avoid

will blow up so how do we avoid

will blow up so how do we avoid that so basically before the int

that so basically before the int

that so basically before the int function gets executed with an

function gets executed with an

function gets executed with an invalid value we need to validate this

invalid value we need to validate this

invalid value we need to validate this whole thing and

whole thing and

whole thing and stop our program before that happens so

stop our program before that happens so

stop our program before that happens so we need the validation before int gets

we need the validation before int gets

we need the validation before int gets executed and we can do that right here

executed and we can do that right here

executed and we can do that right here right

right

right so before that line gets executed we're

so before that line gets executed we're

so before that line gets executed we're gonna do a validation

gonna do a validation

gonna do a validation and one way we can do that is using our

and one way we can do that is using our

and one way we can do that is using our familiar if else statement

familiar if else statement

familiar if else statement so we can say if user input

so we can say if user input

so we can say if user input is digit

so again from the syntax you know this

so again from the syntax you know this is calling a function

is calling a function

is calling a function but note that instead of calling the

but note that instead of calling the

but note that instead of calling the function

function

function like this so basically just stand alone

like this so basically just stand alone

like this so basically just stand alone we have the syntax where we have the

we have the syntax where we have the

we have the syntax where we have the variable

variable

variable dot and then the function name so

dot and then the function name so

dot and then the function name so instead of passing this

instead of passing this

instead of passing this as a parameter right here in the

as a parameter right here in the

as a parameter right here in the function

function

function brackets we are passing it as a

brackets we are passing it as a

brackets we are passing it as a parameter again

parameter again

parameter again but using this syntax right so each

but using this syntax right so each

but using this syntax right so each digit function will execute

digit function will execute

digit function will execute for user input as a parameter

for user input as a parameter

for user input as a parameter and again in if we have conditions so

and again in if we have conditions so

and again in if we have conditions so this will be either true or false

this will be either true or false

this will be either true or false it's a boolean and

it's a boolean and

it's a boolean and if user input is digit it's a number

if user input is digit it's a number

if user input is digit it's a number basically so basically this will filter

basically so basically this will filter

basically so basically this will filter out

out

out input values that are text so basically

input values that are text so basically

input values that are text so basically they're not

they're not

they're not numbers and if the input is digit

numbers and if the input is digit

numbers and if the input is digit then we want to execute this line

then we want to execute this line

then we want to execute this line and also the rest of our application

and also the rest of our application

and also the rest of our application like this and if it's not true

like this and if it's not true

like this and if it's not true so if the user input is not a digit we

so if the user input is not a digit we

so if the user input is not a digit we don't want to execute

don't want to execute

don't want to execute anything in our application we want to

anything in our application we want to

anything in our application we want to stop the execution and want to tell the

stop the execution and want to tell the

stop the execution and want to tell the user

user

user this was an invalid input value i'm not

this was an invalid input value i'm not

this was an invalid input value i'm not doing anything

doing anything

doing anything with my program so that it doesn't crash

with my program so that it doesn't crash

with my program so that it doesn't crash so

so

so else if not digit we

else if not digit we

else if not digit we are telling the user your input

are telling the user your input

are telling the user your input is not a number

is not a number

is not a number don't ruin my program

don't ruin my program

don't ruin my program so now let's actually test it

so now let's actually test it

so now let's actually test it so i'm going to execute and write some

so i'm going to execute and write some

so i'm going to execute and write some text

and there you go so user input is digit

and there you go so user input is digit was

was

was evaluated to false so

evaluated to false so

evaluated to false so none of these got executed instead the

none of these got executed instead the

none of these got executed instead the else

else

else block was executed and it printed a

block was executed and it printed a

block was executed and it printed a message

message

message for our user so we basically avoided our

for our user so we basically avoided our

for our user so we basically avoided our application to crash

application to crash

application to crash with this check and

with this check and

with this check and if we try a proper number

if we try a proper number

if we try a proper number it works and if we enter

it works and if we enter

it works and if we enter 0 for example the application

0 for example the application

0 for example the application will get executed and we will get

will get executed and we will get

will get executed and we will get our message from here

our message from here

our message from here so our application is more or less

so our application is more or less

so our application is more or less protected

protected

protected and we're not allowing for a invalid

and we're not allowing for a invalid

and we're not allowing for a invalid input number you say not a valid

input number you say not a valid

input number you say not a valid number now we know that in programming

number now we know that in programming

number now we know that in programming there are different types of numbers

there are different types of numbers

there are different types of numbers we have float numbers as well so

we have float numbers as well so

we have float numbers as well so let's actually see what ease digit

let's actually see what ease digit

let's actually see what ease digit function

function

function really checks so let's actually try

really checks so let's actually try

really checks so let's actually try to provide a float number instead of

to provide a float number instead of

to provide a float number instead of integer which is not a proper valid

integer which is not a proper valid

integer which is not a proper valid input for our program so i'm going to

input for our program so i'm going to

input for our program so i'm going to type in 19.99

type in 19.99

type in 19.99 and you see that each digit

and you see that each digit

and you see that each digit is false for a float number so we got

is false for a float number so we got

is false for a float number so we got the same

the same

the same your input is not a valid number output

your input is not a valid number output

your input is not a valid number output for float number as well which is

for float number as well which is

for float number as well which is perfect it's exactly what we need

perfect it's exactly what we need

perfect it's exactly what we need and now let's actually try

and now let's actually try

and now let's actually try to enter a negative number and let's see

to enter a negative number and let's see

to enter a negative number and let's see if each digit function

if each digit function

if each digit function returns true or false i'm going to enter

returns true or false i'm going to enter

returns true or false i'm going to enter and you see that else block got executed

and you see that else block got executed

and you see that else block got executed because

because

because is digit was false for a negative number

is digit was false for a negative number

is digit was false for a negative number so basically this function

so basically this function

so basically this function filters out a lot of the bad input

filters out a lot of the bad input

filters out a lot of the bad input for us to protect our application

for us to protect our application

for us to protect our application from bad user input and that also means

from bad user input and that also means

from bad user input and that also means that

that

that we don't need a check for negative

we don't need a check for negative

we don't need a check for negative values anymore and

values anymore and

values anymore and by the way in python you can actually

by the way in python you can actually

by the way in python you can actually have

have

have if statement without an else

if statement without an else

if statement without an else at the end this will work perfectly fine

however note that in programming we

however note that in programming we don't put this type of

don't put this type of

don't put this type of logic directly like this

logic directly like this

logic directly like this basically outside a function as a common

basically outside a function as a common

basically outside a function as a common and best practice we

and best practice we

and best practice we encapsulate most of the logic basically

encapsulate most of the logic basically

encapsulate most of the logic basically in functions

in functions

in functions so as a cleanup for our code

so as a cleanup for our code

so as a cleanup for our code we can take all this and put it into

we can take all this and put it into

we can take all this and put it into a function so right here i'm going to

a function so right here i'm going to

a function so right here i'm going to create

create

create a function and let's call it

a function and let's call it

a function and let's call it validate and execute

validate and execute

validate and execute or something like this

or something like this

or something like this and all the logic that i copied

and all the logic that i copied

and all the logic that i copied will be just simply pasted in that

will be just simply pasted in that

will be just simply pasted in that function like this

function like this

function like this so now we have the logic nicely

so now we have the logic nicely

so now we have the logic nicely encapsulated in its own function

encapsulated in its own function

encapsulated in its own function but as you know when we create a

but as you know when we create a

but as you know when we create a function we have to call that function

function we have to call that function

function we have to call that function otherwise nothing happens

otherwise nothing happens

otherwise nothing happens so we're gonna call it right here

so we're gonna call it right here

so we're gonna call it right here we don't have parameters and we don't

we don't have parameters and we don't

we don't have parameters and we don't have to provide a user

have to provide a user

have to provide a user input because user input is a global

input because user input is a global

input because user input is a global variable

variable

variable so our function has access to it let's

so our function has access to it let's

so our function has access to it let's actually test it out

and it works and let's provide some bad

and it works and let's provide some bad input

and it works too so that's actually a

and it works too so that's actually a proper way of writing code

proper way of writing code

proper way of writing code having every piece of logic in its own

having every piece of logic in its own

having every piece of logic in its own function

function

function with a proper description for the

with a proper description for the

with a proper description for the function

now as a next step i want to show you

now as a next step i want to show you also a concept or something that you

also a concept or something that you

also a concept or something that you will encounter

will encounter

will encounter very often in code which is nested

very often in code which is nested

very often in code which is nested if else statements and i'm going to show

if else statements and i'm going to show

if else statements and i'm going to show that example by

that example by

that example by cleaning up our program a little bit

cleaning up our program a little bit

cleaning up our program a little bit so as you see here we're doing

so as you see here we're doing

so as you see here we're doing validation in two different places

validation in two different places

validation in two different places so we're validating user input here but

so we're validating user input here but

so we're validating user input here but also

also

also inside these two units function itself

inside these two units function itself

inside these two units function itself so what we can do is we can put all the

so what we can do is we can put all the

so what we can do is we can put all the validation in one place

validation in one place

validation in one place in this validate and execute function

in this validate and execute function

in this validate and execute function and basically

and basically

and basically have all the validate logic in here

have all the validate logic in here

have all the validate logic in here and let the days to units function just

and let the days to units function just

and let the days to units function just do the

do the

do the calculation and not the validation and

calculation and not the validation and

calculation and not the validation and this way

this way

this way our functions and code will be a little

our functions and code will be a little

our functions and code will be a little bit

bit

bit cleaner and more logically built

cleaner and more logically built

cleaner and more logically built so after we validate that user input is

so after we validate that user input is

so after we validate that user input is digit we convert it into an integer

digit we convert it into an integer

digit we convert it into an integer so right here we have an integer value

so right here we have an integer value

so right here we have an integer value of the user input

of the user input

of the user input so we can actually check whether that

so we can actually check whether that

so we can actually check whether that integer value is

integer value is

integer value is greater than zero or equal to zero and

greater than zero or equal to zero and

greater than zero or equal to zero and we can do that

we can do that

we can do that right here without passing it on to the

right here without passing it on to the

right here without passing it on to the days to units

days to units

days to units function and just like this if

function and just like this if

function and just like this if conditional

conditional

conditional we're gonna do user input number

we're gonna do user input number

we're gonna do user input number greater than zero if that's the case

greater than zero if that's the case

greater than zero if that's the case we want the calculation to happen so

we want the calculation to happen so

we want the calculation to happen so both of these lines will get executed

both of these lines will get executed

both of these lines will get executed only if user input number is greater

only if user input number is greater

only if user input number is greater than zero

than zero

than zero and else in our case if it's

and else in our case if it's

and else in our case if it's exactly zero we want to print a message

exactly zero we want to print a message

exactly zero we want to print a message to user you entered zero and remember

to user you entered zero and remember

to user you entered zero and remember we've got the negative numbers already

we've got the negative numbers already

we've got the negative numbers already covered using

covered using

covered using this condition here so that's the one

this condition here so that's the one

this condition here so that's the one remaining

remaining

remaining i'm just going to copy that and paste it

i'm just going to copy that and paste it

i'm just going to copy that and paste it right here

right here

right here variable is called user input number so

variable is called user input number so

variable is called user input number so we'll fix that

we'll fix that

we'll fix that and we're going to print out that

and we're going to print out that

and we're going to print out that message

so that means we don't need any

so that means we don't need any validation

validation

validation right here we can

simply do the calculation

simply do the calculation so to go through this logical flow of if

so to go through this logical flow of if

so to go through this logical flow of if else or nested e-files

else or nested e-files

else or nested e-files statements we have the first if right

statements we have the first if right

statements we have the first if right here

here

here also note that indentations for

also note that indentations for

also note that indentations for these if else so basically they are on

these if else so basically they are on

these if else so basically they are on the same

the same

the same line here same position and

line here same position and

line here same position and the nested if else or in our case alif

the nested if else or in our case alif

the nested if else or in our case alif they're also in the same position so

they're also in the same position so

they're also in the same position so again first

again first

again first that's the big validation the first one

that's the big validation the first one

that's the big validation the first one is

is

is is the user input digit in the first

is the user input digit in the first

is the user input digit in the first place if not

place if not

place if not we basically shut down the program we

we basically shut down the program we

we basically shut down the program we print out a message to the user and

print out a message to the user and

print out a message to the user and that's it

that's it

that's it if it is a digit then we need additional

if it is a digit then we need additional

if it is a digit then we need additional validation is that digit a positive

validation is that digit a positive

validation is that digit a positive number

number

number or is it a zero so we do that additional

or is it a zero so we do that additional

or is it a zero so we do that additional validation using a nested ifall

validation using a nested ifall

validation using a nested ifall statement

statement

statement and basically this line gets executed

and basically this line gets executed

and basically this line gets executed only if it is a valid number and if it's

only if it is a valid number and if it's

only if it is a valid number and if it's a positive number and because of that

a positive number and because of that

a positive number and because of that we don't need any additional validation

we don't need any additional validation

we don't need any additional validation once the

once the

once the these two units function gets cold

these two units function gets cold

these two units function gets cold and you probably already think and

and you probably already think and

and you probably already think and notice that nested

notice that nested

notice that nested if else statements are not the most

if else statements are not the most

if else statements are not the most beautiful thing in the world they are

beautiful thing in the world they are

beautiful thing in the world they are pretty

pretty

pretty ugly actually and especially we have

ugly actually and especially we have

ugly actually and especially we have multiple of them or

multiple of them or

multiple of them or multiple else ifs in between

multiple else ifs in between

multiple else ifs in between the function may actually end up looking

the function may actually end up looking

the function may actually end up looking pretty bad

pretty bad

pretty bad so it's not recommended to have multiple

so it's not recommended to have multiple

so it's not recommended to have multiple levels of these

levels of these

levels of these nested if else statements in your code

nested if else statements in your code

nested if else statements in your code to basically just keep it clean but as i

to basically just keep it clean but as i

to basically just keep it clean but as i said

said

said you will encounter it a lot in programs

you will encounter it a lot in programs

you will encounter it a lot in programs in application code

in application code

in application code because sometimes you just have to write

because sometimes you just have to write

because sometimes you just have to write it like this

it like this

it like this thing i want to show you here is

thing i want to show you here is

thing i want to show you here is something called

something called

something called a try accept in python so right here as

a try accept in python so right here as

a try accept in python so right here as you see we're validating

you see we're validating

you see we're validating user input right and then we're

user input right and then we're

user input right and then we're executing this part of code

executing this part of code

executing this part of code only if that condition is true

only if that condition is true

only if that condition is true what if we had logic here where

what if we had logic here where

what if we had logic here where there were multiple places where

there were multiple places where

there were multiple places where something could go wrong let's say a

something could go wrong let's say a

something could go wrong let's say a function

function

function execution could basically just blow up

execution could basically just blow up

execution could basically just blow up because of

because of

because of a wrong input or even

a wrong input or even

a wrong input or even as an example maybe this is digit

as an example maybe this is digit

as an example maybe this is digit doesn't actually cover all the use cases

doesn't actually cover all the use cases

doesn't actually cover all the use cases so maybe there is a value that user can

so maybe there is a value that user can

so maybe there is a value that user can input that will still

input that will still

input that will still blow up our program so instead of

blow up our program so instead of

blow up our program so instead of checking each such possible scenario

checking each such possible scenario

checking each such possible scenario using if statements and then doing the

using if statements and then doing the

using if statements and then doing the actual calculation once

actual calculation once

actual calculation once all those things have been validated

all those things have been validated

all those things have been validated what we can do instead

what we can do instead

what we can do instead is basically tell python

is basically tell python

is basically tell python something like try

something like try

something like try executing this part of code here

executing this part of code here

executing this part of code here and if something goes wrong so if any

and if something goes wrong so if any

and if something goes wrong so if any line any function call or any logic

line any function call or any logic

line any function call or any logic execution

execution

execution fails we want to catch that error and we

fails we want to catch that error and we

fails we want to catch that error and we want to control what happens

want to control what happens

want to control what happens with that error ourselves

with that error ourselves

with that error ourselves programmatically

programmatically

programmatically and then catch logic will be

and then catch logic will be

and then catch logic will be accept and we're going to specify

accept and we're going to specify

accept and we're going to specify what type of value we want to catch

what type of value we want to catch

what type of value we want to catch basically using this block

basically using this block

basically using this block and the name of that error type is

and the name of that error type is

and the name of that error type is actually what we saw in the output when

actually what we saw in the output when

actually what we saw in the output when we provided

we provided

we provided some text and a float which

some text and a float which

some text and a float which is value error

is value error

is value error so that's the error that we want to

so that's the error that we want to

so that's the error that we want to catch basically so

catch basically so

catch basically so again we tell python you know what try

again we tell python you know what try

again we tell python you know what try to

to

to execute this block of code here

execute this block of code here

execute this block of code here and if one of those lines in that code

and if one of those lines in that code

and if one of those lines in that code results into a value error then instead

results into a value error then instead

results into a value error then instead of just

of just

of just crashing the program basically catch

crashing the program basically catch

crashing the program basically catch that error

that error

that error and print out a friendly message to a

and print out a friendly message to a

and print out a friendly message to a user

user

user so let's actually try this out

so let's actually try this out

so let's actually try this out and note that try doesn't have any

and note that try doesn't have any

and note that try doesn't have any validation

validation

validation like if statement so

like if statement so

like if statement so when i entered some text here

when i entered some text here

when i entered some text here int function will actually be called

int function will actually be called

int function will actually be called with some text

with some text

with some text and it will result in a value error and

and it will result in a value error and

and it will result in a value error and this block will then handle that error

this block will then handle that error

this block will then handle that error so i'm going to enter and and you see

so i'm going to enter and and you see

so i'm going to enter and and you see that

that

that your input is not a valid number message

your input is not a valid number message

your input is not a valid number message got printed and the same will work

got printed and the same will work

got printed and the same will work for a float number

for a float number

for a float number that also doesn't convert to integer and

that also doesn't convert to integer and

that also doesn't convert to integer and for a proper integer value

for a proper integer value

for a proper integer value it will work fine and

it will work fine and

it will work fine and again difference between if else

again difference between if else

again difference between if else statement and using try except

statement and using try except

statement and using try except is that you can cover multiple such

is that you can cover multiple such

is that you can cover multiple such errors

errors

errors with this whole try except block right

with this whole try except block right

with this whole try except block right so you don't have to do the validation

so you don't have to do the validation

so you don't have to do the validation specifically and that is especially

specifically and that is especially

specifically and that is especially useful for cases where you can't

useful for cases where you can't

useful for cases where you can't really validate something using if

really validate something using if

really validate something using if condition right if there is a chance

condition right if there is a chance

condition right if there is a chance that you might miss

that you might miss

that you might miss something in that condition check so

something in that condition check so

something in that condition check so basically you just say you know what

basically you just say you know what

basically you just say you know what just try to execute with whatever value

just try to execute with whatever value

just try to execute with whatever value and

and

and if error happens then i still got it

if error happens then i still got it

if error happens then i still got it covered

covered

covered and an obvious difference between this

and an obvious difference between this

and an obvious difference between this if else

if else

if else is that here nothing actually crashes

is that here nothing actually crashes

is that here nothing actually crashes the program the program will still work

the program the program will still work

the program the program will still work is just

is just

is just a nonsense value with zero days right

a nonsense value with zero days right

a nonsense value with zero days right and as you see here we have specified

and as you see here we have specified

and as you see here we have specified an error type but with try

an error type but with try

an error type but with try except what can also do is you can

except what can also do is you can

except what can also do is you can basically say you know what

basically say you know what

basically say you know what i want to cover any type of air i don't

i want to cover any type of air i don't

i want to cover any type of air i don't care if it's

care if it's

care if it's value air or some other type of air let

value air or some other type of air let

value air or some other type of air let me

me

me handle any type of air in this case you

handle any type of air in this case you

handle any type of air in this case you can basically just leave it without a

can basically just leave it without a

can basically just leave it without a specific type

specific type

specific type you get a warning though that it's too

you get a warning though that it's too

you get a warning though that it's too general

general

general however this would work and you will be

however this would work and you will be

however this would work and you will be covering all the air cases with it

covering all the air cases with it

covering all the air cases with it but we can go back to our value error

but we can go back to our value error

but we can go back to our value error and know that in many programming

and know that in many programming

and know that in many programming languages this is actually called a try

languages this is actually called a try

languages this is actually called a try catch so accept is actually pretty

catch so accept is actually pretty

catch so accept is actually pretty specific

specific

specific for python i personally think try catch

for python i personally think try catch

for python i personally think try catch makes more sense because you are

makes more sense because you are

makes more sense because you are catching

catching

catching any error that may happen right here and

any error that may happen right here and

any error that may happen right here and then basically

then basically

then basically handling it in the catch block so if you

handling it in the catch block so if you

handling it in the catch block so if you happen to hear or see

happen to hear or see

happen to hear or see try catch in other programming languages

try catch in other programming languages

try catch in other programming languages note that

note that

note that this is the same thing as try except in

this is the same thing as try except in

this is the same thing as try except in python

python

python one thing that we're missing because we

one thing that we're missing because we

one thing that we're missing because we converted that if statement

converted that if statement

converted that if statement into try except is now we need to

into try except is now we need to

into try except is now we need to validate the negative numbers again

validate the negative numbers again

validate the negative numbers again because negative numbers will not cause

because negative numbers will not cause

because negative numbers will not cause an error

an error

an error in our application so they're not

in our application so they're not

in our application so they're not covered by this

covered by this

covered by this except block here so let's add back

except block here so let's add back

except block here so let's add back our previous else block

our previous else block

our previous else block and again if neither of these

and again if neither of these

and again if neither of these are true it means automatically would

are true it means automatically would

are true it means automatically would mean that it is a negative number

mean that it is a negative number

mean that it is a negative number so let's

so let's

so let's print that message for a user enter

print that message for a user enter

print that message for a user enter negative number

so now we got all the cases covered

so now we got all the cases covered again

again

again so let's try that out -10

so let's try that out -10

so let's try that out -10 and there you go

now there is one minor problem with our

now there is one minor problem with our application

application

application and that is we can only use it once

and that is we can only use it once

and that is we can only use it once so basically whenever we type in a value

so basically whenever we type in a value

so basically whenever we type in a value it either calculates it or gives us

it either calculates it or gives us

it either calculates it or gives us a message that we provided an invalid

a message that we provided an invalid

a message that we provided an invalid value

value

value then the program basically exits so if

then the program basically exits so if

then the program basically exits so if we want to do a calculation

we want to do a calculation

we want to do a calculation for another value then we have to

for another value then we have to

for another value then we have to restart the application

restart the application

restart the application provided value and then do the same

provided value and then do the same

provided value and then do the same so that's not very convenient if we want

so that's not very convenient if we want

so that's not very convenient if we want to use that program to

to use that program to

to use that program to basically calculate a number of hours

basically calculate a number of hours

basically calculate a number of hours for many different values so basically

for many different values so basically

for many different values so basically we want to

we want to

we want to keep fitting it some different values

keep fitting it some different values

keep fitting it some different values for calculation

for calculation

for calculation because we don't want to restart the

because we don't want to restart the

because we don't want to restart the application over and over again

application over and over again

application over and over again so how can we actually make the program

so how can we actually make the program

so how can we actually make the program continue after it's calculated the first

continue after it's calculated the first

continue after it's calculated the first value

value

value so we want the program to basically just

so we want the program to basically just

so we want the program to basically just keep running and

keep running and

keep running and accepting our values so how do we do

accepting our values so how do we do

accepting our values so how do we do that

that

that and we can implement the logic using

and we can implement the logic using

and we can implement the logic using something called

something called

something called while loop concept of loops in

while loop concept of loops in

while loop concept of loops in programming

programming

programming is basically you do the same thing

is basically you do the same thing

is basically you do the same thing so the same logic gets executed

so the same logic gets executed

so the same logic gets executed multiple times in a loop and how many

multiple times in a loop and how many

multiple times in a loop and how many times

times

times that logic gets executed is basically

that logic gets executed is basically

that logic gets executed is basically defined

defined

defined in the condition of that loop and the

in the condition of that loop and the

in the condition of that loop and the condition could be

condition could be

condition could be it should run 10 times or condition

it should run 10 times or condition

it should run 10 times or condition could also be

could also be

could also be it should run until some specific

it should run until some specific

it should run until some specific event happens in the application and

event happens in the application and

event happens in the application and conditions you already know from if else

conditions you already know from if else

conditions you already know from if else statement

statement

statement conditions are basically logic that

conditions are basically logic that

conditions are basically logic that gives you either true

gives you either true

gives you either true or false so condition is checking some

or false so condition is checking some

or false so condition is checking some logic and then

logic and then

logic and then giving you a result which is either true

giving you a result which is either true

giving you a result which is either true or false

or false

or false so now the question is how many times do

so now the question is how many times do

so now the question is how many times do we want this application to run

we want this application to run

we want this application to run in our case let's say we want to run

in our case let's say we want to run

in our case let's say we want to run indefinitely

indefinitely

indefinitely right until we actually stop it from

right until we actually stop it from

right until we actually stop it from here until we kill the program

here until we kill the program

here until we kill the program so it means the condition for that

so it means the condition for that

so it means the condition for that should

should

should always be true and for our application

always be true and for our application

always be true and for our application we're going to use a while loop which is

we're going to use a while loop which is

we're going to use a while loop which is one

one

one type of a loop and very simple syntax

type of a loop and very simple syntax

type of a loop and very simple syntax while and while just like if actually

while and while just like if actually

while and while just like if actually takes

takes

takes a condition this is going to be the

a condition this is going to be the

a condition this is going to be the condition for the loop

condition for the loop

condition for the loop so basically we want to tell the while

so basically we want to tell the while

so basically we want to tell the while loop how many times

loop how many times

loop how many times it should run the logic coming after it

it should run the logic coming after it

it should run the logic coming after it and again you know our familiar

and again you know our familiar

and again you know our familiar indentation

indentation

indentation these two lines should execute in a loop

these two lines should execute in a loop

these two lines should execute in a loop over and over again with some condition

over and over again with some condition

over and over again with some condition right here so how many times do we want

right here so how many times do we want

right here so how many times do we want the program to execute

the program to execute

the program to execute in our specific case well we want the

in our specific case well we want the

in our specific case well we want the program to

program to

program to run indefinitely until we actually stop

run indefinitely until we actually stop

run indefinitely until we actually stop it from here

it from here

it from here right from our editor so

right from our editor so

right from our editor so that means that condition of the loop

that means that condition of the loop

that means that condition of the loop that decides whether the next lines

that decides whether the next lines

that decides whether the next lines should get executed or not in our case

should get executed or not in our case

should get executed or not in our case should always be

should always be

should always be true because if it's false then

true because if it's false then

true because if it's false then the loop will stop right no execution

the loop will stop right no execution

the loop will stop right no execution anymore

anymore

anymore so how can we make sure it's always true

so how can we make sure it's always true

so how can we make sure it's always true we just write

we just write

we just write true right here and you remember i told

true right here and you remember i told

true right here and you remember i told you that true and false in

you that true and false in

you that true and false in programming languages have their own

programming languages have their own

programming languages have their own data types well they are also reserved

data types well they are also reserved

data types well they are also reserved words

words

words even though this is just text

even though this is just text

even though this is just text representation basically you see the

representation basically you see the

representation basically you see the highlighting here

highlighting here

highlighting here just like for these other words because

just like for these other words because

just like for these other words because python knows

python knows

python knows this is a boolean value of

this is a boolean value of

this is a boolean value of true and note that again specifically

true and note that again specifically

true and note that again specifically for python we actually

for python we actually

for python we actually write true with capital t

write true with capital t

write true with capital t unlike in other programming languages so

unlike in other programming languages so

unlike in other programming languages so this

this

this will basically be just a string

will basically be just a string

will basically be just a string so python doesn't know what to do with

so python doesn't know what to do with

so python doesn't know what to do with it but it recognizes

it but it recognizes

it but it recognizes true width capital t so we're telling

true width capital t so we're telling

true width capital t so we're telling our loop

our loop

our loop our while loop the condition is always

our while loop the condition is always

our while loop the condition is always true

true

true so basically run these two lines

so basically run these two lines

so basically run these two lines indefinitely because the condition

indefinitely because the condition

indefinitely because the condition will never change it's always going to

will never change it's always going to

will never change it's always going to be true and

be true and

be true and the syntax is probably already familiar

the syntax is probably already familiar

the syntax is probably already familiar to you

to you

to you we have the keyword just like if

we have the keyword just like if

we have the keyword just like if or try we can actually compare the

or try we can actually compare the

or try we can actually compare the syntax to the if statement

syntax to the if statement

syntax to the if statement so we have the while keyword here

so we have the while keyword here

so we have the while keyword here then we have the condition so this is

then we have the condition so this is

then we have the condition so this is the same type of condition

the same type of condition

the same type of condition as this one right here it's just that

as this one right here it's just that

as this one right here it's just that with us

with us

with us is basically fixed true value

is basically fixed true value

is basically fixed true value here it could be true or it could be

here it could be true or it could be

here it could be true or it could be false based on the condition

false based on the condition

false based on the condition and then we have the colon and then we

and then we have the colon and then we

and then we have the colon and then we have the indentation

have the indentation

have the indentation for the next lines so all of these

for the next lines so all of these

for the next lines so all of these belong to

belong to

belong to the while loop so that's basically it

the while loop so that's basically it

the while loop so that's basically it we can now execute the application and

we can now execute the application and

we can now execute the application and see that our program runs indefinitely

see that our program runs indefinitely

see that our program runs indefinitely so this is the first one

so this is the first one

so this is the first one let's say we enter 10 awesome we have a

let's say we enter 10 awesome we have a

let's say we enter 10 awesome we have a result

result

result and then we have again the next

and then we have again the next

and then we have again the next execution where it's asking for our

execution where it's asking for our

execution where it's asking for our input again

input again

input again and we can do -10 now it's telling us we

and we can do -10 now it's telling us we

and we can do -10 now it's telling us we provide a negative value

provide a negative value

provide a negative value but we can enter the value again let's

but we can enter the value again let's

but we can enter the value again let's enter some

enter some

enter some invalid value that should be

invalid value that should be

invalid value that should be handled by this value error block

handled by this value error block

handled by this value error block execute

execute

execute it's not a valid number and application

it's not a valid number and application

it's not a valid number and application basically continues so again as you see

basically continues so again as you see

basically continues so again as you see if you

if you

if you have an application that should continue

have an application that should continue

have an application that should continue running and basically get user input

running and basically get user input

running and basically get user input over and over again

over and over again

over and over again you don't want that application to be

you don't want that application to be

you don't want that application to be crashed at some point by some

crashed at some point by some

crashed at some point by some bad input you want to catch and handle

bad input you want to catch and handle

bad input you want to catch and handle every type of input so that your

every type of input so that your

every type of input so that your application

application

application continues to run and if we want to stop

continues to run and if we want to stop

continues to run and if we want to stop it

it

it we can basically just shut it off here

we can basically just shut it off here

we can basically just shut it off here and process finished

now we can do one optimization in our

now we can do one optimization in our program

program

program and this would be to allow users

and this would be to allow users

and this would be to allow users themselves

themselves

themselves to stop the application using

to stop the application using

to stop the application using some specific input value so for example

some specific input value so for example

some specific input value so for example when they type in exit for example the

when they type in exit for example the

when they type in exit for example the application

application

application should stop only for that specific

should stop only for that specific

should stop only for that specific word so it shouldn't run anymore so how

word so it shouldn't run anymore so how

word so it shouldn't run anymore so how can we do that

can we do that

can we do that so basically instead of having a

so basically instead of having a

so basically instead of having a condition that is

condition that is

condition that is always true we want a condition that

always true we want a condition that

always true we want a condition that says

says

says if the user did not input

if the user did not input

if the user did not input word exit then continue running the

word exit then continue running the

word exit then continue running the program

program

program if user entered exit then basically just

if user entered exit then basically just

if user entered exit then basically just stop it right so we need to change our

stop it right so we need to change our

stop it right so we need to change our condition right here

condition right here

condition right here so here we want user input is not

so here we want user input is not

so here we want user input is not exit right so user input

exit right so user input

exit right so user input is not exit now we didn't learn

is not exit now we didn't learn

is not exit now we didn't learn how to check for not equals

how to check for not equals

how to check for not equals something right we have check for

something right we have check for

something right we have check for equality so we check whether

equality so we check whether

equality so we check whether input number equals zero or if it's

input number equals zero or if it's

input number equals zero or if it's greater than

greater than

greater than or smaller than however we didn't learn

or smaller than however we didn't learn

or smaller than however we didn't learn how to check for

how to check for

how to check for not equals not equals in programming and

not equals not equals in programming and

not equals not equals in programming and this is not specific for

this is not specific for

this is not specific for python is expressed like this

python is expressed like this

python is expressed like this so instead of two equation

so instead of two equation

so instead of two equation signs we have an exclamation mark and

signs we have an exclamation mark and

signs we have an exclamation mark and equals

equals

equals and if we want to compare it to a string

and if we want to compare it to a string

and if we want to compare it to a string obviously

obviously

obviously we type that string in our case it's

we type that string in our case it's

we type that string in our case it's exit so basically this condition

exit so basically this condition

exit so basically this condition tells our while loop while

tells our while loop while

tells our while loop while user input is not exit

user input is not exit

user input is not exit continue running the program so while

continue running the program so while

continue running the program so while this is true

this is true

this is true basically just keep moving on but if

basically just keep moving on but if

basically just keep moving on but if user enters

user enters

user enters exit this will not be true anymore it

exit this will not be true anymore it

exit this will not be true anymore it will be false

will be false

will be false so loop will basically break and

so loop will basically break and

so loop will basically break and application will

application will

application will end now you see that we have a warning

end now you see that we have a warning

end now you see that we have a warning on this user input

on this user input

on this user input that we're using here and if i hover

that we're using here and if i hover

that we're using here and if i hover over it you see a message that says

over it you see a message that says

over it you see a message that says name user input can be undefined

name user input can be undefined

name user input can be undefined so it's not always undefined but it can

so it's not always undefined but it can

so it's not always undefined but it can be and here i want to mention again

be and here i want to mention again

be and here i want to mention again that pycharm because it's an intelligent

that pycharm because it's an intelligent

that pycharm because it's an intelligent editor

editor

editor can give you actually this warning when

can give you actually this warning when

can give you actually this warning when otherwise

otherwise

otherwise in a simple or normal code editor

in a simple or normal code editor

in a simple or normal code editor you probably wouldn't get such a warning

you probably wouldn't get such a warning

you probably wouldn't get such a warning so again it helps you

so again it helps you

so again it helps you in avoiding some of the mistakes that

in avoiding some of the mistakes that

in avoiding some of the mistakes that you might accidentally

you might accidentally

you might accidentally make when writing code so basically it

make when writing code so basically it

make when writing code so basically it detects the errors or possible errors

detects the errors or possible errors

detects the errors or possible errors for you

for you

for you and tells you to fix it so again

and tells you to fix it so again

and tells you to fix it so again this kind of intelligent warnings and

this kind of intelligent warnings and

this kind of intelligent warnings and error messages

error messages

error messages can be a lot of help when programming an

can be a lot of help when programming an

can be a lot of help when programming an application

application

application and now let's fix that warning so what's

and now let's fix that warning so what's

and now let's fix that warning so what's that all about

that all about

that all about the problem is on the very very first

the problem is on the very very first

the problem is on the very very first run of

run of

run of this while loop user input

this while loop user input

this while loop user input variable itself will not exist

variable itself will not exist

variable itself will not exist why because we're creating that user

why because we're creating that user

why because we're creating that user input variable

input variable

input variable on this line first so our

on this line first so our

on this line first so our application will basically complain

application will basically complain

application will basically complain because

because

because when our while loop runs for the first

when our while loop runs for the first

when our while loop runs for the first time it will not be able to find

time it will not be able to find

time it will not be able to find user input variable let's actually try

user input variable let's actually try

user input variable let's actually try that

that

that and as you see user input is not defined

and as you see user input is not defined

and as you see user input is not defined so we need to create that user input

so we need to create that user input

so we need to create that user input variable before

variable before

variable before the first execution of the loop

the first execution of the loop

the first execution of the loop so right here

we're going to create user input so

we're going to create user input so we're going to create this user input

we're going to create this user input

we're going to create this user input variable

variable

variable before the while loops first run

before the while loops first run

before the while loops first run and it doesn't really matter what the

and it doesn't really matter what the

and it doesn't really matter what the value of that user input variable will

value of that user input variable will

value of that user input variable will be because

be because

be because what matters is the variable exists so

what matters is the variable exists so

what matters is the variable exists so the value is basically just empty

the value is basically just empty

the value is basically just empty and as long as it's not exit the

and as long as it's not exit the

and as long as it's not exit the loop will start running and our

loop will start running and our

loop will start running and our application will get executed

application will get executed

application will get executed so again to go through the flow of this

so again to go through the flow of this

so again to go through the flow of this we're creating a

we're creating a

we're creating a user input variable then we're making

user input variable then we're making

user input variable then we're making sure it's not

sure it's not

sure it's not exit if it's not this line will get

exit if it's not this line will get

exit if it's not this line will get executed so we get the

executed so we get the

executed so we get the input from the user that's going to be

input from the user that's going to be

input from the user that's going to be our first input

our first input

our first input and then we call validate and execute

and then we call validate and execute

and then we call validate and execute function

function

function that basically does all the checks and

that basically does all the checks and

that basically does all the checks and execution

execution

execution so that's going to be the first run of

so that's going to be the first run of

so that's going to be the first run of that loop

that loop

that loop on the second run of the loop the

on the second run of the loop the

on the second run of the loop the condition will get

condition will get

condition will get re-evaluated so now the user input is

re-evaluated so now the user input is

re-evaluated so now the user input is what the user provided so again python

what the user provided so again python

what the user provided so again python will check is the user input

will check is the user input

will check is the user input exit no cool let's execute the program

exit no cool let's execute the program

exit no cool let's execute the program again user will have to enter another

again user will have to enter another

again user will have to enter another value

value

value and then that value will get

and then that value will get

and then that value will get re-evaluated

re-evaluated

re-evaluated so note that after each time

so note that after each time

so note that after each time that this block of code has run and

that this block of code has run and

that this block of code has run and executed

executed

executed every single value that user will give

every single value that user will give

every single value that user will give as an input

as an input

as an input will be evaluated over and over again

will be evaluated over and over again

will be evaluated over and over again in that condition and while user input

in that condition and while user input

in that condition and while user input is something else then exit it will run

is something else then exit it will run

is something else then exit it will run the program

the program

the program if it is exit then the loop will break

if it is exit then the loop will break

if it is exit then the loop will break so let's actually test that

so this is our first message and our

so this is our first message and our first input

first input

first input let's do 10 it got calculated

let's do 10 it got calculated

let's do 10 it got calculated let's do minus

again calculate it and we can do that

again calculate it and we can do that over and over and over again

over and over and over again

over and over and over again and now let's actually enter exit and

and now let's actually enter exit and

and now let's actually enter exit and let's see what happens

let's see what happens

let's see what happens and as you see a process finished with

and as you see a process finished with

and as you see a process finished with exit code so our application actually

exit code so our application actually

exit code so our application actually stopped because this condition was not

stopped because this condition was not

stopped because this condition was not true anymore it was

true anymore it was

true anymore it was false because we entered exit

false because we entered exit

false because we entered exit so that's how we can allow users to

so that's how we can allow users to

so that's how we can allow users to finish the application and two takeaways

finish the application and two takeaways

finish the application and two takeaways here

here

here one is a conditional in a loop

one is a conditional in a loop

one is a conditional in a loop and the second one is a negative equals

and the second one is a negative equals

and the second one is a negative equals check

check

check for values

for values

for values great so now we have our application

great so now we have our application

great so now we have our application that basically

that basically

that basically allows inputs multiple times

allows inputs multiple times

allows inputs multiple times and can be terminated with exit

and can be terminated with exit

and can be terminated with exit input now what if i wanted to calculate

input now what if i wanted to calculate

input now what if i wanted to calculate number of hours for several days but i

number of hours for several days but i

number of hours for several days but i didn't want to

didn't want to

didn't want to basically just pass it on one after

basically just pass it on one after

basically just pass it on one after another because that's just

another because that's just

another because that's just too much effort for me so let's say i

too much effort for me so let's say i

too much effort for me so let's say i wanted to give it

wanted to give it

wanted to give it 10 different values but i don't want to

10 different values but i don't want to

10 different values but i don't want to type it in

type it in

type it in 10 times right i want that application

10 times right i want that application

10 times right i want that application to basically do the

to basically do the

to basically do the whole calculation for all those 10

whole calculation for all those 10

whole calculation for all those 10 values but

values but

values but i just want to enter that list once

i just want to enter that list once

i just want to enter that list once instead of

instead of

instead of entering each value separately

entering each value separately

entering each value separately so in this part we're going to learn

so in this part we're going to learn

so in this part we're going to learn another data type

another data type

another data type in python called list

in python called list

in python called list so till now we have learned several data

so till now we have learned several data

so till now we have learned several data types

types

types like strings for example

as well as integers and

as well as integers and float numbers and

float numbers and

float numbers and boolean true or false

boolean true or false

boolean true or false and list is just another data type

and list is just another data type

and list is just another data type and the syntax for list is

and the syntax for list is

and the syntax for list is using square brackets and

using square brackets and

using square brackets and inside the square brackets we have a

inside the square brackets we have a

inside the square brackets we have a list of

list of

list of elements and those elements can again be

elements and those elements can again be

elements and those elements can again be either strings numbers or boolean values

either strings numbers or boolean values

either strings numbers or boolean values in our case we want to provide our

in our case we want to provide our

in our case we want to provide our application with a list of

application with a list of

application with a list of number of days right so we're going to

number of days right so we're going to

number of days right so we're going to have

have

have a list of integers

a list of integers

a list of integers like this

and you can have as many values inside

and you can have as many values inside the list as you want

the list as you want

the list as you want and these are going to be comma

and these are going to be comma

and these are going to be comma separated and the syntax will look

separated and the syntax will look

separated and the syntax will look like this but again as i said you can

like this but again as i said you can

like this but again as i said you can have a list of strings

have a list of strings

have a list of strings list of booleans etc so as i mentioned

list of booleans etc so as i mentioned

list of booleans etc so as i mentioned we want to let user basically

we want to let user basically

we want to let user basically provide inputs as a list

provide inputs as a list

provide inputs as a list instead of those individual values one

instead of those individual values one

instead of those individual values one at a time

at a time

at a time so i'm going to copy this let's clean

so i'm going to copy this let's clean

so i'm going to copy this let's clean this up

this up

this up and let's actually see what happens if i

and let's actually see what happens if i

and let's actually see what happens if i just

just

just input that list as a value

input that list as a value

input that list as a value right here and enter you see program

right here and enter you see program

right here and enter you see program doesn't recognize that

doesn't recognize that

doesn't recognize that as a valid number obviously because we

as a valid number obviously because we

as a valid number obviously because we have the check

have the check

have the check and causes a value error that's why we

and causes a value error that's why we

and causes a value error that's why we get

get

get your input is not a valid number don't

your input is not a valid number don't

your input is not a valid number don't ruin my program

ruin my program

ruin my program message right here so we want to change

message right here so we want to change

message right here so we want to change that and

that and

that and make our program actually accept that as

make our program actually accept that as

make our program actually accept that as a valid

a valid

a valid input so how do we actually implement it

input so how do we actually implement it

input so how do we actually implement it and let's go through this logic

and let's go through this logic

and let's go through this logic theoretically first

theoretically first

theoretically first before we start implementing it what we

before we start implementing it what we

before we start implementing it what we need here is that

need here is that

need here is that we want to read this list and we want to

we want to read this list and we want to

we want to read this list and we want to do

do

do validation and execution for each

validation and execution for each

validation and execution for each value one at a time so that means that

value one at a time so that means that

value one at a time so that means that validate and execute function needs to

validate and execute function needs to

validate and execute function needs to be called

be called

be called for each value in that list right

for each value in that list right

for each value in that list right so basically this function for all this

so basically this function for all this

so basically this function for all this logic

logic

logic needs to be executed for each element

needs to be executed for each element

needs to be executed for each element now how do we get the individual

now how do we get the individual

now how do we get the individual elements

elements

elements of the list so you remember the

of the list so you remember the

of the list so you remember the definition

definition

definition of a loop loop is basically executing

of a loop loop is basically executing

of a loop loop is basically executing same function with the same logic

same function with the same logic

same function with the same logic multiple times

multiple times

multiple times and the number of times basically

and the number of times basically

and the number of times basically depends on the condition right

depends on the condition right

depends on the condition right here we have a condition for while loop

here we have a condition for while loop

here we have a condition for while loop and the condition

and the condition

and the condition for executing the same logic for each of

for executing the same logic for each of

for executing the same logic for each of those

those

those elements is going to be the number of

elements is going to be the number of

elements is going to be the number of elements in that list right so we want

elements in that list right so we want

elements in that list right so we want to execute the logic

to execute the logic

to execute the logic as many times as we have elements in the

as many times as we have elements in the

as many times as we have elements in the list

list

list and for that we have another type of

and for that we have another type of

and for that we have another type of loop

loop

loop called for loop and basically we want to

called for loop and basically we want to

called for loop and basically we want to execute validate and execute function

execute validate and execute function

execute validate and execute function using a for loop the syntax for

using a for loop the syntax for

using a for loop the syntax for for loop is a little bit different first

for loop is a little bit different first

for loop is a little bit different first of all we have four

of all we have four

of all we have four keyword just like for while then we have

keyword just like for while then we have

keyword just like for while then we have the

the

the element is a variable so we can call

element is a variable so we can call

element is a variable so we can call that

that

that number of days

so this variable basically represents

so this variable basically represents each

each

each of those elements in the list

of those elements in the list

of those elements in the list and then we have in which is again a

and then we have in which is again a

and then we have in which is again a keyword of python

keyword of python

keyword of python so for in basically puts together the

so for in basically puts together the

so for in basically puts together the for loop

for loop

for loop logic in python so python knows what we

logic in python so python knows what we

logic in python so python knows what we are trying to execute

are trying to execute

are trying to execute and finally we need the list

and finally we need the list

and finally we need the list that we are executing this loop on

that we are executing this loop on

that we are executing this loop on and our list is our user input

and our list is our user input

and our list is our user input and that's our for loop however

and that's our for loop however

and that's our for loop however again you remember the indentation the

again you remember the indentation the

again you remember the indentation the logic

logic

logic that for loop executes needs to be

that for loop executes needs to be

that for loop executes needs to be indented so it should belong to for loop

indented so it should belong to for loop

indented so it should belong to for loop so now we can read that for loop

so now we can read that for loop

so now we can read that for loop statement as follows

statement as follows

statement as follows for each element which we call we decide

for each element which we call we decide

for each element which we call we decide to call number of days

to call number of days

to call number of days in a list called user input

in a list called user input

in a list called user input we want to execute this logic

we want to execute this logic

we want to execute this logic exactly what i said before so for each

exactly what i said before so for each

exactly what i said before so for each element

element

element in this user input list we want to

in this user input list we want to

in this user input list we want to execute

validate and execute function we don't

validate and execute function we don't have a condition

have a condition

have a condition written here like we did in while loop

written here like we did in while loop

written here like we did in while loop or

or

or if statement so the condition is

if statement so the condition is

if statement so the condition is basically implicit

basically implicit

basically implicit right the condition says however many

right the condition says however many

right the condition says however many elements there

elements there

elements there are in this list that many times that

are in this list that many times that

are in this list that many times that function or that block of code here will

function or that block of code here will

function or that block of code here will get executed

get executed

get executed so if i provide five elements you will

so if i provide five elements you will

so if i provide five elements you will be executed five times

be executed five times

be executed five times if i provide 10 elements it will be

if i provide 10 elements it will be

if i provide 10 elements it will be executed 10 times

executed 10 times

executed 10 times and that's exactly what we want however

and that's exactly what we want however

and that's exactly what we want however there are still

there are still

there are still a couple of things we need to do for

a couple of things we need to do for

a couple of things we need to do for this application to work

this application to work

this application to work properly first of all validate and

properly first of all validate and

properly first of all validate and execute

execute

execute function still uses user input

function still uses user input

function still uses user input right here so instead we want it to

right here so instead we want it to

right here so instead we want it to use the individual values of the user

use the individual values of the user

use the individual values of the user input because now it's going to be a

input because now it's going to be a

input because now it's going to be a list

list

list and not a number so this

and not a number so this

and not a number so this element we can actually call it num of

element we can actually call it num of

element we can actually call it num of days

days

days element this value should be used here

element this value should be used here

element this value should be used here instead

instead

instead right so we're going to use that element

right so we're going to use that element

right so we're going to use that element instead of the whole user input list

instead of the whole user input list

instead of the whole user input list and paste it here so that fixes the

and paste it here so that fixes the

and paste it here so that fixes the first problem

first problem

first problem and the second one is as you know user

and the second one is as you know user

and the second one is as you know user input is

input is

input is always a string so even if we provide

always a string so even if we provide

always a string so even if we provide a list of these it is still going to be

a list of these it is still going to be

a list of these it is still going to be considered

considered

considered as a string so we need something similar

as a string so we need something similar

as a string so we need something similar to

to

to this right here so the list of numbers

this right here so the list of numbers

this right here so the list of numbers that are provided as input needs to be

that are provided as input needs to be

that are provided as input needs to be converted

converted

converted in at least in python and we can

in at least in python and we can

in at least in python and we can actually do that

actually do that

actually do that in a convenient way using user input

in a convenient way using user input

in a convenient way using user input dot split and split is a function

dot split and split is a function

dot split and split is a function that will take user input as a parameter

that will take user input as a parameter

that will take user input as a parameter and will give us a list data type

and will give us a list data type

and will give us a list data type so split function basically will return

so split function basically will return

so split function basically will return a list

a list

a list of all those input values

of all those input values

of all those input values and again note the syntax of executing

and again note the syntax of executing

and again note the syntax of executing the split function

the split function

the split function we're not just calling a split function

we're not just calling a split function

we're not just calling a split function like this

like this

like this with user input as parameter instead we

with user input as parameter instead we

with user input as parameter instead we are basically

are basically

are basically calling it on user input and i'm going

calling it on user input and i'm going

calling it on user input and i'm going to explain

to explain

to explain more about this type of functions in

more about this type of functions in

more about this type of functions in python

python

python later but for now let's actually execute

later but for now let's actually execute

later but for now let's actually execute this application

this application

this application and see what happens so first of all

and see what happens so first of all

and see what happens so first of all how am i going to provide a list

how am i going to provide a list

how am i going to provide a list to this application so that

to this application so that

to this application so that userinput.split

userinput.split

userinput.split can actually convert it into a proper

can actually convert it into a proper

can actually convert it into a proper list in python and the way i should

list in python and the way i should

list in python and the way i should provide the values are

provide the values are

provide the values are list of values with spaces between them

list of values with spaces between them

list of values with spaces between them so basically like that so why spaces how

so basically like that so why spaces how

so basically like that so why spaces how come it's not

come it's not

come it's not a comma or something else the reason

a comma or something else the reason

a comma or something else the reason is because split function by default

is because split function by default

is because split function by default splits that provided list on

splits that provided list on

splits that provided list on spaces and then creates a list value

spaces and then creates a list value

spaces and then creates a list value out of them so that's the default

out of them so that's the default

out of them so that's the default behavior of split

behavior of split

behavior of split however we can override that behavior

however we can override that behavior

however we can override that behavior and we can decide you know what

and we can decide you know what

and we can decide you know what we want the input to be a list of

we want the input to be a list of

we want the input to be a list of numbers that are comma separated instead

numbers that are comma separated instead

numbers that are comma separated instead of

of

of space separated so what we can do is

space separated so what we can do is

space separated so what we can do is right here we can do split on a comma

right here we can do split on a comma

right here we can do split on a comma so that's what our split function here

so that's what our split function here

so that's what our split function here will do and now if i re-execute it

will do and now if i re-execute it

will do and now if i re-execute it and i can do commas now

40 55.

40 55. so that's going to be user input and

so that's going to be user input and

so that's going to be user input and split

split

split with comma should convert it into

with comma should convert it into

with comma should convert it into a list value in python so let's execute

a list value in python so let's execute

a list value in python so let's execute it

it

it and as you see it worked fine we have

and as you see it worked fine we have

and as you see it worked fine we have a calculation for each of those values

a calculation for each of those values

a calculation for each of those values now let's actually play around with this

now let's actually play around with this

now let's actually play around with this and let's say we provide

and let's say we provide

and let's say we provide a list with some values

a list with some values

a list with some values and somewhere in between we decide to

and somewhere in between we decide to

and somewhere in between we decide to add a text

add a text

add a text and then maybe a float so let's see what

and then maybe a float so let's see what

and then maybe a float so let's see what happens now

happens now

happens now and you see that for those two valid

and you see that for those two valid

and you see that for those two valid numbers the calculation was done

numbers the calculation was done

numbers the calculation was done properly and for the other two basically

properly and for the other two basically

properly and for the other two basically the validation kicked in and it says

the validation kicked in and it says

the validation kicked in and it says that these are invalid numbers

that these are invalid numbers

that these are invalid numbers however again our application ran

however again our application ran

however again our application ran without any problems

without any problems

without any problems and we can even provide another input so

and we can even provide another input so

and we can even provide another input so now let's actually

now let's actually

now let's actually do 20 maybe a boolean even

do 20 maybe a boolean even

do 20 maybe a boolean even and a negative number execute

and a negative number execute

and a negative number execute and you see that for 20 the number of

and you see that for 20 the number of

and you see that for 20 the number of hours got calculated

hours got calculated

hours got calculated true is obviously not a valid number

true is obviously not a valid number

true is obviously not a valid number and minus 100 is a negative number

and minus 100 is a negative number

and minus 100 is a negative number so everything works perfect validations

so everything works perfect validations

so everything works perfect validations in place

in place

in place and we can provide a list here now and

and we can provide a list here now and

and we can provide a list here now and as a final optimization

as a final optimization

as a final optimization we can actually change this message here

we can actually change this message here

we can actually change this message here that says

that says

that says hey user enter

number of days as a

number of days as a comma separated

comma separated

comma separated list and i will convert it

list and i will convert it

list and i will convert it to hours so now we can provide

to hours so now we can provide

to hours so now we can provide either just one value and it works fine

either just one value and it works fine

either just one value and it works fine or we can provide

or we can provide

or we can provide multiple values

and again if we want to see how that

and again if we want to see how that list

list

list actually looks like and check the type

actually looks like and check the type

actually looks like and check the type that it has in python let's actually

that it has in python let's actually

that it has in python let's actually print it

print it

print it so first i'm gonna print type

so first i'm gonna print type

so first i'm gonna print type of user input called split

and then i'm just gonna print that list

and then i'm just gonna print that list itself so let's execute

itself so let's execute

itself so let's execute and let's provide

some values and here you see

some values and here you see this is the class list so basically the

this is the class list so basically the

this is the class list so basically the data type

data type

data type list and that's how our list

list and that's how our list

list and that's how our list looks like so we have these square

looks like so we have these square

looks like so we have these square brackets here and each element inside

brackets here and each element inside

brackets here and each element inside as a string because we have the quotes

as a string because we have the quotes

as a string because we have the quotes here

here

here and later our application then

and later our application then

and later our application then transforms it or tries to

transforms it or tries to

transforms it or tries to transform it into an integer

transform it into an integer

transform it into an integer and you also see there are some

and you also see there are some

and you also see there are some additional spaces here because

additional spaces here because

additional spaces here because that's how we entered the values so

that's how we entered the values so

that's how we entered the values so basically

basically

basically the split splits the values on comma

the split splits the values on comma

the split splits the values on comma so this space also becomes part of that

so this space also becomes part of that

so this space also becomes part of that element

element

element so to fix that leading space in each

so to fix that leading space in each

so to fix that leading space in each value we can

value we can

value we can basically just add a space here so it

basically just add a space here so it

basically just add a space here so it will split on

will split on

will split on comma and space

comma and space

comma and space and let's test it out

and there you go we have our values

and there you go we have our values without the space before them

so you saw an example of when we

so you saw an example of when we actually need

actually need

actually need to use list data types in this example

to use list data types in this example

to use list data types in this example we wanted to allow users to basically

we wanted to allow users to basically

we wanted to allow users to basically just input multiple values at once as a

just input multiple values at once as a

just input multiple values at once as a list

list

list but obviously this is just one of the

but obviously this is just one of the

but obviously this is just one of the use cases

use cases

use cases for a list and one of the specific

for a list and one of the specific

for a list and one of the specific examples because throughout the

examples because throughout the

examples because throughout the application you can create

application you can create

application you can create lists and you can use the elements of

lists and you can use the elements of

lists and you can use the elements of that list

that list

that list in another function so you can use it

in another function so you can use it

in another function so you can use it for multiple use cases

for multiple use cases

for multiple use cases and just to show you some basic syntax

and just to show you some basic syntax

and just to show you some basic syntax of

of

of how to create lists within your code

how to create lists within your code

how to create lists within your code inside your application so how to

inside your application so how to

inside your application so how to initiate it and then how to use that

initiate it and then how to use that

initiate it and then how to use that list

list

list i will show you the examples here so

i will show you the examples here so

i will show you the examples here so basically to create a

basically to create a

basically to create a list in your code you would use that

list in your code you would use that

list in your code you would use that syntax that i showed you earlier

syntax that i showed you earlier

syntax that i showed you earlier with square brackets and inside that you

with square brackets and inside that you

with square brackets and inside that you would have

would have

would have list of elements and this could be

list of elements and this could be

list of elements and this could be strings

strings

strings so it could be for example names of

so it could be for example names of

so it could be for example names of month

month

month let's say like this

let's say like this

let's say like this and then we would have to assign it to a

and then we would have to assign it to a

and then we would have to assign it to a variable right

variable right

variable right again just like we did for strings or

again just like we did for strings or

again just like we did for strings or integers or other data types

integers or other data types

integers or other data types so we can call it my list

so we can call it my list

so we can call it my list and this will give us a list with

and this will give us a list with

and this will give us a list with three string values inside

three string values inside

three string values inside and once you have created a list you can

and once you have created a list you can

and once you have created a list you can then

then

then use it to read the values from the list

use it to read the values from the list

use it to read the values from the list right

right

right so basically to get the individual

so basically to get the individual

so basically to get the individual values elements out of that list so for

values elements out of that list so for

values elements out of that list so for example if we wanted to print out

example if we wanted to print out

example if we wanted to print out the first element of my list

the first element of my list

the first element of my list then we would access that

then we would access that

then we would access that using my list and then following syntax

using my list and then following syntax

using my list and then following syntax with again square brackets and then

with again square brackets and then

with again square brackets and then index number of the element which is

index number of the element which is

index number of the element which is starting from zero so this is the first

starting from zero so this is the first

starting from zero so this is the first element with index zero this is

element with index zero this is

element with index zero this is the element with index one index

the element with index one index

the element with index one index two and so on right so it could be

two and so on right so it could be

two and so on right so it could be confusing because it starts with zero

confusing because it starts with zero

confusing because it starts with zero not with one but that's how the

not with one but that's how the

not with one but that's how the specific element of a list can be

specific element of a list can be

specific element of a list can be accessed right

accessed right

accessed right so if i wanted the march value here the

so if i wanted the march value here the

so if i wanted the march value here the third element then i would just

third element then i would just

third element then i would just type in index two and this is a syntax

type in index two and this is a syntax

type in index two and this is a syntax of

of

of getting elements from a list if i just

getting elements from a list if i just

getting elements from a list if i just want specific

want specific

want specific values and not each element one by one

values and not each element one by one

values and not each element one by one as we had in this example right so one

as we had in this example right so one

as we had in this example right so one way to use a list

way to use a list

way to use a list is to basically loop through it and get

is to basically loop through it and get

is to basically loop through it and get one element at a time

one element at a time

one element at a time and that's why we don't need to use

and that's why we don't need to use

and that's why we don't need to use index here because it gives us

index here because it gives us

index here because it gives us elements one after another or

elements one after another or

elements one after another or maybe we don't want all the elements or

maybe we don't want all the elements or

maybe we don't want all the elements or to do something for each element we just

to do something for each element we just

to do something for each element we just want specific

want specific

want specific values from the list for different use

values from the list for different use

values from the list for different use cases in this case we can

cases in this case we can

cases in this case we can access them individually like this and

access them individually like this and

access them individually like this and in addition to accessing the values from

in addition to accessing the values from

in addition to accessing the values from a list or basically reading the values

a list or basically reading the values

a list or basically reading the values from release

from release

from release we can also add values to a list

we can also add values to a list

we can also add values to a list and we can do that by typing my list

and we can do that by typing my list

and we can do that by typing my list and then on the my list we're going to

and then on the my list we're going to

and then on the my list we're going to do dot

do dot

do dot and use the append function

and use the append function

and use the append function right so append will basically take the

right so append will basically take the

right so append will basically take the next element

next element

next element or another value basically and add it to

or another value basically and add it to

or another value basically and add it to the list of elements already in the list

the list of elements already in the list

the list of elements already in the list right

right

right so let's say we want to add the next

so let's say we want to add the next

so let's say we want to add the next month

month

month and now if i print

and now if i print

and now if i print my list we should actually see

my list we should actually see

my list we should actually see this here with april as a fourth element

this here with april as a fourth element

this here with april as a fourth element right so let's execute and there you go

right so let's execute and there you go

right so let's execute and there you go so first we have march here printed out

so first we have march here printed out

so first we have march here printed out which is

which is

which is the third element right index two

the third element right index two

the third element right index two and then we have my list append that

and then we have my list append that

and then we have my list append that adds fourth month name into the list

adds fourth month name into the list

adds fourth month name into the list so after append this is how my list

so after append this is how my list

so after append this is how my list will look like and now again we can

will look like and now again we can

will look like and now again we can access

access

access the specific element for example if we

the specific element for example if we

the specific element for example if we wanted to access

wanted to access

wanted to access the newly edit element on index three

the newly edit element on index three

the newly edit element on index three so that's going to be the fourth element

so that's going to be the fourth element

so that's going to be the fourth element and there you go we have the new

and there you go we have the new

and there you go we have the new element printed out and also an

element printed out and also an

element printed out and also an interesting note is what happens

interesting note is what happens

interesting note is what happens if we use an index here which is

if we use an index here which is

if we use an index here which is too high so basically pointing an

too high so basically pointing an

too high so basically pointing an element that doesn't exist right so

element that doesn't exist right so

element that doesn't exist right so instead of three let's say we have

instead of three let's say we have

instead of three let's say we have four here so this will point to the

four here so this will point to the

four here so this will point to the fifth element and since we only have

fifth element and since we only have

fifth element and since we only have four elements let's actually see what's

four elements let's actually see what's

four elements let's actually see what's gonna happen so i'm gonna execute this

gonna happen so i'm gonna execute this

gonna happen so i'm gonna execute this and there you go you see an error index

and there you go you see an error index

and there you go you see an error index error that says a list index out of

error that says a list index out of

error that says a list index out of range

range

range so every time you access or you try to

so every time you access or you try to

so every time you access or you try to access an

access an

access an element at an index that doesn't exist

element at an index that doesn't exist

element at an index that doesn't exist you will get this list index out of

you will get this list index out of

you will get this list index out of range error

range error

range error and this is actually something that may

and this is actually something that may

and this is actually something that may happen pretty often

happen pretty often

happen pretty often when working with lists if you're

when working with lists if you're

when working with lists if you're accessing the values like this

accessing the values like this

accessing the values like this so this is how you work with lists how

so this is how you work with lists how

so this is how you work with lists how you create them and access

you create them and access

you create them and access values in them as well as add some

values in them as well as add some

values in them as well as add some values however

values however

values however note that most of the time if you are

note that most of the time if you are

note that most of the time if you are using lists

using lists

using lists you're going to be using them in a for

you're going to be using them in a for

you're going to be using them in a for loop because most of the time you would

loop because most of the time you would

loop because most of the time you would want to do

want to do

want to do something specific for each element in

something specific for each element in

something specific for each element in the list

the list

the list so this basically should give you an

so this basically should give you an

so this basically should give you an idea of syntax of

idea of syntax of

idea of syntax of lists and how to use them generally and

lists and how to use them generally and

lists and how to use them generally and also how to use them in combination with

also how to use them in combination with

also how to use them in combination with for loops here i want to take a few

for loops here i want to take a few

for loops here i want to take a few seconds to thank jetbrains

seconds to thank jetbrains

seconds to thank jetbrains the creators of the awesome pycharm and

the creators of the awesome pycharm and

the creators of the awesome pycharm and intellij editors

intellij editors

intellij editors for sponsoring this complete course

for sponsoring this complete course

for sponsoring this complete course besides all the great existing products

besides all the great existing products

besides all the great existing products they have

they have

they have they recently introduced space which is

they recently introduced space which is

they recently introduced space which is an

an

an all-in-one team collaboration platform

all-in-one team collaboration platform

all-in-one team collaboration platform covering software development

covering software development

covering software development project and team management and the

project and team management and the

project and team management and the great thing about space is that

great thing about space is that

great thing about space is that every single tool you would need in a

every single tool you would need in a

every single tool you would need in a company to collaborate and work together

company to collaborate and work together

company to collaborate and work together in a team

in a team

in a team is in one space so you have tools for

is in one space so you have tools for

is in one space so you have tools for chats blogs planning and creating tasks

chats blogs planning and creating tasks

chats blogs planning and creating tasks meetings but also software development

meetings but also software development

meetings but also software development tools like

tools like

tools like version control ci cd package

version control ci cd package

version control ci cd package repositories and much more

repositories and much more

repositories and much more so all these in one platform and in

so all these in one platform and in

so all these in one platform and in terms of

terms of

terms of productivity the great thing is you get

productivity the great thing is you get

productivity the great thing is you get all the notifications in one place

all the notifications in one place

all the notifications in one place like code review updates newly created

like code review updates newly created

like code review updates newly created issues

issues

issues new blog posts etc you get all of these

new blog posts etc you get all of these

new blog posts etc you get all of these in

in

in chats where you can react directly in

chats where you can react directly in

chats where you can react directly in place

place

place or add them to your to-do list

or add them to your to-do list

or add them to your to-do list automatically

automatically

automatically so i think the main value of space isn't

so i think the main value of space isn't

so i think the main value of space isn't that it has all these tools

that it has all these tools

that it has all these tools but rather the fact that it integrates

but rather the fact that it integrates

but rather the fact that it integrates them in such an intelligent way

them in such an intelligent way

them in such an intelligent way that it improves the team communication

that it improves the team communication

that it improves the team communication and productivity overall

and productivity overall

and productivity overall now let's go back to coding

now let's go back to coding

now let's go back to coding now at this point here i want to mention

now at this point here i want to mention

now at this point here i want to mention a pretty

a pretty

a pretty minor and simple detail but something

minor and simple detail but something

minor and simple detail but something that is also very

that is also very

that is also very important and useful in programming and

important and useful in programming and

important and useful in programming and that

that

that is comments so how do we write comments

is comments so how do we write comments

is comments so how do we write comments in python and why do we need or in which

in python and why do we need or in which

in python and why do we need or in which cases

cases

cases are comments actually useful one usage

are comments actually useful one usage

are comments actually useful one usage of comments is basically to give

of comments is basically to give

of comments is basically to give yourself

yourself

yourself some notes on your own code so

some notes on your own code so

some notes on your own code so basically if your code gets a little bit

basically if your code gets a little bit

basically if your code gets a little bit complicated

complicated

complicated and it's not really clear what the logic

and it's not really clear what the logic

and it's not really clear what the logic or the function body is doing

or the function body is doing

or the function body is doing it could be because of bad programming

it could be because of bad programming

it could be because of bad programming but also because

but also because

but also because the function logic is just a little too

the function logic is just a little too

the function logic is just a little too complicated

complicated

complicated so you want to add some textual notes to

so you want to add some textual notes to

so you want to add some textual notes to that code

that code

that code so that you understand what's going on

so that you understand what's going on

so that you understand what's going on there even when you look at that code

there even when you look at that code

there even when you look at that code days or maybe weeks after you wrote it

days or maybe weeks after you wrote it

days or maybe weeks after you wrote it so for example right here we may want to

so for example right here we may want to

so for example right here we may want to add

add

add some notes about what

some notes about what

some notes about what this part here is doing and comments in

this part here is doing and comments in

this part here is doing and comments in python

python

python are written with this character so for

are written with this character so for

are written with this character so for example

example

example i want to add a note here we want

i want to add a note here we want

i want to add a note here we want to do conversion only

to do conversion only

to do conversion only for positive integers

and that's basically my note that

and that's basically my note that summarizes

summarizes

summarizes all that logic right here and it is not

all that logic right here and it is not

all that logic right here and it is not only useful for myself

only useful for myself

only useful for myself in case i forget what this complex logic

in case i forget what this complex logic

in case i forget what this complex logic actually does but also for your team

actually does but also for your team

actually does but also for your team members so if you're working in a team

members so if you're working in a team

members so if you're working in a team and your code gets really complex and

and your code gets really complex and

and your code gets really complex and it's

it's

it's difficult to keep an overview of

difficult to keep an overview of

difficult to keep an overview of different functions and variables and

different functions and variables and

different functions and variables and what all these things do

what all these things do

what all these things do you can basically add these comments as

you can basically add these comments as

you can basically add these comments as notes

notes

notes to your team members so they can also

to your team members so they can also

to your team members so they can also understand what you thought

understand what you thought

understand what you thought or what kind of logic actually you were

or what kind of logic actually you were

or what kind of logic actually you were thinking about when writing this code

thinking about when writing this code

thinking about when writing this code so comments is a way of communicating

so comments is a way of communicating

so comments is a way of communicating your thoughts and your logic on your

your thoughts and your logic on your

your thoughts and your logic on your code so that's one use case for using

code so that's one use case for using

code so that's one use case for using comments

comments

comments and the second use case if you have a

and the second use case if you have a

and the second use case if you have a piece of code that you do not want to

piece of code that you do not want to

piece of code that you do not want to delete

delete

delete because it has some logic or it has some

because it has some logic or it has some

because it has some logic or it has some example that you want to

example that you want to

example that you want to keep as a reference but you don't want

keep as a reference but you don't want

keep as a reference but you don't want that code to be

that code to be

that code to be executed so basically you can comment

executed so basically you can comment

executed so basically you can comment out

out

out code so that it still stays there but

code so that it still stays there but

code so that it still stays there but doesn't get executed and the way to do

doesn't get executed and the way to do

doesn't get executed and the way to do that is just basically

that is just basically

that is just basically having this character before the line

having this character before the line

having this character before the line and also

and also

and also note the color of the comment in the

note the color of the comment in the

note the color of the comment in the editor

editor

editor is gray so it's immediately visible that

is gray so it's immediately visible that

is gray so it's immediately visible that these are the comments

these are the comments

these are the comments and now these two lines will not get

and now these two lines will not get

and now these two lines will not get executed by the program

executed by the program

executed by the program they will be ignored but they are for

they will be ignored but they are for

they will be ignored but they are for your own reference

your own reference

your own reference in case you want to keep it there for

in case you want to keep it there for

in case you want to keep it there for example this could happen

example this could happen

example this could happen if you are unsure about the change and

if you are unsure about the change and

if you are unsure about the change and you want to delete that whole code

you want to delete that whole code

you want to delete that whole code from your application because you might

from your application because you might

from your application because you might actually need that

actually need that

actually need that eventually so you're not sure about it

eventually so you're not sure about it

eventually so you're not sure about it so temporary

so temporary

so temporary comment the code before you permanently

comment the code before you permanently

comment the code before you permanently delete that

delete that

delete that so these are some of the use cases of

so these are some of the use cases of

so these are some of the use cases of comments

comments

comments now if you have multiple lines of code

now if you have multiple lines of code

now if you have multiple lines of code that you want to comment out

that you want to comment out

that you want to comment out or maybe hold text that you wrote as a

or maybe hold text that you wrote as a

or maybe hold text that you wrote as a note so for example you want to comment

note so for example you want to comment

note so for example you want to comment out all these four lines here

out all these four lines here

out all these four lines here obviously you don't want to do this in

obviously you don't want to do this in

obviously you don't want to do this in front of every line

front of every line

front of every line so for multi-line comments you can

so for multi-line comments you can

so for multi-line comments you can actually

actually

actually use the following syntax which is three

use the following syntax which is three

use the following syntax which is three quotes at the beginning and

quotes at the beginning and

quotes at the beginning and at the end and again you see the

at the end and again you see the

at the end and again you see the highlighting is

highlighting is

highlighting is different here which basically is

different here which basically is

different here which basically is highlighting of a string however it is

highlighting of a string however it is

highlighting of a string however it is ignored

ignored

ignored by the program and it will not be

by the program and it will not be

by the program and it will not be executed

executed

executed as a best practice you shouldn't have

as a best practice you shouldn't have

as a best practice you shouldn't have too many comments in your code because

too many comments in your code because

too many comments in your code because it will just add additional clutter

it will just add additional clutter

it will just add additional clutter and your code will look basically

and your code will look basically

and your code will look basically unclean so

unclean so

unclean so you should use them only when needed

in this part i'm going to show you

in this part i'm going to show you another data type in python

another data type in python

another data type in python called set so what is a set let's start

called set so what is a set let's start

called set so what is a set let's start our application again

our application again

our application again and let's say i provide here input

and let's say i provide here input

and let's say i provide here input values as a list let's say 20

values as a list let's say 20

values as a list let's say 20 40 and 20 again

40 and 20 again

40 and 20 again so basically i have duplicate values in

so basically i have duplicate values in

so basically i have duplicate values in my list

my list

my list and when i execute it i see that

and when i execute it i see that

and when i execute it i see that the program got executed for each

the program got executed for each

the program got executed for each element

element

element and i have duplicate results because i

and i have duplicate results because i

and i have duplicate results because i passed in the same value

passed in the same value

passed in the same value twice now again users

twice now again users

twice now again users they can input any value they want

they can input any value they want

they can input any value they want either

either

either intentionally or accidentally this could

intentionally or accidentally this could

intentionally or accidentally this could be bad values

be bad values

be bad values or things that don't make any sense so

or things that don't make any sense so

or things that don't make any sense so let's say

let's say

let's say we want our program to behave in a way

we want our program to behave in a way

we want our program to behave in a way that

that

that if user provides the same values twice

if user provides the same values twice

if user provides the same values twice or three times we only want to calculate

or three times we only want to calculate

or three times we only want to calculate the number of hours for that value just

the number of hours for that value just

the number of hours for that value just once

once

once so basically for this input we want just

so basically for this input we want just

so basically for this input we want just those

those

those two lines and basically ignore the

two lines and basically ignore the

two lines and basically ignore the execution again for the same value

execution again for the same value

execution again for the same value and you probably already guessed that's

and you probably already guessed that's

and you probably already guessed that's where set

where set

where set data type will help us so set is

data type will help us so set is

data type will help us so set is basically a list

basically a list

basically a list of elements but with unique values

of elements but with unique values

of elements but with unique values inside

inside

inside so list data type allows duplicate

so list data type allows duplicate

so list data type allows duplicate values

values

values the same value multiple times set does

the same value multiple times set does

the same value multiple times set does not allow duplicate values

not allow duplicate values

not allow duplicate values so how do we use set instead of a list

so how do we use set instead of a list

so how do we use set instead of a list and it's actually very easy to convert

and it's actually very easy to convert

and it's actually very easy to convert an existing

an existing

an existing list into a set and we can do that

list into a set and we can do that

list into a set and we can do that using a function called set

using a function called set

using a function called set and basically the parameter of our set

and basically the parameter of our set

and basically the parameter of our set function will be

function will be

function will be the list so if this list here contains

the list so if this list here contains

the list so if this list here contains any duplicated values that will be

any duplicated values that will be

any duplicated values that will be basically just filtered out

basically just filtered out

basically just filtered out when we convert it into a set so that's

when we convert it into a set so that's

when we convert it into a set so that's how it works

how it works

how it works and again for demonstration let's

and again for demonstration let's

and again for demonstration let's actually print out

actually print out

actually print out how set value looks like

how set value looks like

how set value looks like so i'm going to print the list first

so i'm going to print the list first

so i'm going to print the list first so that we can compare then we're gonna

so that we can compare then we're gonna

so that we can compare then we're gonna print out the set

and let's also print out the types

and let's also print out the types and i don't want to repeat this

and i don't want to repeat this

and i don't want to repeat this expression over and over again

expression over and over again

expression over and over again so what we can do even though this is

so what we can do even though this is

so what we can do even though this is just for demonstration

just for demonstration

just for demonstration we can actually

extract it into a variable let's say

extract it into a variable let's say list of days

like this and

like this and we can use it everywhere we need and

we can use it everywhere we need and

we can use it everywhere we need and this is a little bit cleaner because

this is a little bit cleaner because

this is a little bit cleaner because we don't have to repeat the same

we don't have to repeat the same

we don't have to repeat the same expression

expression

expression over and over again and again let's

over and over again and again let's

over and over again and again let's print out the type

print out the type

print out the type of list of days and then print out

of list of days and then print out

of list of days and then print out the type of a set

the type of a set

the type of a set of lists of days and again you see that

of lists of days and again you see that

of lists of days and again you see that nested function calls three times

nested function calls three times

nested function calls three times and this should give us some interesting

and this should give us some interesting

and this should give us some interesting value that we can compare

value that we can compare

value that we can compare lists and sets and just a small note

lists and sets and just a small note

lists and sets and just a small note here that whenever we have this nested

here that whenever we have this nested

here that whenever we have this nested function calls

function calls

function calls think of the execution from inside

think of the execution from inside

think of the execution from inside out so the first function that will get

out so the first function that will get

out so the first function that will get executed in this chain

executed in this chain

executed in this chain is actually the set right so it starts

is actually the set right so it starts

is actually the set right so it starts from the last function

from the last function

from the last function in that chain so set function will get

in that chain so set function will get

in that chain so set function will get executed and convert that list into a

executed and convert that list into a

executed and convert that list into a set

set

set then type function will get executed on

then type function will get executed on

then type function will get executed on that resulting set value

that resulting set value

that resulting set value and then print will get executed and

and then print will get executed and

and then print will get executed and print basically the result

print basically the result

print basically the result of the type so the order goes from

of the type so the order goes from

of the type so the order goes from innermost function to the outer

innermost function to the outer

innermost function to the outer functions

functions

functions so let's save it and execute and now i'm

so let's save it and execute and now i'm

so let's save it and execute and now i'm going to

going to

going to again provide a list let's say 10

again provide a list let's say 10

again provide a list let's say 10 and then 45 and 30 and 10 again

and then 45 and 30 and 10 again

and then 45 and 30 and 10 again and enter and first of all we see that

and enter and first of all we see that

and enter and first of all we see that 10 only got executed once and not twice

10 only got executed once and not twice

10 only got executed once and not twice and we can also see the first one

and we can also see the first one

and we can also see the first one is basically value of a list and you see

is basically value of a list and you see

is basically value of a list and you see at least here the second one is a set

at least here the second one is a set

at least here the second one is a set and you already notice the difference

and you already notice the difference

and you already notice the difference that list basically uses square brackets

that list basically uses square brackets

that list basically uses square brackets and set

and set

and set is represented using curly braces right

is represented using curly braces right

is represented using curly braces right and again it has value of 10 just once

and again it has value of 10 just once

and again it has value of 10 just once and again we have the data type of a

and again we have the data type of a

and again we have the data type of a list

list

list and a set so just to demonstrate that

and a set so just to demonstrate that

and a set so just to demonstrate that they are actually

they are actually

they are actually own separate data types

and like we saw previously with lists we

and like we saw previously with lists we can also

can also

can also create sets as well as add an excess

create sets as well as add an excess

create sets as well as add an excess values from it

values from it

values from it so let's see an example here for example

so let's see an example here for example

so let's see an example here for example if you want to create a set

if you want to create a set

if you want to create a set the syntax for that will look like this

the syntax for that will look like this

the syntax for that will look like this as we already saw again set can have

as we already saw again set can have

as we already saw again set can have strings or numbers or booleans

strings or numbers or booleans

strings or numbers or booleans as its elements let's use the same

as its elements let's use the same

as its elements let's use the same example we use with lists so

example we use with lists so

example we use with lists so i'm gonna just basically type in names

i'm gonna just basically type in names

i'm gonna just basically type in names of the month here

of the month here

of the month here so let's say we have again january

march and we're going to

march and we're going to assign that again to a variable

assign that again to a variable

assign that again to a variable so this will give us a set that we can

so this will give us a set that we can

so this will give us a set that we can create ourselves

create ourselves

create ourselves not just from the user input and now we

not just from the user input and now we

not just from the user input and now we can access

can access

can access the values the individual elements from

the values the individual elements from

the values the individual elements from the set

the set

the set and we can also add elements to the set

and we can also add elements to the set

and we can also add elements to the set however

however

however we cannot access the individual

we cannot access the individual

we cannot access the individual elements of the set like we did on lists

elements of the set like we did on lists

elements of the set like we did on lists right

right

right you remember on lists we use the syntax

you remember on lists we use the syntax

you remember on lists we use the syntax with square brackets and the index of

with square brackets and the index of

with square brackets and the index of the element

the element

the element in set we cannot actually do that

in set we cannot actually do that

in set we cannot actually do that instead we can only access the elements

instead we can only access the elements

instead we can only access the elements of a set

of a set

of a set in a loop so for example in a for loop

in a loop so for example in a for loop

in a loop so for example in a for loop we would write element

we would write element

we would write element in my set and then

in my set and then

in my set and then we can basically print that element so

we can basically print that element so

we can basically print that element so let's

execute

execute and right here you see all the elements

and right here you see all the elements

and right here you see all the elements printed out

printed out

printed out and again as i mentioned with lists also

and again as i mentioned with lists also

and again as i mentioned with lists also previously

previously

previously most of the time when you're working

most of the time when you're working

most of the time when you're working with lists or sets

with lists or sets

with lists or sets you're gonna want to look through the

you're gonna want to look through the

you're gonna want to look through the elements because you probably would want

elements because you probably would want

elements because you probably would want to do some operation

to do some operation

to do some operation on individual elements or some of the

on individual elements or some of the

on individual elements or some of the elements right instead of just grabbing

elements right instead of just grabbing

elements right instead of just grabbing individual

individual

individual one or two values from that now how do

one or two values from that now how do

one or two values from that now how do we

we

we add elements to a set

add elements to a set

add elements to a set let's see it as well we can add elements

let's see it as well we can add elements

let's see it as well we can add elements to my set

to my set

to my set using my set so the

using my set so the

using my set so the set itself the variable name and then if

set itself the variable name and then if

set itself the variable name and then if you do

you do

you do dot you see a bunch of built-in

dot you see a bunch of built-in

dot you see a bunch of built-in functions again

functions again

functions again set has its own built-in functions which

set has its own built-in functions which

set has its own built-in functions which are completely different from what

are completely different from what

are completely different from what list has and it has a function called

list has and it has a function called

list has and it has a function called ed and here we can basically add

ed and here we can basically add

ed and here we can basically add a new element again let's do april

a new element again let's do april

a new element again let's do april and now we can print my set

and execute and there you go so we have

and execute and there you go so we have here individual elements that are

here individual elements that are

here individual elements that are printed out

printed out

printed out and we have the new list after we edit

and we have the new list after we edit

and we have the new list after we edit april now one thing you probably already

april now one thing you probably already

april now one thing you probably already noticed

noticed

noticed when working with the set like printing

when working with the set like printing

when working with the set like printing its elements or

its elements or

its elements or adding a new element it doesn't work

adding a new element it doesn't work

adding a new element it doesn't work in the same sequence as with a list

in the same sequence as with a list

in the same sequence as with a list right

right

right so for list we basically had this

so for list we basically had this

so for list we basically had this january february march in this

january february march in this

january february march in this exact order and when we edit a new

exact order and when we edit a new

exact order and when we edit a new element

element

element basically it got added at the end right

basically it got added at the end right

basically it got added at the end right as a fourth element

as a fourth element

as a fourth element in set it's not ordered it's basically

in set it's not ordered it's basically

in set it's not ordered it's basically in a random order right

in a random order right

in a random order right so if i execute this again rerun

so if i execute this again rerun

so if i execute this again rerun you see the order changed here and here

you see the order changed here and here

you see the order changed here and here as well right

as well right

as well right and if i do it again there you go so

and if i do it again there you go so

and if i do it again there you go so this order and this order basically

this order and this order basically

this order and this order basically changes right

changes right

changes right so as you see working with sets

so as you see working with sets

so as you see working with sets is actually pretty different from

is actually pretty different from

is actually pretty different from working with lists

working with lists

working with lists so this means that set

so this means that set

so this means that set not having or not allowing duplicate

not having or not allowing duplicate

not having or not allowing duplicate values is

values is

values is basically just one of the differences

basically just one of the differences

basically just one of the differences between

between

between sets and lists and

sets and lists and

sets and lists and of course you're probably wondering i

of course you're probably wondering i

of course you're probably wondering i can add elements i can access elements

can add elements i can access elements

can add elements i can access elements what about removing elements right from

what about removing elements right from

what about removing elements right from lists or

lists or

lists or sets and you can do that actually

sets and you can do that actually

sets and you can do that actually the same way for both sets and

the same way for both sets and

the same way for both sets and lists so for example if we want to

lists so for example if we want to

lists so for example if we want to remove an element from a set

remove an element from a set

remove an element from a set we can execute a built-in function

we can execute a built-in function

we can execute a built-in function called remove

called remove

called remove and remove basically takes a parameter

and remove basically takes a parameter

and remove basically takes a parameter which is the value itself

which is the value itself

which is the value itself so let's say if we want to remove

so let's say if we want to remove

so let's say if we want to remove january from here

january from here

january from here then we're going to pass the value to

then we're going to pass the value to

then we're going to pass the value to remove function

remove function

remove function and now if i print my set again

and now if i print my set again

and now if i print my set again after the remove gets executed and let's

after the remove gets executed and let's

after the remove gets executed and let's run it

run it

run it and here you see the last print

and here you see the last print

and here you see the last print basically doesn't have january

basically doesn't have january

basically doesn't have january inside and as i said it works the same

inside and as i said it works the same

inside and as i said it works the same for lists so let me demonstrate

for lists so let me demonstrate

for lists so let me demonstrate this as well so on my list which has its

this as well so on my list which has its

this as well so on my list which has its own

own

own set of built-in functions one of them is

set of built-in functions one of them is

set of built-in functions one of them is remove

remove

remove which in this case is called the same

which in this case is called the same

which in this case is called the same for both set and list

for both set and list

for both set and list and this remove built-in function also

and this remove built-in function also

and this remove built-in function also accepts

accepts

accepts the value of the element you want to

the value of the element you want to

the value of the element you want to remove

remove

remove and let's print it again my list

and let's print it again my list

and let's print it again my list and execute there you go this is a set

and execute there you go this is a set

and execute there you go this is a set with the syntax with curly braces and

with the syntax with curly braces and

with the syntax with curly braces and this is a list

this is a list

this is a list which now doesn't have january inside

which now doesn't have january inside

which now doesn't have january inside because we removed it

because we removed it

because we removed it and as you know lists can have duplicate

and as you know lists can have duplicate

and as you know lists can have duplicate values

values

values so if we have january

so if we have january

so if we have january again here so two times and

again here so two times and

again here so two times and we do remove january it will actually

we do remove january it will actually

we do remove january it will actually remove

remove

remove the first occurrence of that value so if

the first occurrence of that value so if

the first occurrence of that value so if i execute this

i execute this

i execute this you see the first one got removed and

you see the first one got removed and

you see the first one got removed and the last one or the second january value

the last one or the second january value

the last one or the second january value is

is

is still there so that's how you work

still there so that's how you work

still there so that's how you work with sets basically and also how to

with sets basically and also how to

with sets basically and also how to remove

remove

remove elements from sets and lists

so at this point i want to take time and

so at this point i want to take time and review the functions that we have used

review the functions that we have used

review the functions that we have used from

from

from python itself so the functions that we

python itself so the functions that we

python itself so the functions that we ourselves didn't actually

ourselves didn't actually

ourselves didn't actually write and the functions that python

write and the functions that python

write and the functions that python basically makes

basically makes

basically makes available for us to use are called

available for us to use are called

available for us to use are called built-in functions

built-in functions

built-in functions so till now we have used function

so till now we have used function

so till now we have used function print which basically just takes

print which basically just takes

print which basically just takes some input this could be a string this

some input this could be a string this

some input this could be a string this could be a variable

could be a variable

could be a variable this could be a number doesn't really

this could be a number doesn't really

this could be a number doesn't really matter and

matter and

matter and basically just prints it in the output

basically just prints it in the output

basically just prints it in the output console right

console right

console right in the terminal we also saw input

in the terminal we also saw input

in the terminal we also saw input function that basically takes user input

function that basically takes user input

function that basically takes user input again we can provide a parameter which

again we can provide a parameter which

again we can provide a parameter which will be a message

will be a message

will be a message or leave it empty we also in the

or leave it empty we also in the

or leave it empty we also in the last example so an example of set

last example so an example of set

last example so an example of set function which basically takes a list

function which basically takes a list

function which basically takes a list and converts it into a set and another

and converts it into a set and another

and converts it into a set and another example

example

example is int again takes

is int again takes

is int again takes a string as a parameter and converts it

a string as a parameter and converts it

a string as a parameter and converts it into integer

into integer

into integer and all of these are built-in functions

and all of these are built-in functions

and all of these are built-in functions because python provides them to us

because python provides them to us

because python provides them to us so that we can use it in our code and in

so that we can use it in our code and in

so that we can use it in our code and in python

python

python there are a lot of very useful built-in

there are a lot of very useful built-in

there are a lot of very useful built-in functions for different purposes

functions for different purposes

functions for different purposes and as i mentioned most of these

and as i mentioned most of these

and as i mentioned most of these functions basically accept

functions basically accept

functions basically accept a parameter and then do something with

a parameter and then do something with

a parameter and then do something with that parameter

that parameter

that parameter that input that we provide that function

that input that we provide that function

that input that we provide that function and give us an

and give us an

and give us an output again print basically

output again print basically

output again print basically provides something here and gives us the

provides something here and gives us the

provides something here and gives us the output

output

output in the output window here

in the output window here

in the output window here in input we can provide some message

that will again print an input here and

that will again print an input here and the rest of them

the rest of them

the rest of them are giving value inside the code

are giving value inside the code

are giving value inside the code without displaying anything so in set we

without displaying anything so in set we

without displaying anything so in set we can

can

can provide a list

and the same way a parameter here which

and the same way a parameter here which is logical because the purpose of a

is logical because the purpose of a

is logical because the purpose of a function

function

function usually is to take some input like

usually is to take some input like

usually is to take some input like this as a parameter do something with

this as a parameter do something with

this as a parameter do something with that input

that input

that input and give us an output from that

and give us an output from that

and give us an output from that parameter and we have created our own

parameter and we have created our own

parameter and we have created our own functions

functions

functions that also take some input and

that also take some input and

that also take some input and give back some output like this and

give back some output like this and

give back some output like this and in addition to built-in functions that

in addition to built-in functions that

in addition to built-in functions that are called like this

are called like this

are called like this and our own functions we have also used

and our own functions we have also used

and our own functions we have also used third type of functions which is called

third type of functions which is called

third type of functions which is called directly on a value right and this is an

directly on a value right and this is an

directly on a value right and this is an example of that

example of that

example of that so basically directly on a value this

so basically directly on a value this

so basically directly on a value this could be a variable but

could be a variable but

could be a variable but also the string representation of that

also the string representation of that

also the string representation of that itself

itself

itself so if i had a string like that so

so if i had a string like that so

so if i had a string like that so basically directly on that value

basically directly on that value

basically directly on that value call a function like this and these are

call a function like this and these are

call a function like this and these are also built-in functions because

also built-in functions because

also built-in functions because python makes them available to us other

python makes them available to us other

python makes them available to us other than the syntax

than the syntax

than the syntax there is one major difference between

there is one major difference between

there is one major difference between these

these

these type of functions that are called

type of functions that are called

type of functions that are called directly like that

directly like that

directly like that and the functions that are called on the

and the functions that are called on the

and the functions that are called on the value itself

value itself

value itself and the main difference is that each

and the main difference is that each

and the main difference is that each data type

data type

data type has its own set of functions

has its own set of functions

has its own set of functions that can be executed like this so

that can be executed like this so

that can be executed like this so again let's take example of a string

again let's take example of a string

again let's take example of a string and if i do dot here you see

and if i do dot here you see

and if i do dot here you see the ide pycharm basically gives me

the ide pycharm basically gives me

the ide pycharm basically gives me a list of all the functions

a list of all the functions

a list of all the functions again built-in functions in python but

again built-in functions in python but

again built-in functions in python but functions that i can execute

functions that i can execute

functions that i can execute on a string value and

on a string value and

on a string value and again you see split is digit this is the

again you see split is digit this is the

again you see split is digit this is the one that we used

one that we used

one that we used in one of our previous examples that

in one of our previous examples that

in one of our previous examples that basically checks if that string

basically checks if that string

basically checks if that string is a representation of a digit or just a

is a representation of a digit or just a

is a representation of a digit or just a regular string

regular string

regular string and as you see lots of different

and as you see lots of different

and as you see lots of different functions so all of these are provided

functions so all of these are provided

functions so all of these are provided by python

by python

by python to do different stuff like turn the

to do different stuff like turn the

to do different stuff like turn the string literal to uppercase or

string literal to uppercase or

string literal to uppercase or replace a letter for example in that

replace a letter for example in that

replace a letter for example in that string

string

string and so on but the main point here is

and so on but the main point here is

and so on but the main point here is that those functions

that those functions

that those functions are only for string but as i said

are only for string but as i said

are only for string but as i said each data type has its own list of

each data type has its own list of

each data type has its own list of functions

functions

functions that can be called on that data type so

that can be called on that data type so

that can be called on that data type so for a demonstration let's take a list

and if i do dot here

and if i do dot here again you see a list of functions that i

again you see a list of functions that i

again you see a list of functions that i can execute specifically

can execute specifically

can execute specifically on list values and there are lots of

on list values and there are lots of

on list values and there are lots of things that you can do with lists like

things that you can do with lists like

things that you can do with lists like add elements to it remove elements from

add elements to it remove elements from

add elements to it remove elements from it

it

it sort the list copy and so on

sort the list copy and so on

sort the list copy and so on so that's basically a major difference

so that's basically a major difference

so that's basically a major difference between

between

between these type of functions and functions

these type of functions and functions

these type of functions and functions that can be executed on

that can be executed on

that can be executed on specific data type values but the

specific data type values but the

specific data type values but the concept is the same here

concept is the same here

concept is the same here you also have a function that gets a

you also have a function that gets a

you also have a function that gets a parameter an input

parameter an input

parameter an input and gives you an output and the

and gives you an output and the

and gives you an output and the parameter for this type of functions

parameter for this type of functions

parameter for this type of functions is actually the value that we are

is actually the value that we are

is actually the value that we are calling that function

calling that function

calling that function on so this string here 2 3

on so this string here 2 3

on so this string here 2 3 is going to be parameter of the split

is going to be parameter of the split

is going to be parameter of the split and in addition to that we can also

and in addition to that we can also

and in addition to that we can also provide

provide

provide additional parameters for example for

additional parameters for example for

additional parameters for example for split you saw here that we were able to

split you saw here that we were able to

split you saw here that we were able to add

add

add a comma space to basically tell

a comma space to basically tell

a comma space to basically tell the split function on which character to

the split function on which character to

the split function on which character to split that text

split that text

split that text so that was function comparisons in a

so that was function comparisons in a

so that was function comparisons in a nutshell

in this part we're going to learn a new

in this part we're going to learn a new data type in python

data type in python

data type in python called a dictionary and we're going to

called a dictionary and we're going to

called a dictionary and we're going to do that by modifying our application

do that by modifying our application

do that by modifying our application and modifying how users can actually

and modifying how users can actually

and modifying how users can actually input

input

input the values now our program currently

the values now our program currently

the values now our program currently takes the number of days and turns it

takes the number of days and turns it

takes the number of days and turns it into a number of hours

into a number of hours

into a number of hours what if we wanted to make our program a

what if we wanted to make our program a

what if we wanted to make our program a little bit more advanced

little bit more advanced

little bit more advanced a little fancier and basically allow

a little fancier and basically allow

a little fancier and basically allow users to also decide

users to also decide

users to also decide what units it should be converted to so

what units it should be converted to so

what units it should be converted to so user gives us the number of days

user gives us the number of days

user gives us the number of days and tells us whether to convert it into

and tells us whether to convert it into

and tells us whether to convert it into hours

hours

hours or minutes so instead of the whole list

or minutes so instead of the whole list

or minutes so instead of the whole list now we're going to get just number of

now we're going to get just number of

now we're going to get just number of days and

days and

days and the conversion units and this change may

the conversion units and this change may

the conversion units and this change may be a little bit complex

be a little bit complex

be a little bit complex in terms of syntax so i will try to

in terms of syntax so i will try to

in terms of syntax so i will try to explain everything step by step

explain everything step by step

explain everything step by step so the first thing we need to do is

so the first thing we need to do is

so the first thing we need to do is adjust

adjust

adjust how we get input from the user so now we

how we get input from the user so now we

how we get input from the user so now we want the user to

want the user to

want the user to be able to give us the number of days

be able to give us the number of days

be able to give us the number of days and units in one input so

and units in one input so

and units in one input so first of all i'm going to adjust the

first of all i'm going to adjust the

first of all i'm going to adjust the text here

text here

text here enter a number of days

enter a number of days

enter a number of days and conversion unit

and conversion unit

and conversion unit now there are a lot of different ways we

now there are a lot of different ways we

now there are a lot of different ways we can allow a user to do that

can allow a user to do that

can allow a user to do that but what we want to do is something like

this as an input so basically number of

this as an input so basically number of days

days

days colon and minutes or

colon and minutes or

colon and minutes or number of days and hours again this is

number of days and hours again this is

number of days and hours again this is our own decision

our own decision

our own decision we decide how the user input should look

we decide how the user input should look

we decide how the user input should look like

like

like but this should be a nice way of

but this should be a nice way of

but this should be a nice way of providing both of those values

providing both of those values

providing both of those values basically colon separated so instead of

basically colon separated so instead of

basically colon separated so instead of a list

a list

a list we're going to have a single input with

we're going to have a single input with

we're going to have a single input with two values that are

two values that are

two values that are separated by a colon so on the next line

separated by a colon so on the next line

separated by a colon so on the next line i'm going to change this split here

i'm going to change this split here

i'm going to change this split here into a column and this will give us

into a column and this will give us

into a column and this will give us user input this whole value split into

user input this whole value split into

user input this whole value split into two values as a list this is going to be

two values as a list this is going to be

two values as a list this is going to be day and days and

day and days and

day and days and unit so least with these two

unit so least with these two

unit so least with these two values and let's actually get rid of

values and let's actually get rid of

values and let's actually get rid of this for loop because we're not

this for loop because we're not

this for loop because we're not iterating through a list of numbers

iterating through a list of numbers

iterating through a list of numbers anymore

anymore

anymore and to begin with let's just print out

and to begin with let's just print out

and to begin with let's just print out the output or the result

the output or the result

the output or the result of days and unit variable

of days and unit variable

of days and unit variable so i'm gonna refresh and let's do

so i'm gonna refresh and let's do

so i'm gonna refresh and let's do two hours and enter

two hours and enter

two hours and enter and this is what we get so basically

and this is what we get so basically

and this is what we get so basically splitting this string

splitting this string

splitting this string on column will give us a list with

on column will give us a list with

on column will give us a list with elements

elements

elements 20 and hours and note that 20 is still

20 and hours and note that 20 is still

20 and hours and note that 20 is still a string right because that's how we get

a string right because that's how we get

a string right because that's how we get the input and now

the input and now

the input and now from those two values we're going to

from those two values we're going to

from those two values we're going to create

create

create a value of a data type called

a value of a data type called

a value of a data type called dictionary so in python we have another

dictionary so in python we have another

dictionary so in python we have another data type

data type

data type called the dictionary which basically

called the dictionary which basically

called the dictionary which basically looks

looks

looks like this so you have curly braces just

like this so you have curly braces just

like this so you have curly braces just like we had for

like we had for

like we had for a set and inside we have key

a set and inside we have key

a set and inside we have key value pairs so we don't have just single

value pairs so we don't have just single

value pairs so we don't have just single elements

elements

elements like this but rather we have key value

like this but rather we have key value

like this but rather we have key value pairs

pairs

pairs so key in our case is

so key in our case is

so key in our case is days and the value of that key

days and the value of that key

days and the value of that key in our case would be 20. and then comma

in our case would be 20. and then comma

in our case would be 20. and then comma separated another value would be

separated another value would be

separated another value would be unit and

unit and

unit and a string hours so basically this is

a string hours so basically this is

a string hours so basically this is the syntax of a dictionary and obviously

the syntax of a dictionary and obviously

the syntax of a dictionary and obviously the

the

the difference between a list and a

difference between a list and a

difference between a list and a dictionary is that we have

dictionary is that we have

dictionary is that we have descriptions for each of our values

descriptions for each of our values

descriptions for each of our values represented as key value pairs so we

represented as key value pairs so we

represented as key value pairs so we want to

want to

want to create this construct right here from

create this construct right here from

create this construct right here from those two values

those two values

those two values and since this is a data type we can

and since this is a data type we can

and since this is a data type we can create a value and

create a value and

create a value and assign it to a variable of that data

assign it to a variable of that data

assign it to a variable of that data type so let's call it

type so let's call it

type so let's call it days and unit

days and unit

days and unit dictionary

equals and obviously we don't want those

equals and obviously we don't want those values to be

values to be

values to be hard coded here we want to get it from

hard coded here we want to get it from

hard coded here we want to get it from the list

the list

the list now how do we access an element

now how do we access an element

now how do we access an element of a list how do we grab the first value

of a list how do we grab the first value

of a list how do we grab the first value which is

which is

which is 20 out of that list

20 out of that list

20 out of that list and to do that there is a syntax to

and to do that there is a syntax to

and to do that there is a syntax to access the elements

access the elements

access the elements in the list the list name and then you

in the list the list name and then you

in the list the list name and then you have

have

have square brackets and index of the element

square brackets and index of the element

square brackets and index of the element which if you remember you already

which if you remember you already

which if you remember you already learned in the section

learned in the section

learned in the section of lists so again days of unit

of lists so again days of unit

of lists so again days of unit list is this one right here and with

list is this one right here and with

list is this one right here and with index 0 we are accessing the first

index 0 we are accessing the first

index 0 we are accessing the first element

element

element index 1 is the second element and so on

index 1 is the second element and so on

index 1 is the second element and so on and

and

and index is basically just location this is

index is basically just location this is

index is basically just location this is location 0 location

location 0 location

location 0 location 1 and so on so this will give us the

1 and so on so this will give us the

1 and so on so this will give us the first value

first value

first value and obviously the second value is going

and obviously the second value is going

and obviously the second value is going to be with the same syntax with index

to be with the same syntax with index

to be with the same syntax with index one and let's actually print

one and let's actually print

one and let's actually print that one out as well

that one out as well

that one out as well so that we see the results restart the

so that we see the results restart the

so that we see the results restart the application

application

application let's do 20 hours

let's do 20 hours

let's do 20 hours so again this is our list 20

so again this is our list 20

so again this is our list 20 hours as two separate values and this is

hours as two separate values and this is

hours as two separate values and this is a dictionary that we

a dictionary that we

a dictionary that we created using those two values

created using those two values

created using those two values so we have key value pairs basically and

so we have key value pairs basically and

so we have key value pairs basically and the same way

the same way

the same way for minutes we would end up with a

for minutes we would end up with a

for minutes we would end up with a dictionary that looks like this

dictionary that looks like this

dictionary that looks like this so now we have these two pieces of

so now we have these two pieces of

so now we have these two pieces of information in one variable

information in one variable

information in one variable and now we can give that variable to our

and now we can give that variable to our

and now we can give that variable to our function so that it does the validation

function so that it does the validation

function so that it does the validation first of all of the number and

first of all of the number and

first of all of the number and calculation based on the units so

calculation based on the units so

calculation based on the units so on the next line we're going to call our

on the next line we're going to call our

on the next line we're going to call our validate and execute function

validate and execute function

validate and execute function and as you see we have this red line

and as you see we have this red line

and as you see we have this red line here because something

here because something

here because something is wrong first of all we don't have this

is wrong first of all we don't have this

is wrong first of all we don't have this variable called num of days element

variable called num of days element

variable called num of days element anymore

anymore

anymore because we deleted the for loop instead

because we deleted the for loop instead

because we deleted the for loop instead we have days and

we have days and

we have days and unit dictionary and here we are

unit dictionary and here we are

unit dictionary and here we are validating

validating

validating the integer value of the input number

the integer value of the input number

the integer value of the input number and the same way we need to validate

and the same way we need to validate

and the same way we need to validate this input number here

this input number here

this input number here as well so now the question is

as well so now the question is

as well so now the question is how do we access a specific value in

how do we access a specific value in

how do we access a specific value in this case

this case

this case the value of days here in a dictionary

the value of days here in a dictionary

the value of days here in a dictionary because we have to validate this value

because we have to validate this value

because we have to validate this value as well because i might as well

as well because i might as well

as well because i might as well have entered text instead of this number

have entered text instead of this number

have entered text instead of this number so the way to access values

so the way to access values

so the way to access values inside a dictionary is again

inside a dictionary is again

inside a dictionary is again using the square brackets just like we

using the square brackets just like we

using the square brackets just like we did for list

did for list

did for list but instead of an index index 0 or index

but instead of an index index 0 or index

but instead of an index index 0 or index 1 we don't need to use an index because

1 we don't need to use an index because

1 we don't need to use an index because we

we

we actually have a key so instead of index

actually have a key so instead of index

actually have a key so instead of index we're going to

we're going to

we're going to use the key like days or

use the key like days or

use the key like days or unit and this will give us

unit and this will give us

unit and this will give us value of 40 which will then be

value of 40 which will then be

value of 40 which will then be converted into an integer and then

converted into an integer and then

converted into an integer and then validated right here

validated right here

validated right here so again i'm gonna copy this

so again i'm gonna copy this

so again i'm gonna copy this for comparison so to access

for comparison so to access

for comparison so to access an element of a list let's say

an element of a list let's say

an element of a list let's say my list here and let's do

my list here and let's do

my list here and let's do 20 30 doesn't matter in order to access

20 30 doesn't matter in order to access

20 30 doesn't matter in order to access the elements

the elements

the elements of that list

we can do that using an index so this

we can do that using an index so this will basically

will basically

will basically print number 30. again if we had

print number 30. again if we had

print number 30. again if we had other elements here we can do index

other elements here we can do index

other elements here we can do index 2 so that will print out 100 and let's

2 so that will print out 100 and let's

2 so that will print out 100 and let's actually

actually

actually check that and remember to comment out

check that and remember to comment out

check that and remember to comment out a multi-line code we can use

a multi-line code we can use

a multi-line code we can use three quotes at the beginning and at the

three quotes at the beginning and at the

three quotes at the beginning and at the end

end

end let's refresh and there you go 100

let's refresh and there you go 100

let's refresh and there you go 100 was printed let's do the same with the

was printed let's do the same with the

was printed let's do the same with the dictionary

days

days like this and

like this and

like this and to access an element inside

to access an element inside

to access an element inside that dictionary we use the square

that dictionary we use the square

that dictionary we use the square brackets

brackets

brackets and instead of the index like here on

and instead of the index like here on

and instead of the index like here on the list

the list

the list we use the key itself

we use the key itself

we use the key itself and again i'm going to print this

and there you go you see

and there you go you see value 20 and i can also access

value 20 and i can also access

value 20 and i can also access unit value and if i execute it i see

unit value and if i execute it i see

unit value and if i execute it i see hours and so on and i can

hours and so on and i can

hours and so on and i can add any number of key value pairs in my

add any number of key value pairs in my

add any number of key value pairs in my dictionary as i want

dictionary as i want

dictionary as i want so for example i can add a message here

so for example i can add a message here

so for example i can add a message here all good and

all good and

all good and i can access that message

i can access that message

i can access that message like this so this is how you create a

like this so this is how you create a

like this so this is how you create a dictionary and that's how you

dictionary and that's how you

dictionary and that's how you access the values in a list or in a

access the values in a list or in a

access the values in a list or in a dictionary

dictionary

dictionary so let's clean this up

comment in our code again like this

comment in our code again like this and get back to our code

and get back to our code

and get back to our code so basically again this is how we access

so basically again this is how we access

so basically again this is how we access the

the

the number of days in our dictionary and

number of days in our dictionary and

number of days in our dictionary and in our days to units function we need

in our days to units function we need

in our days to units function we need both of those values and we can

both of those values and we can

both of those values and we can pass in those values separately so we

pass in those values separately so we

pass in those values separately so we already have a user input number

already have a user input number

already have a user input number from the dictionary and the second value

from the dictionary and the second value

from the dictionary and the second value would be

the unit from the dictionary

the unit from the dictionary however we have to add that second

however we have to add that second

however we have to add that second parameter to our function

parameter to our function

parameter to our function so let's do that unit

so let's do that unit

so let's do that unit let's call it conversion unit

let's call it conversion unit

let's call it conversion unit so now we are passing both of these

so now we are passing both of these

so now we are passing both of these values

values

values to our function so we have the user

to our function so we have the user

to our function so we have the user input number here

input number here

input number here which is already converted into an

which is already converted into an

which is already converted into an integer

integer

integer and the second one which is the

and the second one which is the

and the second one which is the conversion

conversion

conversion unit and now we can finish

unit and now we can finish

unit and now we can finish the logic in this function here

the logic in this function here

the logic in this function here right now we are using this hard-coded

right now we are using this hard-coded

right now we are using this hard-coded calculation to units which is

calculation to units which is

calculation to units which is 24 and number of units which is

24 and number of units which is

24 and number of units which is hard-coded hours

hard-coded hours

hard-coded hours so first of all i'm going to remove

so first of all i'm going to remove

so first of all i'm going to remove those two we don't need them anymore

those two we don't need them anymore

those two we don't need them anymore because we get those values from the

because we get those values from the

because we get those values from the user

user

user and now we have to substitute

and now we have to substitute

and now we have to substitute those two so here we're going to check

those two so here we're going to check

those two so here we're going to check if the conversion unit is

if the conversion unit is

if the conversion unit is hours

equals hours

equals hours then we're going to return calculation

then we're going to return calculation

then we're going to return calculation with

with

with hours it's going to be 24 and

hours it's going to be 24 and

hours it's going to be 24 and conversion unit here we can also hard

conversion unit here we can also hard

conversion unit here we can also hard code

code

code hours here because we know it's hours

so if the conversion unit is

so if the conversion unit is minutes

calculation for minutes and a text like

calculation for minutes and a text like this

this

this and it could also be that the conversion

and it could also be that the conversion

and it could also be that the conversion unit that was provided

unit that was provided

unit that was provided is none of those or maybe some invalid

is none of those or maybe some invalid

is none of those or maybe some invalid text

text

text and in this case we're gonna add final

and in this case we're gonna add final

and in this case we're gonna add final validation so

validation so

validation so if it's neither hours nor minutes

if it's neither hours nor minutes

if it's neither hours nor minutes then we're just gonna say you know what

then we're just gonna say you know what

then we're just gonna say you know what unsupported

so basically we don't do conversions

so basically we don't do conversions other than those two

other than those two

other than those two so we just tell the user that's an

so we just tell the user that's an

so we just tell the user that's an unsupported unit

unsupported unit

unsupported unit and now if we execute our

and now if we execute our

and now if we execute our program and enter

program and enter

program and enter value there you go we have

value there you go we have

value there you go we have our output and same way if we do

our output and same way if we do

our output and same way if we do 90 days to hours

90 days to hours

90 days to hours we have our calculation in hours so

we have our calculation in hours so

we have our calculation in hours so that's how dictionaries work we can do

that's how dictionaries work we can do

that's how dictionaries work we can do one final thing here and

one final thing here and

one final thing here and as usual print out the type

as usual print out the type

as usual print out the type of our dictionary

and there you go you see class of type

and there you go you see class of type dictionary here

dictionary here

dictionary here which is another data type and at this

which is another data type and at this

which is another data type and at this point we can actually

point we can actually

point we can actually summarize all the data types that we

summarize all the data types that we

summarize all the data types that we have learned so far

have learned so far

have learned so far so let's give us some space here so

so let's give us some space here so

so let's give us some space here so first one was string so basically

first one was string so basically

first one was string so basically a message or some output

that's our string then we have integers

that's our string then we have integers example of that we saw already days

example of that we saw already days

example of that we saw already days then we have float numbers which for

then we have float numbers which for

then we have float numbers which for example can be used for

example can be used for

example can be used for price or

price or

price or weight of a product etc we also have

weight of a product etc we also have

weight of a product etc we also have learned boolean data types when we check

learned boolean data types when we check

learned boolean data types when we check some kind of condition whether if it's

some kind of condition whether if it's

some kind of condition whether if it's true or not

true or not

true or not so for example is it a valid number

or is the user input

or is the user input exit

we also learned a data type of lists

we also learned a data type of lists so for example usage list

so for example usage list

so for example usage list of days

like this including duplicate values

like this including duplicate values and list data type can be used for

and list data type can be used for

and list data type can be used for strings as well

strings as well

strings as well not only for numbers so for example we

not only for numbers so for example we

not only for numbers so for example we can have list of month

can have list of month

can have list of month like january

doesn't really matter we also learned a

doesn't really matter we also learned a data type

data type

data type called set and set basically

called set and set basically

called set and set basically is very similar to list but it doesn't

is very similar to list but it doesn't

is very similar to list but it doesn't allow

allow

allow duplicate values and its syntax is

duplicate values and its syntax is

duplicate values and its syntax is with curly braces so the same way we can

with curly braces so the same way we can

with curly braces so the same way we can have

have

have numbers or strings or booleans or any

numbers or strings or booleans or any

numbers or strings or booleans or any other data types

other data types

other data types inside a set and the last one that we

inside a set and the last one that we

inside a set and the last one that we learned

learned

learned was a dictionary

was a dictionary

was a dictionary and let's take our own example

and let's take our own example

and let's take our own example day in unit

and dictionary is basically a collection

and dictionary is basically a collection of key value pairs and the syntax

of key value pairs and the syntax

of key value pairs and the syntax is written like

is written like

is written like this so why do we need all these

this so why do we need all these

this so why do we need all these different data types

different data types

different data types well depending on the use case or what

well depending on the use case or what

well depending on the use case or what exactly you are trying to achieve in the

exactly you are trying to achieve in the

exactly you are trying to achieve in the program

program

program you're gonna need a different data type

you're gonna need a different data type

you're gonna need a different data type to achieve exactly that

to achieve exactly that

to achieve exactly that so each data type has its own specific

so each data type has its own specific

so each data type has its own specific purpose

purpose

purpose and throughout these days to units

and throughout these days to units

and throughout these days to units calculator i try to

calculator i try to

calculator i try to demonstrate the purpose of each data

demonstrate the purpose of each data

demonstrate the purpose of each data type

type

type and when we need to use them so these

and when we need to use them so these

and when we need to use them so these are all the data types that we learned

are all the data types that we learned

are all the data types that we learned these are also

these are also

these are also most of the data types available in

most of the data types available in

most of the data types available in python and the main ones

python and the main ones

python and the main ones that you're going to be working with so

that you're going to be working with so

that you're going to be working with so this should give you a good foundational

this should give you a good foundational

this should give you a good foundational knowledge about data types

knowledge about data types

knowledge about data types in python and also note that most of

in python and also note that most of

in python and also note that most of these data

these data

these data types you will also encounter in any

types you will also encounter in any

types you will also encounter in any other programming languages

other programming languages

other programming languages because as i said these are the core

because as i said these are the core

because as i said these are the core data types and most of the programming

data types and most of the programming

data types and most of the programming languages actually support these data

languages actually support these data

languages actually support these data types as well

types as well

types as well till now we have been writing all our

till now we have been writing all our

till now we have been writing all our code

code

code in one single file so basically we have

in one single file so basically we have

in one single file so basically we have a project

a project

a project with just one python file and we're

with just one python file and we're

with just one python file and we're writing all the logic

writing all the logic

writing all the logic inside that file however you can imagine

inside that file however you can imagine

inside that file however you can imagine that

that

that if you're writing a little bit more

if you're writing a little bit more

if you're writing a little bit more complex applications

complex applications

complex applications that have much more complex logic so

that have much more complex logic so

that have much more complex logic so they end up having

they end up having

they end up having lots of functions obviously you're gonna

lots of functions obviously you're gonna

lots of functions obviously you're gonna end up with a python file that has

end up with a python file that has

end up with a python file that has hundreds of lines of code maybe

hundreds of lines of code maybe

hundreds of lines of code maybe thousands of lines of code

thousands of lines of code

thousands of lines of code and it's not very practical to manage

and it's not very practical to manage

and it's not very practical to manage all this logic and all this code in just

all this logic and all this code in just

all this logic and all this code in just one file so instead you need to

one file so instead you need to

one file so instead you need to structure your

structure your

structure your code and divide your logic between

code and divide your logic between

code and divide your logic between multiple different python files and you

multiple different python files and you

multiple different python files and you do that

do that

do that with modules to give an example

with modules to give an example

with modules to give an example imagine a web application that has

imagine a web application that has

imagine a web application that has basically many features like facebook

basically many features like facebook

basically many features like facebook for example

for example

for example obviously you can put all the facebook

obviously you can put all the facebook

obviously you can put all the facebook logic in

logic in

logic in one single python file right you will

one single python file right you will

one single python file right you will have a structure

have a structure

have a structure of facebook project with subfolders in

of facebook project with subfolders in

of facebook project with subfolders in your project

your project

your project which all contain multiple python files

which all contain multiple python files

which all contain multiple python files so you would have

so you would have

so you would have maybe packages for each feature

maybe packages for each feature

maybe packages for each feature and each such feature has a lot of

and each such feature has a lot of

and each such feature has a lot of functionalities

functionalities

functionalities so they will be all grouped then again

so they will be all grouped then again

so they will be all grouped then again in multiple

in multiple

in multiple python files right so you would end up

python files right so you would end up

python files right so you would end up with

with

with a project with a hierarchy of folders

a project with a hierarchy of folders

a project with a hierarchy of folders and lots of lots of python files inside

and lots of lots of python files inside

and lots of lots of python files inside now the question is if i

now the question is if i

now the question is if i have multiple python files in my project

have multiple python files in my project

have multiple python files in my project how do i connect them together so for

how do i connect them together so for

how do i connect them together so for example if i have

example if i have

example if i have another file here and let's call it

another file here and let's call it

another file here and let's call it helper

helper

helper dot py

dot py

dot py and if i have some logic here basically

and if i have some logic here basically

and if i have some logic here basically functions defined here how do i use them

functions defined here how do i use them

functions defined here how do i use them or how do i reference them

or how do i reference them

or how do i reference them in another file and the way it works in

in another file and the way it works in

in another file and the way it works in python is using the concept

python is using the concept

python is using the concept called modules so a module is basically

called modules so a module is basically

called modules so a module is basically a python file that contains

a python file that contains

a python file that contains functions or variables that

functions or variables that

functions or variables that you can use in another python file

you can use in another python file

you can use in another python file so basically any python file that you

so basically any python file that you

so basically any python file that you have in your project

have in your project

have in your project both of these in this case are modules

both of these in this case are modules

both of these in this case are modules and you can reference

and you can reference

and you can reference one module from another so basically

one module from another so basically

one module from another so basically the idea is that you can structure your

the idea is that you can structure your

the idea is that you can structure your application

application

application your program using modules so you can

your program using modules so you can

your program using modules so you can make your project

make your project

make your project modular so in this part we're going to

modular so in this part we're going to

modular so in this part we're going to create our own module

create our own module

create our own module in helper file and we're going to

in helper file and we're going to

in helper file and we're going to reference that in main dot

reference that in main dot

reference that in main dot python

python

python and let's say in main.python i only want

and let's say in main.python i only want

and let's say in main.python i only want the code

the code

the code that basically starts the program right

that basically starts the program right

that basically starts the program right all the functions

all the functions

all the functions all the logic i kind of want it hidden

all the logic i kind of want it hidden

all the logic i kind of want it hidden away

away

away and grouped together in a separate file

and grouped together in a separate file

and grouped together in a separate file so what we're going to do is copy this

so what we're going to do is copy this

so what we're going to do is copy this entire thing

entire thing

entire thing so both of these functions basically and

so both of these functions basically and

so both of these functions basically and paste it in here so now you already see

paste it in here so now you already see

paste it in here so now you already see a couple of

a couple of

a couple of red lines here because now the reference

red lines here because now the reference

red lines here because now the reference is obviously broken right

is obviously broken right

is obviously broken right so main.python obviously doesn't know

so main.python obviously doesn't know

so main.python obviously doesn't know anything about

anything about

anything about validate and execute function right it

validate and execute function right it

validate and execute function right it says unresolved

says unresolved

says unresolved reference and the same way face to unit

reference and the same way face to unit

reference and the same way face to unit dictionary is unresolved for helper

dictionary is unresolved for helper

dictionary is unresolved for helper because it doesn't know anything about

because it doesn't know anything about

because it doesn't know anything about main.python and the variables defined

main.python and the variables defined

main.python and the variables defined right here so the first thing we need to

right here so the first thing we need to

right here so the first thing we need to do is we need to tell

do is we need to tell

do is we need to tell main note python file where to find this

main note python file where to find this

main note python file where to find this validate and

validate and

validate and execute function right we have defined

execute function right we have defined

execute function right we have defined it in helper python so

it in helper python so

it in helper python so that's what we need to define how we

that's what we need to define how we

that's what we need to define how we do that is using something called an

do that is using something called an

do that is using something called an import

import

import statement so we basically import

statement so we basically import

statement so we basically import this whole helper.pi module

this whole helper.pi module

this whole helper.pi module inside main.python and we do that

inside main.python and we do that

inside main.python and we do that very simply using import

very simply using import

very simply using import helper right helper is the name of the

helper right helper is the name of the

helper right helper is the name of the file

file

file and therefore name of the module and

and therefore name of the module and

and therefore name of the module and right now it's grey because we're not

right now it's grey because we're not

right now it's grey because we're not using it

using it

using it and the way to use it is helper dot

and the way to use it is helper dot

and the way to use it is helper dot and the function name and you see the

and the function name and you see the

and the function name and you see the red line disappeared

red line disappeared

red line disappeared so again what we did is we told

so again what we did is we told

so again what we did is we told main.python

main.python

main.python there is a helper module in this project

there is a helper module in this project

there is a helper module in this project and please import this whole module

and please import this whole module

and please import this whole module and all the functions that this module

and all the functions that this module

and all the functions that this module has and make it available

has and make it available

has and make it available in main.pi and then once we have that

in main.pi and then once we have that

in main.pi and then once we have that helper module

helper module

helper module we can reference any functions if we had

we can reference any functions if we had

we can reference any functions if we had any variables

any variables

any variables using module name dot

using module name dot

using module name dot function so this has to be the name and

function so this has to be the name and

function so this has to be the name and if i hover over it you see that pycharm

if i hover over it you see that pycharm

if i hover over it you see that pycharm actually displays the whole path

actually displays the whole path

actually displays the whole path to that helper.pi file

to that helper.pi file

to that helper.pi file and now note that here we still have

and now note that here we still have

and now note that here we still have redline

redline

redline because this is a variable which is

because this is a variable which is

because this is a variable which is defined in main

defined in main

defined in main dot pi but a helper module doesn't know

dot pi but a helper module doesn't know

dot pi but a helper module doesn't know anything about it and that's an

anything about it and that's an

anything about it and that's an important distinction here

important distinction here

important distinction here because we imported helper module inside

because we imported helper module inside

because we imported helper module inside main

main

main so helper modules functions are

so helper modules functions are

so helper modules functions are available here but not the other way

available here but not the other way

available here but not the other way so in order to make this dictionary

so in order to make this dictionary

so in order to make this dictionary available

available

available invalidate and execute function we would

invalidate and execute function we would

invalidate and execute function we would need to

need to

need to pass it in as a variable like this

pass it in as a variable like this

pass it in as a variable like this and this will work now now

and this will work now now

and this will work now now note that in main.python

note that in main.python

note that in main.python we actually only need this validate and

we actually only need this validate and

we actually only need this validate and execute function

execute function

execute function we don't need the days to units function

we don't need the days to units function

we don't need the days to units function because

because

because this function is only used by validate

this function is only used by validate

this function is only used by validate and execute function

and execute function

and execute function so that means that we don't need to

so that means that we don't need to

so that means that we don't need to import the whole entire module inside

import the whole entire module inside

import the whole entire module inside main.pi

main.pi

main.pi we actually only need the validated

we actually only need the validated

we actually only need the validated execute function

execute function

execute function and this is a small example but if you

and this is a small example but if you

and this is a small example but if you had a module with

had a module with

had a module with 20 30 functions and you just needed one

20 30 functions and you just needed one

20 30 functions and you just needed one of them

of them

of them you wouldn't need to import the whole

you wouldn't need to import the whole

you wouldn't need to import the whole module just for that one function

module just for that one function

module just for that one function so what you could do is you can pick and

so what you could do is you can pick and

so what you could do is you can pick and choose which

choose which

choose which specific functions you want to

specific functions you want to

specific functions you want to make available inside another file

make available inside another file

make available inside another file or another module and you can do that

or another module and you can do that

or another module and you can do that very easily

very easily

very easily using the following syntax we say from

using the following syntax we say from

using the following syntax we say from helper that's the module again import

helper that's the module again import

helper that's the module again import and the name of the function

like this and now because we are

like this and now because we are accessing

accessing

accessing and importing that specific function we

and importing that specific function we

and importing that specific function we don't need

don't need

don't need to use module name anymore we have that

to use module name anymore we have that

to use module name anymore we have that function

function

function available directly so we can delete the

available directly so we can delete the

available directly so we can delete the module

module

module reference here and we have that function

reference here and we have that function

reference here and we have that function available

available

available like this so again instead of having

like this so again instead of having

like this so again instead of having entire

entire

entire helper module with all of its functions

helper module with all of its functions

helper module with all of its functions and

and

and other stuff we only have one specific

other stuff we only have one specific

other stuff we only have one specific function

function

function available here so that means we wouldn't

available here so that means we wouldn't

available here so that means we wouldn't be able to use

be able to use

be able to use these two units for example now we saw

these two units for example now we saw

these two units for example now we saw an example

an example

an example of a module that has just functions

of a module that has just functions

of a module that has just functions right

right

right however module can have many other stuff

however module can have many other stuff

however module can have many other stuff for example

for example

for example variables and you can make those

variables and you can make those

variables and you can make those variables also available

variables also available

variables also available for another program and that's an

for another program and that's an

for another program and that's an example here

example here

example here i'm going to create a variable called

i'm going to create a variable called

i'm going to create a variable called user input

message

message and this is our user input message and

and this is our user input message and

and this is our user input message and we can actually

we can actually

we can actually put it into a variable instead of having

put it into a variable instead of having

put it into a variable instead of having it defined like that

it defined like that

it defined like that so i'm going to copy it

so i'm going to copy it

so i'm going to copy it and paste it here so now we have

and paste it here so now we have

and paste it here so now we have the user input in a variable in another

the user input in a variable in another

the user input in a variable in another file

file

file again how do we access it in main dot pi

again how do we access it in main dot pi

again how do we access it in main dot pi in this statement at the top we can

in this statement at the top we can

in this statement at the top we can actually import

actually import

actually import several things from a module

several things from a module

several things from a module right now we are importing a function we

right now we are importing a function we

right now we are importing a function we can also

can also

can also import our variable and we can do that

import our variable and we can do that

import our variable and we can do that also very easily

also very easily

also very easily like this and we can use that

like this and we can use that

like this and we can use that user input message here so basically if

user input message here so basically if

user input message here so basically if you have

you have

you have again 20 functions and variables

again 20 functions and variables

again 20 functions and variables from a module and you just need maybe

from a module and you just need maybe

from a module and you just need maybe five of them

five of them

five of them you can import them individually

you can import them individually

you can import them individually like this just basically just list the

like this just basically just list the

like this just basically just list the names

names

names of functions and variables what you can

of functions and variables what you can

of functions and variables what you can also do

also do

also do is import all this is what this

is import all this is what this

is import all this is what this asterisk sign represents so we're

asterisk sign represents so we're

asterisk sign represents so we're basically importing

basically importing

basically importing everything from the helper module again

everything from the helper module again

everything from the helper module again this is kind of a waste if you just need

this is kind of a waste if you just need

this is kind of a waste if you just need a couple of

a couple of

a couple of functions and variables from that module

functions and variables from that module

functions and variables from that module and not the entire thing

and not the entire thing

and not the entire thing however with this syntax you can import

however with this syntax you can import

however with this syntax you can import everything

everything

everything and now you may be wondering what is a

and now you may be wondering what is a

and now you may be wondering what is a difference between

difference between

difference between importing everything from the module and

importing everything from the module and

importing everything from the module and importing the whole module

importing the whole module

importing the whole module because in both cases you have

because in both cases you have

because in both cases you have everything in the module available

everything in the module available

everything in the module available the difference is in the syntax because

the difference is in the syntax because

the difference is in the syntax because note that if we

note that if we

note that if we use this from import statement

use this from import statement

use this from import statement you don't need to use name of the module

you don't need to use name of the module

you don't need to use name of the module every time you're

every time you're

every time you're accessing something defined in that

accessing something defined in that

accessing something defined in that module right

module right

module right so we don't need to do helper dot

so we don't need to do helper dot

so we don't need to do helper dot function name or helper dot

function name or helper dot

function name or helper dot variable name whereas if we imported

variable name whereas if we imported

variable name whereas if we imported the module like this you see

the module like this you see

the module like this you see we have red lines because we would need

we have red lines because we would need

we have red lines because we would need to do

to do

to do helper dot or module name dot

helper dot or module name dot

helper dot or module name dot whenever we use something from the

whenever we use something from the

whenever we use something from the module now this could be

module now this could be

module now this could be a matter of taste so basically which one

a matter of taste so basically which one

a matter of taste so basically which one you want to use i personally think that

you want to use i personally think that

you want to use i personally think that this is the most efficient and also

this is the most efficient and also

this is the most efficient and also cleaner way of

cleaner way of

cleaner way of using specific functions variables etc

using specific functions variables etc

using specific functions variables etc defined in a module

defined in a module

defined in a module and as a side note the things that are

and as a side note the things that are

and as a side note the things that are defined in a module

defined in a module

defined in a module that you can use basically in another

that you can use basically in another

that you can use basically in another file are called

file are called

file are called definitions so all these those three

definitions so all these those three

definitions so all these those three elements here

elements here

elements here are definitions of a module and you can

are definitions of a module and you can

are definitions of a module and you can use

use

use any of those definitions in a file where

any of those definitions in a file where

any of those definitions in a file where you

you

you import that module what you can also do

import that module what you can also do

import that module what you can also do when importing a module

when importing a module

when importing a module is you can rename that module basically

is you can rename that module basically

is you can rename that module basically to

to

to whatever you want so if the name of the

whatever you want so if the name of the

whatever you want so if the name of the module

module

module is too long or you just want to use a

is too long or you just want to use a

is too long or you just want to use a different name

different name

different name you can do as and then basically write a

you can do as and then basically write a

you can do as and then basically write a name whatever you want

name whatever you want

name whatever you want like h for example and then obviously

like h for example and then obviously

like h for example and then obviously you need to use that

you need to use that

you need to use that new name everywhere you access

new name everywhere you access

new name everywhere you access functions or variables of that module

functions or variables of that module

functions or variables of that module so basically how you import a module and

so basically how you import a module and

so basically how you import a module and whether you rename it

whether you rename it

whether you rename it is a matter of taste basically how you

is a matter of taste basically how you

is a matter of taste basically how you want

want

want to do that in your code

to do that in your code

to do that in your code however i think that importing specific

however i think that importing specific

however i think that importing specific elements from a module like this is

elements from a module like this is

elements from a module like this is most efficient and also cleanest way to

most efficient and also cleanest way to

most efficient and also cleanest way to do that

do that

do that so we saw how to create our own module

so we saw how to create our own module

so we saw how to create our own module and use it in another file so basically

and use it in another file so basically

and use it in another file so basically if you had hundred python files here

if you had hundred python files here

if you had hundred python files here with each one of them having their own

with each one of them having their own

with each one of them having their own functions and variables you can cross

functions and variables you can cross

functions and variables you can cross reference them from each other using

reference them from each other using

reference them from each other using the import statement very easily

now in addition to creating your own

now in addition to creating your own modules

modules

modules we can actually use modules that python

we can actually use modules that python

we can actually use modules that python itself already includes so just like we

itself already includes so just like we

itself already includes so just like we used some

used some

used some functions that python gives us out of

functions that python gives us out of

functions that python gives us out of the box

the box

the box like inputs or ins so basically all of

like inputs or ins so basically all of

like inputs or ins so basically all of those

those

those the same way python also gives us

the same way python also gives us

the same way python also gives us modules

modules

modules for different scenarios so that we don't

for different scenarios so that we don't

for different scenarios so that we don't have to write this logic

have to write this logic

have to write this logic ourselves and there are a lot of useful

ourselves and there are a lot of useful

ourselves and there are a lot of useful modules that python actually includes

modules that python actually includes

modules that python actually includes for example math module for mathematical

for example math module for mathematical

for example math module for mathematical operations

operations

operations its own module for working with dates or

its own module for working with dates or

its own module for working with dates or date times

date times

date times module for working with specific files

module for working with specific files

module for working with specific files and so on so basically

and so on so basically

and so on so basically for many different use cases python

for many different use cases python

for many different use cases python already gives you

already gives you

already gives you ready modules and these modules will

ready modules and these modules will

ready modules and these modules will then contain multiple functions

then contain multiple functions

then contain multiple functions and variables for that specific use case

and variables for that specific use case

and variables for that specific use case again if we take an example of a date

again if we take an example of a date

again if we take an example of a date so if you have an application that works

so if you have an application that works

so if you have an application that works with dates

with dates

with dates and times you have this module from a

and times you have this module from a

and times you have this module from a python

python

python that gives you a bunch of useful

that gives you a bunch of useful

that gives you a bunch of useful functions

functions

functions for working with dates and again this

for working with dates and again this

for working with dates and again this means you don't have to write this logic

means you don't have to write this logic

means you don't have to write this logic yourself but rather use the existing one

yourself but rather use the existing one

yourself but rather use the existing one so to give you some examples of modules

so to give you some examples of modules

so to give you some examples of modules that

that

that python provides us with for example if

python provides us with for example if

python provides us with for example if you want to

you want to

you want to work with operating system there is an

work with operating system there is an

work with operating system there is an os

os

os module so

module so

module so we can print out we can get the name

we can print out we can get the name

we can print out we can get the name of the os for example

and run and you see the name of the os

and run and you see the name of the os another useful module python offers is

another useful module python offers is

another useful module python offers is logging so if you want to use logging in

logging so if you want to use logging in

logging so if you want to use logging in your application

your application

your application the logging module gives you different

the logging module gives you different

the logging module gives you different functions to log

functions to log

functions to log an error message or warning etc

an error message or warning etc

an error message or warning etc as well as basically just configure how

as well as basically just configure how

as well as basically just configure how the login will look like

the login will look like

the login will look like again to see an example

again to see an example

again to see an example again it may look a little bit complex

again it may look a little bit complex

again it may look a little bit complex here but essentially

here but essentially

here but essentially just using the name of the module and

just using the name of the module and

just using the name of the module and then functions that

then functions that

then functions that it gives you obviously you need to know

it gives you obviously you need to know

it gives you obviously you need to know the functions

the functions

the functions and you need to know how to use them and

and you need to know how to use them and

and you need to know how to use them and you can get that information from

you can get that information from

you can get that information from documentation

documentation

documentation or if you're using pycharm

or if you're using pycharm

or if you're using pycharm it actually gives you all the

it actually gives you all the

it actually gives you all the information about these functions and

information about these functions and

information about these functions and the module

the module

the module if you just hover on it so you don't

if you just hover on it so you don't

if you just hover on it so you don't even need to

even need to

even need to google or check out the documentation

google or check out the documentation

google or check out the documentation and basically we're

and basically we're

and basically we're creating a logger and we're logging an

creating a logger and we're logging an

creating a logger and we're logging an error message

error message

error message so if i execute this now and here you

so if i execute this now and here you

so if i execute this now and here you see

see

see the output of the logger error happened

the output of the logger error happened

the output of the logger error happened in the app and logging in application is

in the app and logging in application is

in the app and logging in application is actually

actually

actually a very important feature so that's why

a very important feature so that's why

a very important feature so that's why logging module is available

logging module is available

logging module is available by default in python any use case

by default in python any use case

by default in python any use case in our application would be right here

in our application would be right here

in our application would be right here if an

if an

if an error happened for example instead of

error happened for example instead of

error happened for example instead of using a print basically just

using a print basically just

using a print basically just log and error so these were just

log and error so these were just

log and error so these were just some basic examples but as i said python

some basic examples but as i said python

some basic examples but as i said python comes

comes

comes with lots of very useful modules that

with lots of very useful modules that

with lots of very useful modules that you can

you can

you can use in your applications for different

use in your applications for different

use in your applications for different use cases

use cases

use cases and that of course makes your work

and that of course makes your work

and that of course makes your work easier

easier

easier because you can just use the logic

because you can just use the logic

because you can just use the logic instead of having to write it

instead of having to write it

instead of having to write it yourself in the modules that are part of

yourself in the modules that are part of

yourself in the modules that are part of python so that you can import them like

python so that you can import them like

python so that you can import them like this

this

this directly are called built-in modules we

directly are called built-in modules we

directly are called built-in modules we learned about built-in functions

learned about built-in functions

learned about built-in functions so these are the functions that python

so these are the functions that python

so these are the functions that python makes available to us

makes available to us

makes available to us directly and there are built-in modules

directly and there are built-in modules

directly and there are built-in modules that we get from python

that we get from python

that we get from python and by the way if you're wondering where

and by the way if you're wondering where

and by the way if you're wondering where this module actually comes from so where

this module actually comes from so where

this module actually comes from so where is the physical location

is the physical location

is the physical location on our machine or where this module

on our machine or where this module

on our machine or where this module files actually

files actually

files actually leave if you're using pycharm you can

leave if you're using pycharm you can

leave if you're using pycharm you can actually hover

actually hover

actually hover over it and hold down a control key or

over it and hold down a control key or

over it and hold down a control key or if you're a mac

if you're a mac

if you're a mac command key and click inside

command key and click inside

command key and click inside you see the file opens up which is the

you see the file opens up which is the

you see the file opens up which is the module the logging module

module the logging module

module the logging module since i said module is basically just a

since i said module is basically just a

since i said module is basically just a python file that has

python file that has

python file that has multiple functions variables etc

multiple functions variables etc

multiple functions variables etc available and you see right here

available and you see right here

available and you see right here on this top line the whole path

on this top line the whole path

on this top line the whole path for that python file so that's the

for that python file so that's the

for that python file so that's the location

location

location of that module file locally on my

of that module file locally on my

of that module file locally on my computer

computer

computer and inside this python file basically

and inside this python file basically

and inside this python file basically you again have python code

you again have python code

you again have python code and if we look for get logger function

and if we look for get logger function

and if we look for get logger function here like this

right here you will find the definition

right here you will find the definition of that function right so somebody

of that function right so somebody

of that function right so somebody implemented this function

implemented this function

implemented this function and called it get logger

and this is basically the logic all the

and this is basically the logic all the things that get

things that get

things that get executed behind the scenes and

executed behind the scenes and

executed behind the scenes and you as a user of python basically can

you as a user of python basically can

you as a user of python basically can use the name of the function

use the name of the function

use the name of the function and write your own programs with it

and write your own programs with it

and write your own programs with it and let's also look for error

and let's also look for error

and let's also look for error and there you go we have error function

and there you go we have error function

and there you go we have error function as well right here

as well right here

as well right here and obviously this is a more complex

and obviously this is a more complex

and obviously this is a more complex code here

code here

code here than what we write but just

than what we write but just

than what we write but just to give you an idea that this is

to give you an idea that this is

to give you an idea that this is actually a file on your machine

actually a file on your machine

actually a file on your machine that comes with the python version that

that comes with the python version that

that comes with the python version that you

you

you install locally and all the functions

install locally and all the functions

install locally and all the functions are defined already there by python

are defined already there by python

are defined already there by python developers

developers

developers and you can just use them like this

and you can just use them like this

and you can just use them like this without worrying about

without worrying about

without worrying about how the logic is actually implemented

how the logic is actually implemented

how the logic is actually implemented and another interesting thing is if i

and another interesting thing is if i

and another interesting thing is if i click here

click here

click here in this python 3.9

in this python 3.9

in this python 3.9 like this logging is basically one

like this logging is basically one

like this logging is basically one module

module

module that we used and here you will see

that we used and here you will see

that we used and here you will see the list of the complete list of all the

the list of the complete list of all the

the list of the complete list of all the built-in modules

built-in modules

built-in modules that you get from python so some of them

that you get from python so some of them

that you get from python so some of them are folders

are folders

are folders like logging for example email and bunch

like logging for example email and bunch

like logging for example email and bunch of other stuff

of other stuff

of other stuff and the operating system module for

and the operating system module for

and the operating system module for example that we used

example that we used

example that we used is a python file then you can find

is a python file then you can find

is a python file then you can find right here so these are the built-in

right here so these are the built-in

right here so these are the built-in modules

so now that we know what built-in

so now that we know what built-in modules are and how to use them

modules are and how to use them

modules are and how to use them let's actually see a realistic example

let's actually see a realistic example

let's actually see a realistic example and

and

and also write a little more interesting

also write a little more interesting

also write a little more interesting application using

application using

application using built-in module

so what i'm going to do is in my python

so what i'm going to do is in my python project i'm going to create a new file

project i'm going to create a new file

project i'm going to create a new file and i'm going to call this time to

and i'm going to call this time to

and i'm going to call this time to deadline dot pi y

deadline dot pi y

deadline dot pi y and we're going to write an application

and we're going to write an application

and we're going to write an application that basically accepts a user input

that basically accepts a user input

that basically accepts a user input of a goal and a date like a deadline

of a goal and a date like a deadline

of a goal and a date like a deadline date

date

date and then we're going to print out back

and then we're going to print out back

and then we're going to print out back to the user

to the user

to the user how much time it is remaining till that

how much time it is remaining till that

how much time it is remaining till that deadline

deadline

deadline and that deadline will be a date right

and that deadline will be a date right

and that deadline will be a date right some date in the future so that means

some date in the future so that means

some date in the future so that means that we're going to be working with

that we're going to be working with

that we're going to be working with dates

and in order to work with dates we are

and in order to work with dates we are going to need

going to need

going to need python's built-in module that allows us

python's built-in module that allows us

python's built-in module that allows us to call functions and do some processing

to call functions and do some processing

to call functions and do some processing and stuff

and stuff

and stuff on date values and that module

on date values and that module

on date values and that module is called date time so

is called date time so

is called date time so import date time

import date time

import date time so let's have that import statement

so let's have that import statement

so let's have that import statement right there and we're going to use it

right there and we're going to use it

right there and we're going to use it in our program so the first thing we

in our program so the first thing we

in our program so the first thing we want to do is

want to do is

want to do is let the user give us an input about

let the user give us an input about

let the user give us an input about their goal

their goal

their goal and a date or deadline for that goal

and a date or deadline for that goal

and a date or deadline for that goal so let's do that first

so let's do that first

so let's do that first we already know how to ask for user

we already know how to ask for user

we already know how to ask for user input

input

input with a message so we're gonna say enter

with a message so we're gonna say enter

with a message so we're gonna say enter your goal with a deadline

your goal with a deadline

your goal with a deadline separated by colon and we also know this

separated by colon and we also know this

separated by colon and we also know this already

already

already basically what we want to do is user to

basically what we want to do is user to

basically what we want to do is user to be able to

be able to

be able to enter their goal like learn python

enter their goal like learn python

enter their goal like learn python column and a date and let's say

column and a date and let's say

column and a date and let's say again this is totally up to us to decide

again this is totally up to us to decide

again this is totally up to us to decide we're the ones basically setting the

we're the ones basically setting the

we're the ones basically setting the rules here so let's say we want the date

rules here so let's say we want the date

rules here so let's say we want the date to be entered in following format

to be entered in following format

to be entered in following format day month

day month

day month and a full year like this

and a full year like this

and a full year like this so that's the format that we're looking

so that's the format that we're looking

so that's the format that we're looking for and this is how user

for and this is how user

for and this is how user should input the value otherwise with a

should input the value otherwise with a

should input the value otherwise with a different format it's not going to work

different format it's not going to work

different format it's not going to work so we're going to save that input value

so we're going to save that input value

so we're going to save that input value into a variable

into a variable

into a variable let's call it user input

so we have the user input let's do the

so we have the user input let's do the split again

split again

split again on a colon remember we have this whole

on a colon remember we have this whole

on a colon remember we have this whole thing as a string as one

thing as a string as one

thing as a string as one string so we want to split it into two

string so we want to split it into two

string so we want to split it into two parts

parts

parts so we have the goal here and the

so we have the goal here and the

so we have the goal here and the deadline and this will give

deadline and this will give

deadline and this will give us a list with those two values

us a list with those two values

us a list with those two values and let's call it input list

and let's call it input list

and let's call it input list and now from that list we can actually

and now from that list we can actually

and now from that list we can actually extract

extract

extract or get those individual values using

or get those individual values using

or get those individual values using a list syntax so accessing the elements

a list syntax so accessing the elements

a list syntax so accessing the elements from a list

from a list

from a list which is what we learned already using

which is what we learned already using

which is what we learned already using an index

an index

an index right so we have input list index

right so we have input list index

right so we have input list index 0 which is going to give us learn python

0 which is going to give us learn python

0 which is going to give us learn python and let's save it as a goal variable

and let's save it as a goal variable

and let's save it as a goal variable and let's create another variable which

and let's create another variable which

and let's create another variable which is going to be

is going to be

is going to be date let's call it deadline

and this will be the second

and this will be the second value in our list now

value in our list now

value in our list now let's actually print this out

now note that we are actually in a

now note that we are actually in a different file we're not in the main.pi

different file we're not in the main.pi

different file we're not in the main.pi anymore and we don't want to execute

anymore and we don't want to execute

anymore and we don't want to execute main

main

main python file instead we want to execute

python file instead we want to execute

python file instead we want to execute this one right here we basically just

this one right here we basically just

this one right here we basically just want to ignore everything else in this

want to ignore everything else in this

want to ignore everything else in this project

project

project so how do i go from main to this file

so how do i go from main to this file

so how do i go from main to this file execution

execution

execution very easy in this editor just to right

very easy in this editor just to right

very easy in this editor just to right click

click

click and you see here run time till deadline

and you see here run time till deadline

and you see here run time till deadline and i'm going to execute this everything

and i'm going to execute this everything

and i'm going to execute this everything else is ignored in the project we are

else is ignored in the project we are

else is ignored in the project we are basically just working on this one right

basically just working on this one right

basically just working on this one right here

here

here so enter your goal with the deadline

so enter your goal with the deadline

so enter your goal with the deadline separated by colon

separated by colon

separated by colon let's do that i'm going to do pi learn

let's do that i'm going to do pi learn

let's do that i'm going to do pi learn python

python

python colon and then

let's enter some date and

let's enter some date and enter and this is the output so we

enter and this is the output so we

enter and this is the output so we basically split that into

basically split that into

basically split that into two values and put it in a list right

two values and put it in a list right

two values and put it in a list right here

here

here and very important to note here that

and very important to note here that

and very important to note here that both of these elements in this list

both of these elements in this list

both of these elements in this list are strings because again user input is

are strings because again user input is

are strings because again user input is always

always

always interpreted as strings so this was a

interpreted as strings so this was a

interpreted as strings so this was a string and it was split into two strings

string and it was split into two strings

string and it was split into two strings which are learn python and this date

which are learn python and this date

which are learn python and this date here

here

here however we don't want date or deadline

however we don't want date or deadline

however we don't want date or deadline as a string we want deadline as a date

as a string we want deadline as a date

as a string we want deadline as a date and exactly for that functionality we

and exactly for that functionality we

and exactly for that functionality we need

need

need this date time module because we don't

this date time module because we don't

this date time module because we don't want to implement it ourselves

want to implement it ourselves

want to implement it ourselves we want python to give us a ready

we want python to give us a ready

we want python to give us a ready function

function

function from a module that will basically just

from a module that will basically just

from a module that will basically just let us convert this string

let us convert this string

let us convert this string into a date value and converting string

into a date value and converting string

into a date value and converting string to date is just one example usage of

to date is just one example usage of

to date is just one example usage of date time module but you can use this

date time module but you can use this

date time module but you can use this module to work with dates

module to work with dates

module to work with dates generally like creating new dates

generally like creating new dates

generally like creating new dates formatting the dates updating the value

formatting the dates updating the value

formatting the dates updating the value etc

etc

etc and we're gonna see some of those

and we're gonna see some of those

and we're gonna see some of those examples in this section

examples in this section

examples in this section now if you're learning this type of

now if you're learning this type of

now if you're learning this type of thing alone you don't have

thing alone you don't have

thing alone you don't have me basically teaching you and giving you

me basically teaching you and giving you

me basically teaching you and giving you an example the way you would do that

an example the way you would do that

an example the way you would do that is you would basically research and

is you would basically research and

is you would basically research and maybe google how this is done

maybe google how this is done

maybe google how this is done in python and you would basically see

in python and you would basically see

in python and you would basically see some examples

some examples

some examples of using this date time and what the

of using this date time and what the

of using this date time and what the name of this function is and how to use

name of this function is and how to use

name of this function is and how to use that

that

that as well as each module has its own

as well as each module has its own

as well as each module has its own documentation page

documentation page

documentation page where you can look up the syntax and

where you can look up the syntax and

where you can look up the syntax and usage examples

usage examples

usage examples because obviously you're not going to

because obviously you're not going to

because obviously you're not going to know how to do that

know how to do that

know how to do that by yourself so the way we convert a

by yourself so the way we convert a

by yourself so the way we convert a string

string

string into a date using this date

into a date using this date

into a date using this date time module is on this datetime module

time module is on this datetime module

time module is on this datetime module if i type in dot

if i type in dot

if i type in dot i will see a list of all the definitions

i will see a list of all the definitions

i will see a list of all the definitions that daytime module gives me right

that daytime module gives me right

that daytime module gives me right so i have date daytime time etc

so i have date daytime time etc

so i have date daytime time etc the one that we need is date time

the one that we need is date time

the one that we need is date time because the function

because the function

because the function that we need for conversion is inside

that we need for conversion is inside

that we need for conversion is inside that definition and don't be confused

that definition and don't be confused

that definition and don't be confused here because we have date time twice

here because we have date time twice

here because we have date time twice here

here

here the first one is a module and the second

the first one is a module and the second

the first one is a module and the second one is a definition in that module and

one is a definition in that module and

one is a definition in that module and we can actually check that as well

we can actually check that as well

we can actually check that as well so if i jump into this date time module

so if i jump into this date time module

so if i jump into this date time module and inside that if i look for

and inside that if i look for

and inside that if i look for date time again so right here you see

date time again so right here you see

date time again so right here you see this

this

this date time definition and on that daytime

date time definition and on that daytime

date time definition and on that daytime definition

definition

definition we have now functions that we can use

we have now functions that we can use

we have now functions that we can use and as you see this is not a function or

and as you see this is not a function or

and as you see this is not a function or variable

variable

variable it says class here which is another

it says class here which is another

it says class here which is another concept in programming

concept in programming

concept in programming we're gonna see later so just for now

we're gonna see later so just for now

we're gonna see later so just for now think about this as a container of

think about this as a container of

think about this as a container of functions

functions

functions and variables inside that module

and variables inside that module

and variables inside that module and that's why we have to access it like

and that's why we have to access it like

and that's why we have to access it like this

this

this and then on that daytime definition this

and then on that daytime definition this

and then on that daytime definition this class

class

class we now have functions that we can use to

we now have functions that we can use to

we now have functions that we can use to do the conversion

do the conversion

do the conversion so the function we need is called str

so the function we need is called str

so the function we need is called str so string p time and this function will

so string p time and this function will

so string p time and this function will take a string

take a string

take a string representation of a date and we'll

representation of a date and we'll

representation of a date and we'll convert it into a date format

convert it into a date format

convert it into a date format so our string

so our string

so our string representation is deadline and

representation is deadline and

representation is deadline and we need to pass in the second parameter

we need to pass in the second parameter

we need to pass in the second parameter because remember

because remember

because remember i said we basically decided that the

i said we basically decided that the

i said we basically decided that the date should be entered like this with

date should be entered like this with

date should be entered like this with points and a full year here

points and a full year here

points and a full year here and as you know there are lots of

and as you know there are lots of

and as you know there are lots of different formats and types for dates

different formats and types for dates

different formats and types for dates right

right

right depending on a country or a language or

depending on a country or a language or

depending on a country or a language or even within that language

even within that language

even within that language we basically have multiple different

we basically have multiple different

we basically have multiple different formats right we have formats

formats right we have formats

formats right we have formats like this or we could also have

a shorter version of the ear etc so we

a shorter version of the ear etc so we need to define here the format

need to define here the format

need to define here the format that we want python or this method here

that we want python or this method here

that we want python or this method here to use when converting this string into

to use when converting this string into

to use when converting this string into a date

a date

a date again because there are so many

again because there are so many

again because there are so many different formats available

different formats available

different formats available so what we have here is a day then we

so what we have here is a day then we

so what we have here is a day then we have a

have a

have a dot then we have a month again a dot

dot then we have a month again a dot

dot then we have a month again a dot and then we have an ear so this is kind

and then we have an ear so this is kind

and then we have an ear so this is kind of a

of a

of a main structure of a format however

main structure of a format however

main structure of a format however formats for dates have their own

formats for dates have their own

formats for dates have their own specific syntax

specific syntax

specific syntax and this is actually for all programming

and this is actually for all programming

and this is actually for all programming languages so what we need to do

languages so what we need to do

languages so what we need to do is put this percentage sign in front of

is put this percentage sign in front of

is put this percentage sign in front of every

every

every letter so again we have day month year

letter so again we have day month year

letter so again we have day month year and

and

and there is one more thing about this

there is one more thing about this

there is one more thing about this format this format right here

format this format right here

format this format right here matches

this date however we want the full date

this date however we want the full date not just

not just

not just the last two and the format for that

the last two and the format for that

the last two and the format for that would be a capital y

would be a capital y

would be a capital y again this is something that you would

again this is something that you would

again this is something that you would look up in the documentation

look up in the documentation

look up in the documentation of the module instead of knowing it by

of the module instead of knowing it by

of the module instead of knowing it by heart but just know that this type of

heart but just know that this type of

heart but just know that this type of formats

formats

formats are used when working with dates and

are used when working with dates and

are used when working with dates and this is not specific to python

this is not specific to python

this is not specific to python you will actually see something very

you will actually see something very

you will actually see something very similar in all the other different

similar in all the other different

similar in all the other different programming languages and that will

programming languages and that will

programming languages and that will do exactly what we want it will take

do exactly what we want it will take

do exactly what we want it will take this date here

this date here

this date here and give us a proper date format from it

and give us a proper date format from it

and give us a proper date format from it let's actually test this so i'm going to

let's actually test this so i'm going to

let's actually test this so i'm going to print this first

and i'm also going to print a type

and i'm also going to print a type a data type of that value so let's

a data type of that value so let's

a data type of that value so let's execute

i'm actually going to copy that so i

i'm actually going to copy that so i don't have to retype it over and over

don't have to retype it over and over

don't have to retype it over and over again

again

again and enter

and here you see we printed first of all

and here you see we printed first of all the

the

the date not a string and now this looks

date not a string and now this looks

date not a string and now this looks like a

like a

like a proper date and not a string anymore

proper date and not a string anymore

proper date and not a string anymore note the

note the

note the change in the format plus we have these

change in the format plus we have these

change in the format plus we have these zeros here

zeros here

zeros here which represent hours minutes and

which represent hours minutes and

which represent hours minutes and seconds

seconds

seconds we didn't set any of those so these are

we didn't set any of those so these are

we didn't set any of those so these are all zero and we have the date

all zero and we have the date

all zero and we have the date time type again note date time

time type again note date time

time type again note date time for a module name and date time of the

for a module name and date time of the

for a module name and date time of the class name

class name

class name so this is the type of our converted

so this is the type of our converted

so this is the type of our converted date and the reason why we needed to

date and the reason why we needed to

date and the reason why we needed to convert that

convert that

convert that string into a date is because we want to

string into a date is because we want to

string into a date is because we want to calculate

calculate

calculate how many days or how many hours are

how many days or how many hours are

how many days or how many hours are remaining

remaining

remaining until the deadline from now starting

until the deadline from now starting

until the deadline from now starting from

from

from today and to do that calculation

today and to do that calculation

today and to do that calculation we need to have date type because we

we need to have date type because we

we need to have date type because we can't do that on a string

can't do that on a string

can't do that on a string great so now we have our deadline

great so now we have our deadline

great so now we have our deadline represented as

represented as

represented as a date so let's actually assign this to

a date so let's actually assign this to

a date so let's actually assign this to a variable

a variable

a variable it's a deadline date

it's a deadline date

it's a deadline date like this and remove this

like this and remove this

like this and remove this and now we need to do a calculation

how many days from now

how many days from now till the deadline

till the deadline

till the deadline we already have the deadline we need now

we already have the deadline we need now

we already have the deadline we need now again now is or today is also a date

again now is or today is also a date

again now is or today is also a date and since we have this module date time

and since we have this module date time

and since we have this module date time we can

we can

we can also assume that this module will give

also assume that this module will give

also assume that this module will give us some function

us some function

us some function to tell us the date of today

to tell us the date of today

to tell us the date of today and if i do date time

and if i do date time

and if i do date time again daytime class

again daytime class

again daytime class and today you see that we have this

and today you see that we have this

and today you see that we have this function available

function available

function available and this will basically give us the date

and this will basically give us the date

and this will basically give us the date of today so depending obviously when you

of today so depending obviously when you

of today so depending obviously when you execute this program

execute this program

execute this program it will give you always the current date

so let's print it today

so let's print it today for me it's 7th of february so if i

for me it's 7th of february so if i

for me it's 7th of february so if i execute it now

execute it now

execute it now i'm going to enter this and today is

i'm going to enter this and today is

i'm going to enter this and today is 7th of february for me so if i execute

7th of february for me so if i execute

7th of february for me so if i execute this

this

this let's actually comment this out

here i have the date for today which is

here i have the date for today which is 7th of february

7th of february

7th of february plus the exact time it is now but we

plus the exact time it is now but we

plus the exact time it is now but we don't care about the hours and minutes

don't care about the hours and minutes

don't care about the hours and minutes and seconds

and seconds

and seconds we just care about the day

so that means we already have deadline

so that means we already have deadline and we have today let's also

and we have today let's also

and we have today let's also add it to a variable

add it to a variable

add it to a variable like this and now we can actually

like this and now we can actually

like this and now we can actually do the calculation calculation is

do the calculation calculation is

do the calculation calculation is super easy we just say deadline date

super easy we just say deadline date

super easy we just say deadline date minus today date and this will actually

minus today date and this will actually

minus today date and this will actually give us

give us

give us the difference between

or time difference between today and

or time difference between today and the deadline date in the future

the deadline date in the future

the deadline date in the future again let's actually try this out

and you see that so this is 12th of

and you see that so this is 12th of august for me today is 7th of february

august for me today is 7th of february

august for me today is 7th of february so the program calculated that there are

so the program calculated that there are

so the program calculated that there are 185 days

185 days

185 days until the time plus how many hours

until the time plus how many hours

until the time plus how many hours minutes

minutes

minutes seconds and milliseconds so that was a

seconds and milliseconds so that was a

seconds and milliseconds so that was a pretty easy calculation

pretty easy calculation

pretty easy calculation now what we want to do is

now what we want to do is

now what we want to do is tell the user some kind of message and

tell the user some kind of message and

tell the user some kind of message and we want the message to be

we want the message to be

we want the message to be dear user the time remaining until the

dear user the time remaining until the

dear user the time remaining until the deadline

deadline

deadline for your goal whatever the goal was is

for your goal whatever the goal was is

for your goal whatever the goal was is this so let's actually put that text and

this so let's actually put that text and

this so let's actually put that text and message together

message together

message together and bring it back to the user

so first i'm going to save it into a

so first i'm going to save it into a variable

variable

variable let's call it time

let's call it time

let's call it time till

and the message dear user

and the message dear user time remaining

for your goal and here we want to print

for your goal and here we want to print what the goal actually is and you

what the goal actually is and you

what the goal actually is and you remember how we format

remember how we format

remember how we format a string when we want to use a variable

a string when we want to use a variable

a string when we want to use a variable we put an f here and in curly braces now

we put an f here and in curly braces now

we put an f here and in curly braces now we can use

we can use

we can use variables or numbers or some other

variables or numbers or some other

variables or numbers or some other expressions

expressions

expressions which are not string so first of all

which are not string so first of all

which are not string so first of all we're printing back

we're printing back

we're printing back the goal so time remaining for your goal

the goal so time remaining for your goal

the goal so time remaining for your goal whatever goal they entered

whatever goal they entered

whatever goal they entered is time till

and let's give it some other value

and let's give it some other value like this and enter and here we have

like this and enter and here we have

like this and enter and here we have our message dear user time remaining for

our message dear user time remaining for

our message dear user time remaining for your goal

your goal

your goal learn python is 132 days

learn python is 132 days

learn python is 132 days and this many hours minutes etc

and this many hours minutes etc

and this many hours minutes etc now let's say we don't care about this

now let's say we don't care about this

now let's say we don't care about this whole thing here we just want to know

whole thing here we just want to know

whole thing here we just want to know how many

how many

how many days are remaining so how do we get rid

days are remaining so how do we get rid

days are remaining so how do we get rid of

of

of this part here again very easy

this part here again very easy

this part here again very easy and the time till if i do dot here

and the time till if i do dot here

and the time till if i do dot here i get a list of suggestions for

i get a list of suggestions for

i get a list of suggestions for functions or variables that i have

functions or variables that i have

functions or variables that i have available

available

available and one of them is days as you see here

and one of them is days as you see here

and one of them is days as you see here so if i click here

so if i click here

so if i click here and save and i'm going to reuse these

and save and i'm going to reuse these

and save and i'm going to reuse these inputs

inputs

inputs because i don't want to type and

because i don't want to type and

because i don't want to type and as you see we got rid of this whole

as you see we got rid of this whole

as you see we got rid of this whole thing here and we just have

thing here and we just have

thing here and we just have days and let's actually write days

and there you go we have a cleaner

and there you go we have a cleaner output now for

output now for

output now for our user and finally what if the

our user and finally what if the

our user and finally what if the deadline was

deadline was

deadline was just a couple of days in the future and

just a couple of days in the future and

just a couple of days in the future and the user wanted to know how many

the user wanted to know how many

the user wanted to know how many hours are remaining till that deadline

hours are remaining till that deadline

hours are remaining till that deadline we can do that

we can do that

we can do that by getting rid of these days and again

by getting rid of these days and again

by getting rid of these days and again type in dot and we have something called

type in dot and we have something called

type in dot and we have something called total seconds here which gives us the

total seconds here which gives us the

total seconds here which gives us the time different

time different

time different in total seconds and now we can

in total seconds and now we can

in total seconds and now we can reverse engineer and calculate the

reverse engineer and calculate the

reverse engineer and calculate the number of hours

number of hours

number of hours from this total seconds which is pretty

from this total seconds which is pretty

from this total seconds which is pretty easy

easy

easy like this calculate minutes and then

like this calculate minutes and then

like this calculate minutes and then calculate hours

calculate hours

calculate hours and i'm gonna execute this again

and here you see the number of hours

and here you see the number of hours with a decimal precision so we have 4450

with a decimal precision so we have 4450

with a decimal precision so we have 4450 hours point

hours point

hours point some fraction number here again we want

some fraction number here again we want

some fraction number here again we want to get rid of this

to get rid of this

to get rid of this extra stuff and as you see from the

extra stuff and as you see from the

extra stuff and as you see from the syntax

syntax

syntax it is actually a float number with a dot

it is actually a float number with a dot

it is actually a float number with a dot here

here

here so what we could do is basically convert

so what we could do is basically convert

so what we could do is basically convert this whole thing

this whole thing

this whole thing this float number into an integer so

this float number into an integer so

this float number into an integer so convert this whole thing into an integer

convert this whole thing into an integer

convert this whole thing into an integer using

using

using int function and we need this whole

int function and we need this whole

int function and we need this whole calculation here inside the int function

calculation here inside the int function

calculation here inside the int function and let's execute it again learn

and let's execute it again learn

and let's execute it again learn python and let's choose a date which is

python and let's choose a date which is

python and let's choose a date which is near

near

near and there you go we have a whole number

and there you go we have a whole number

and there you go we have a whole number 57 again

57 again

57 again cleaner output and as a code

cleaner output and as a code

cleaner output and as a code optimization

optimization

optimization we could take this whole thing out

we could take this whole thing out

we could take this whole thing out into a variable and call it hours

into a variable and call it hours

into a variable and call it hours till to make our code a little bit

till to make our code a little bit

till to make our code a little bit cleaner

cleaner

cleaner so now we have the whole program that

so now we have the whole program that

so now we have the whole program that takes user input

takes user input

takes user input and basically prints back to them how

and basically prints back to them how

and basically prints back to them how many

many

many hours are remaining till the deadline

hours are remaining till the deadline

hours are remaining till the deadline for their goal

for their goal

for their goal and for this program we used a date time

and for this program we used a date time

and for this program we used a date time module

module

module a built-in date time module from python

a built-in date time module from python

a built-in date time module from python and we also learned a new data type

and we also learned a new data type

and we also learned a new data type which is date time and as we learned

which is date time and as we learned

which is date time and as we learned from the module section

from the module section

from the module section we can actually optimize the import of

we can actually optimize the import of

we can actually optimize the import of the module because

the module because

the module because obviously we're just using the date time

obviously we're just using the date time

obviously we're just using the date time definition

definition

definition and nothing else from that module

and nothing else from that module

and nothing else from that module so what we could do is from date time

so what we could do is from date time

so what we could do is from date time module

module

module import date time definition

import date time definition

import date time definition which is a class in this case so

which is a class in this case so

which is a class in this case so now you don't need to use the module

now you don't need to use the module

now you don't need to use the module name

name

name so let's get rid of those and this could

so let's get rid of those and this could

so let's get rid of those and this could make

make

make the code cleaner as well as make the

the code cleaner as well as make the

the code cleaner as well as make the import more efficient because we're not

import more efficient because we're not

import more efficient because we're not importing the whole module even though

importing the whole module even though

importing the whole module even though we just need one definition from there

when you install python it comes with a

when you install python it comes with a set of

set of

set of modules that are built in into python

modules that are built in into python

modules that are built in into python however there are many more modules

however there are many more modules

however there are many more modules for other different use cases like web

for other different use cases like web

for other different use cases like web development or data science and machine

development or data science and machine

development or data science and machine learning etc

learning etc

learning etc that are not part of that installation

that are not part of that installation

that are not part of that installation and these are basically

and these are basically

and these are basically external modules not built-in modules

external modules not built-in modules

external modules not built-in modules that you have to

that you have to

that you have to install as you need and this makes sense

install as you need and this makes sense

install as you need and this makes sense because the built-in modules are the

because the built-in modules are the

because the built-in modules are the ones that

ones that

ones that most of python programs will probably

most of python programs will probably

most of python programs will probably need

need

need and depending on what specifically you

and depending on what specifically you

and depending on what specifically you are doing with your program

are doing with your program

are doing with your program whether you are developing a web

whether you are developing a web

whether you are developing a web application or creating some machine

application or creating some machine

application or creating some machine learning

learning

learning program you can then add and install

program you can then add and install

program you can then add and install them as you need

them as you need

them as you need and there are hundreds of such external

and there are hundreds of such external

and there are hundreds of such external modules

modules

modules for python out there and obviously it

for python out there and obviously it

for python out there and obviously it wouldn't be practical

wouldn't be practical

wouldn't be practical to have them all on your laptop when

to have them all on your laptop when

to have them all on your laptop when you're just gonna use maybe a handful of

you're just gonna use maybe a handful of

you're just gonna use maybe a handful of them right

them right

them right now if i need to install an additional

now if i need to install an additional

now if i need to install an additional module for example django for web

module for example django for web

module for example django for web development

development

development where do i find these modules and how do

where do i find these modules and how do

where do i find these modules and how do i install them

i install them

i install them python modules actually live in a module

python modules actually live in a module

python modules actually live in a module repository

repository

repository where you can find them and that module

where you can find them and that module

where you can find them and that module repository is called

repository is called

repository is called pipey so if i look for pipey

pipey so if i look for pipey

pipey so if i look for pipey right here you see the python package

right here you see the python package

right here you see the python package index

index

index if i click inside you can search for any

if i click inside you can search for any

if i click inside you can search for any module that you want to add or install

module that you want to add or install

module that you want to add or install additionally for your application and

additionally for your application and

additionally for your application and here you see this word

here you see this word

here you see this word package everywhere instead of a module

package everywhere instead of a module

package everywhere instead of a module so what is a package or what is the

so what is a package or what is the

so what is a package or what is the difference between

difference between

difference between package and a module

to give you a simple comparison module

to give you a simple comparison module is basically

is basically

is basically a python file like this one right here

a python file like this one right here

a python file like this one right here that has

that has

that has a name of that file right so we have an

a name of that file right so we have an

a name of that file right so we have an ssl

ssl

ssl module or the one that we used

module or the one that we used

module or the one that we used earlier we have this os module right

earlier we have this os module right

earlier we have this os module right so module is one python file that

so module is one python file that

so module is one python file that contains all these functions and

contains all these functions and

contains all these functions and variables that you can use

variables that you can use

variables that you can use package is a collection of modules

package is a collection of modules

package is a collection of modules so if we scroll up and logging

so if we scroll up and logging

so if we scroll up and logging is actually one our example

is actually one our example

is actually one our example so these are actually packages and

so these are actually packages and

so these are actually packages and again let's go to logging so package

again let's go to logging so package

again let's go to logging so package basically contains

basically contains

basically contains multiple python files and use it in the

multiple python files and use it in the

multiple python files and use it in the same way you basically

same way you basically

same way you basically import the functions and definitions

import the functions and definitions

import the functions and definitions from the module

from the module

from the module and as you see clearly the difference is

and as you see clearly the difference is

and as you see clearly the difference is that package

that package

that package is more structured so for example the

is more structured so for example the

is more structured so for example the code is not available in just one

code is not available in just one

code is not available in just one single python file but it's divided like

single python file but it's divided like

single python file but it's divided like this

this

this in our case we have two python files and

in our case we have two python files and

in our case we have two python files and package

package

package always has this init python file

always has this init python file

always has this init python file and this file basically differentiates a

and this file basically differentiates a

and this file basically differentiates a normal folder

normal folder

normal folder like we have right here with bunch of

like we have right here with bunch of

like we have right here with bunch of python files

python files

python files from an actual package with python files

from an actual package with python files

from an actual package with python files so that's the difference between modules

so that's the difference between modules

so that's the difference between modules and packages

and packages

and packages and many external modules basically that

and many external modules basically that

and many external modules basically that we want to use in our projects are

we want to use in our projects are

we want to use in our projects are actually packages so basically package

actually packages so basically package

actually packages so basically package is a

is a

is a good way to define some hierarchy and

good way to define some hierarchy and

good way to define some hierarchy and structure for your modules

structure for your modules

structure for your modules and kind of group them together so

and kind of group them together so

and kind of group them together so that's why you see

that's why you see

that's why you see package here as a name instead of module

package here as a name instead of module

package here as a name instead of module so now that we know the difference let's

so now that we know the difference let's

so now that we know the difference let's actually search

actually search

actually search for a package for our project so for

for a package for our project so for

for a package for our project so for example if i type here

example if i type here

example if i type here django you see django packages that we

django you see django packages that we

django you see django packages that we can

can

can use from here we also have numpy

use from here we also have numpy

use from here we also have numpy and so on however in programming when

and so on however in programming when

and so on however in programming when working with and using these external

working with and using these external

working with and using these external packages a typical example would be

packages a typical example would be

packages a typical example would be where

where

where you need to implement some logic for

you need to implement some logic for

you need to implement some logic for example you want

example you want

example you want to write a program that basically talks

to write a program that basically talks

to write a program that basically talks to aws maybe

to aws maybe

to aws maybe and you don't know exactly the name of

and you don't know exactly the name of

and you don't know exactly the name of that package

that package

that package but you know what you're looking for so

but you know what you're looking for so

but you know what you're looking for so in this case

in this case

in this case instead of the exact name you would

instead of the exact name you would

instead of the exact name you would actually type in here in the search

actually type in here in the search

actually type in here in the search projects box

projects box

projects box a description of what you're looking for

a description of what you're looking for

a description of what you're looking for so let's say we're looking for

so let's say we're looking for

so let's say we're looking for an aws api package right

an aws api package right

an aws api package right something that will allow us to connect

something that will allow us to connect

something that will allow us to connect to the aws api

to the aws api

to the aws api and as you see here we get a list of

and as you see here we get a list of

and as you see here we get a list of different packages for that to choose

different packages for that to choose

different packages for that to choose from

from

from so basically pipey is a repository

so basically pipey is a repository

so basically pipey is a repository or storage for all of those modules and

or storage for all of those modules and

or storage for all of those modules and packages

packages

packages and people can also publish their own

and people can also publish their own

and people can also publish their own libraries like individual developers for

libraries like individual developers for

libraries like individual developers for example

example

example they can publish their own packages and

they can publish their own packages and

they can publish their own packages and modules there

modules there

modules there and make it available for other

and make it available for other

and make it available for other programmers to use

programmers to use

programmers to use and that's one reason why large

and that's one reason why large

and that's one reason why large community is

community is

community is so great for a programming language

so great for a programming language

so great for a programming language because then you can make

because then you can make

because then you can make use of all these modules and packages

use of all these modules and packages

use of all these modules and packages that others in the community have

that others in the community have

that others in the community have developed so for any kind of

developed so for any kind of

developed so for any kind of functionality you need in your

functionality you need in your

functionality you need in your application

application

application you could imagine that there is a module

you could imagine that there is a module

you could imagine that there is a module or package that helps you do exactly

or package that helps you do exactly

or package that helps you do exactly that

now let's say i need a django package

now let's say i need a django package for my

for my

for my web application so first i find the

web application so first i find the

web application so first i find the package

package

package and now i can actually check some of the

and now i can actually check some of the

and now i can actually check some of the documentation for that specific package

documentation for that specific package

documentation for that specific package so if i click inside i see some

so if i click inside i see some

so if i click inside i see some description

description

description for the project as well as documentation

for the project as well as documentation

for the project as well as documentation and some other links

and some other links

and some other links now the question is how do i actually

now the question is how do i actually

now the question is how do i actually install this package

install this package

install this package locally so that i can use it in my

locally so that i can use it in my

locally so that i can use it in my project

project

project in python we install packages

in python we install packages

in python we install packages using a package manager tool called peep

using a package manager tool called peep

using a package manager tool called peep and right here on top below the package

and right here on top below the package

and right here on top below the package name you actually see a command

name you actually see a command

name you actually see a command peep install django so this is actually

peep install django so this is actually

peep install django so this is actually a command

a command

a command that will install that package locally

that will install that package locally

that will install that package locally on my laptop

on my laptop

on my laptop so we install packages in python using

so we install packages in python using

so we install packages in python using this pip command so

this pip command so

this pip command so what is this command or where does it

what is this command or where does it

what is this command or where does it come from

come from

come from pip is a package manager for python

pip is a package manager for python

pip is a package manager for python and if you know any other programming

and if you know any other programming

and if you know any other programming language basically

language basically

language basically the concept is the same every

the concept is the same every

the concept is the same every programming language

programming language

programming language has its own package manager tool

has its own package manager tool

has its own package manager tool for javascript it's npm for java

for javascript it's npm for java

for javascript it's npm for java it's maven or gradle and for python it

it's maven or gradle and for python it

it's maven or gradle and for python it is

is

is pip and one of the main tasks or usages

pip and one of the main tasks or usages

pip and one of the main tasks or usages of a package manager tool

of a package manager tool

of a package manager tool is to install external packages or

is to install external packages or

is to install external packages or libraries

libraries

libraries or also called dependencies for your

or also called dependencies for your

or also called dependencies for your project

project

project so if python needs this django package

so if python needs this django package

so if python needs this django package basically it's the job of the package

basically it's the job of the package

basically it's the job of the package manager

manager

manager to install that package and make

to install that package and make

to install that package and make available for python

available for python

available for python now where did this command come from do

now where did this command come from do

now where did this command come from do we have pip command available

we have pip command available

we have pip command available well in python version 3 actually

well in python version 3 actually

well in python version 3 actually pip is packaged inside the python so

pip is packaged inside the python so

pip is packaged inside the python so when we install the python we actually

when we install the python we actually

when we install the python we actually installed pip as well so basically we're

installed pip as well so basically we're

installed pip as well so basically we're going to copy this command

going to copy this command

going to copy this command peep install django and we're going to

peep install django and we're going to

peep install django and we're going to execute it actually from the terminal

execute it actually from the terminal

execute it actually from the terminal of pycharm so in pycharm editor we have

of pycharm so in pycharm editor we have

of pycharm so in pycharm editor we have this

this

this integrated terminal so this is actually

integrated terminal so this is actually

integrated terminal so this is actually pretty much the same

pretty much the same

pretty much the same terminal as you have outside like this

terminal as you have outside like this

terminal as you have outside like this so we are going to execute this pip

so we are going to execute this pip

so we are going to execute this pip install command directly

install command directly

install command directly in this pycharm terminal so i'm going to

in this pycharm terminal so i'm going to

in this pycharm terminal so i'm going to copy it

copy it

copy it here and do peep install django

here and do peep install django

here and do peep install django and you see it is downloading and

and you see it is downloading and

and you see it is downloading and successfully

successfully

successfully installed django 3.1.6

installed django 3.1.6

installed django 3.1.6 and we can actually see that package

and we can actually see that package

and we can actually see that package from our editor directly

from our editor directly

from our editor directly if i expand these external libraries

if i expand these external libraries

if i expand these external libraries and site packages

and scroll a bit down here i have django

and scroll a bit down here i have django 316 version installed so i see that the

316 version installed so i see that the

316 version installed so i see that the package is now

package is now

package is now available in my project and to also test

available in my project and to also test

available in my project and to also test it

it

it in the code i can do import and

in the code i can do import and

in the code i can do import and django and you see that pycharm actually

django and you see that pycharm actually

django and you see that pycharm actually recognize that i have django packaged

recognize that i have django packaged

recognize that i have django packaged locally

locally

locally so it gives me that package as a

so it gives me that package as a

so it gives me that package as a suggestion

suggestion

suggestion so that will basically import the whole

so that will basically import the whole

so that will basically import the whole django package

django package

django package so we can now use it in our application

so we can now use it in our application

so we can now use it in our application here you see pycharm

here you see pycharm

here you see pycharm actually noticed you are using or want

actually noticed you are using or want

actually noticed you are using or want to use

to use

to use django web framework as i mentioned in

django web framework as i mentioned in

django web framework as i mentioned in the beginning the pycharm professional

the beginning the pycharm professional

the beginning the pycharm professional edition

edition

edition has special support for different python

has special support for different python

has special support for different python web frameworks

web frameworks

web frameworks supporting you with syntax highlighting

supporting you with syntax highlighting

supporting you with syntax highlighting suggestions

suggestions

suggestions database integration and so on so again

database integration and so on so again

database integration and so on so again if you want to try it out for free for

if you want to try it out for free for

if you want to try it out for free for three months just use my code in the

three months just use my code in the

three months just use my code in the video description

video description

video description in the same way as we install the

in the same way as we install the

in the same way as we install the package

package

package we can also uninstall packages using pip

we can also uninstall packages using pip

we can also uninstall packages using pip and let's also actually demonstrate that

and let's also actually demonstrate that

and let's also actually demonstrate that pip uninstall

pip uninstall

pip uninstall django and

django and

django and let's confirm that

let's confirm that

let's confirm that successfully uninstalled django now if

successfully uninstalled django now if

successfully uninstalled django now if in the site packages i click inside

in the site packages i click inside

in the site packages i click inside you see that django packages are gone so

you see that django packages are gone so

you see that django packages are gone so this site packages folder got updated

this site packages folder got updated

this site packages folder got updated django was removed

django was removed

django was removed and you also see that in the code editor

and you also see that in the code editor

and you also see that in the code editor now i have this

now i have this

now i have this red line under django because pycharm

red line under django because pycharm

red line under django because pycharm cannot find

cannot find

cannot find a module called django and also if i do

a module called django and also if i do

a module called django and also if i do this

this

this obviously it won't give me any auto

obviously it won't give me any auto

obviously it won't give me any auto suggestion for that

suggestion for that

suggestion for that so that's how you can use peep to

so that's how you can use peep to

so that's how you can use peep to install packages and also to uninstall

install packages and also to uninstall

install packages and also to uninstall packages

packages

packages for your application

now here i want to show you another cool

now here i want to show you another cool alternative to installing and

alternative to installing and

alternative to installing and uninstalling packages directly in the

uninstalling packages directly in the

uninstalling packages directly in the pycharm ide

pycharm ide

pycharm ide and this is actually a feature in the

and this is actually a feature in the

and this is actually a feature in the latest pycharm release

latest pycharm release

latest pycharm release and for this i need to switch to an

and for this i need to switch to an

and for this i need to switch to an early access pycharm version so you see

early access pycharm version so you see

early access pycharm version so you see here

here

here it says pycharm eap early access

it says pycharm eap early access

it says pycharm eap early access to show you the feature however when you

to show you the feature however when you

to show you the feature however when you watch the tutorial it probably will

watch the tutorial it probably will

watch the tutorial it probably will already be included in the latest

already be included in the latest

already be included in the latest official pycharm version so you should

official pycharm version so you should

official pycharm version so you should have that already

have that already

have that already so instead of us basically finding this

so instead of us basically finding this

so instead of us basically finding this package in pipey

package in pipey

package in pipey and then executing peep install commands

and then executing peep install commands

and then executing peep install commands right here what you can do is

right here what you can do is

right here what you can do is down here you have another tab called

down here you have another tab called

down here you have another tab called python packages so if we click inside

python packages so if we click inside

python packages so if we click inside this is a place where you have

this is a place where you have

this is a place where you have everything that you need to know

everything that you need to know

everything that you need to know about the package the package search and

about the package the package search and

about the package the package search and all these

all these

all these features basically in one place so for

features basically in one place so for

features basically in one place so for example

example

example in order to install django we can just

in order to install django we can just

in order to install django we can just search

search

search for django right here and you see that

for django right here and you see that

for django right here and you see that when i type in the first couple of

when i type in the first couple of

when i type in the first couple of letters

letters

letters i already get suggestions so this is a

i already get suggestions so this is a

i already get suggestions so this is a list of all the packages

list of all the packages

list of all the packages that start with this name that are

that start with this name that are

that start with this name that are actually available in pipi

actually available in pipi

actually available in pipi so let's type in django and we see that

so let's type in django and we see that

so let's type in django and we see that right here

right here

right here and on the right you see the

and on the right you see the

and on the right you see the documentation

documentation

documentation of the package that you would actually

of the package that you would actually

of the package that you would actually see in

see in

see in pipey ui so you have that in place as

pipey ui so you have that in place as

pipey ui so you have that in place as well

well

well and in addition to that what they added

and in addition to that what they added

and in addition to that what they added is the documentation

is the documentation

is the documentation link so this is actually the package

link so this is actually the package

link so this is actually the package how-to guide

how-to guide

how-to guide and the full documentation with examples

and the full documentation with examples

and the full documentation with examples etc

etc

etc so very convenient way to basically get

so very convenient way to basically get

so very convenient way to basically get all the information about the package

all the information about the package

all the information about the package search the package and then to install

search the package and then to install

search the package and then to install the package

the package

the package we can choose the version here so either

we can choose the version here so either

we can choose the version here so either you can leave the latest

you can leave the latest

you can leave the latest or basically select the specific version

or basically select the specific version

or basically select the specific version and then once you have selected that you

and then once you have selected that you

and then once you have selected that you can just click

can just click

can just click install and here you see installing

install and here you see installing

install and here you see installing package

package

package and there you go so now in installed

and there you go so now in installed

and there you go so now in installed view here so we just had pip and setup

view here so we just had pip and setup

view here so we just had pip and setup tools

tools

tools these two things installed and right

these two things installed and right

these two things installed and right here we have now

here we have now

here we have now django in the installed packages list

django in the installed packages list

django in the installed packages list and again while you're now using the

and again while you're now using the

and again while you're now using the installed

installed

installed package or library in your code and

package or library in your code and

package or library in your code and basically you want to look

basically you want to look

basically you want to look up some examples or you want to check

up some examples or you want to check

up some examples or you want to check some documentation

some documentation

some documentation right you go back to the package click

right you go back to the package click

right you go back to the package click inside and you have link to

inside and you have link to

inside and you have link to documentation and

documentation and

documentation and the package information as well and also

the package information as well and also

the package information as well and also just by looking at this list you know

just by looking at this list you know

just by looking at this list you know which versions of which packages you

which versions of which packages you

which versions of which packages you have installed so i think it's really

have installed so i think it's really

have installed so i think it's really cool way to manage all your packages to

cool way to manage all your packages to

cool way to manage all your packages to install packages

install packages

install packages and for example if you want to uninstall

and for example if you want to uninstall

and for example if you want to uninstall packages

packages

packages from your project then again just

from your project then again just

from your project then again just clicking

clicking

clicking to that specific package right here

to that specific package right here

to that specific package right here you can just delete it and it will be

you can just delete it and it will be

you can just delete it and it will be removed from your application

like this and no django anymore here

like this and no django anymore here so a very cool addition to pycharm

so a very cool addition to pycharm

so a very cool addition to pycharm because this will be very convenient to

because this will be very convenient to

because this will be very convenient to work with the packages

work with the packages

work with the packages so now i will switch back to my other

so now i will switch back to my other

so now i will switch back to my other editor again

editor again

editor again and continue from there

so basically i have just cleaned up my

so basically i have just cleaned up my python project we have this main.pi

python project we have this main.pi

python project we have this main.pi which is

which is

which is empty and we're gonna write an

empty and we're gonna write an

empty and we're gonna write an application that will read

application that will read

application that will read a spreadsheet file from our local file

a spreadsheet file from our local file

a spreadsheet file from our local file system

system

system it will read some information from that

it will read some information from that

it will read some information from that spreadsheet file and do

spreadsheet file and do

spreadsheet file and do something with that data and this could

something with that data and this could

something with that data and this could be a very useful

be a very useful

be a very useful use case if you're working with lots of

use case if you're working with lots of

use case if you're working with lots of files and you want to do some

files and you want to do some

files and you want to do some data processing in those files and you

data processing in those files and you

data processing in those files and you don't want to do that manually

don't want to do that manually

don't want to do that manually by automating or writing a program in

by automating or writing a program in

by automating or writing a program in python

python

python that basically can do anything in a file

that basically can do anything in a file

that basically can do anything in a file or across multiple files so let's see

or across multiple files so let's see

or across multiple files so let's see exactly

exactly

exactly what we are going to be doing with this

what we are going to be doing with this

what we are going to be doing with this program so first of all

program so first of all

program so first of all we're going to have an input file a

we're going to have an input file a

we're going to have an input file a spreadsheet file that we're going to be

spreadsheet file that we're going to be

spreadsheet file that we're going to be working with

working with

working with and that spreadsheet will look like this

and that spreadsheet will look like this

and that spreadsheet will look like this it's called inventory that's how it's

it's called inventory that's how it's

it's called inventory that's how it's going to look like

going to look like

going to look like so basically this file simulates

so basically this file simulates

so basically this file simulates something that many companies would have

something that many companies would have

something that many companies would have and employees of that company would be

and employees of that company would be

and employees of that company would be working with

working with

working with so we have this list of product numbers

so we have this list of product numbers

so we have this list of product numbers inventory for each product price for the

inventory for each product price for the

inventory for each product price for the product

product

product and a supplier so this could be an

and a supplier so this could be an

and a supplier so this could be an example file from a company that is

example file from a company that is

example file from a company that is basically dealing with

basically dealing with

basically dealing with selling or buying products so what we're

selling or buying products so what we're

selling or buying products so what we're going to do is

going to do is

going to do is we're going to read the information from

we're going to read the information from

we're going to read the information from this file and we're going to do

this file and we're going to do

this file and we're going to do something with that information

something with that information

something with that information first we're going to write logic that

first we're going to write logic that

first we're going to write logic that calculates

calculates

calculates how many products we have per supplier

how many products we have per supplier

how many products we have per supplier so we have three supplier companies here

so we have three supplier companies here

so we have three supplier companies here and per supplier we're gonna calculate

and per supplier we're gonna calculate

and per supplier we're gonna calculate number of

number of

number of products from that specific company and

products from that specific company and

products from that specific company and as a result we're gonna list

as a result we're gonna list

as a result we're gonna list the company so all three companies with

the company so all three companies with

the company so all three companies with their respective

their respective

their respective number of products then we're going to

number of products then we're going to

number of products then we're going to write another logic that

write another logic that

write another logic that lists inventory products that have

lists inventory products that have

lists inventory products that have inventory which is

inventory which is

inventory which is less than 10 so basically those ones

less than 10 so basically those ones

less than 10 so basically those ones the third exercise is going to be to

the third exercise is going to be to

the third exercise is going to be to list

list

list each company with their respective total

each company with their respective total

each company with their respective total inventory value

inventory value

inventory value and finally in the last exercise we will

and finally in the last exercise we will

and finally in the last exercise we will calculate the inventory value for

calculate the inventory value for

calculate the inventory value for each product so product count times

each product so product count times

each product so product count times price and we're going to write that

price and we're going to write that

price and we're going to write that value to

value to

value to an additional column in the spreadsheet

an additional column in the spreadsheet

an additional column in the spreadsheet and

and

and after that we're going to save that

after that we're going to save that

after that we're going to save that updated spreadsheet file

updated spreadsheet file

updated spreadsheet file programmatically using python so we're

programmatically using python so we're

programmatically using python so we're gonna see how to

gonna see how to

gonna see how to update a file and then save it

update a file and then save it

update a file and then save it programmatically

programmatically

programmatically in python if any of these sounds a

in python if any of these sounds a

in python if any of these sounds a little bit too complicated for you then

little bit too complicated for you then

little bit too complicated for you then just bear with me

just bear with me

just bear with me i'm gonna explain everything step by

i'm gonna explain everything step by

i'm gonna explain everything step by step and

step and

step and it's gonna become much clearer when we

it's gonna become much clearer when we

it's gonna become much clearer when we actually start writing the

actually start writing the

actually start writing the logic

so the first thing what i'm gonna do is

so the first thing what i'm gonna do is i'm gonna take this

i'm gonna take this

i'm gonna take this file that i have in the downloads folder

file that i have in the downloads folder

file that i have in the downloads folder and i'm actually gonna

and i'm actually gonna

and i'm actually gonna move that into my project so i'm gonna

move that into my project so i'm gonna

move that into my project so i'm gonna copy that and i'm gonna drop it in here

copy that and i'm gonna drop it in here

copy that and i'm gonna drop it in here so that we have the file right in our

so that we have the file right in our

so that we have the file right in our project and so we can basically just

project and so we can basically just

project and so we can basically just read it

read it

read it easily and okay and here is

easily and okay and here is

easily and okay and here is our inventory file so that's taken care

our inventory file so that's taken care

our inventory file so that's taken care of so obviously what we want to do now

of so obviously what we want to do now

of so obviously what we want to do now is read that file so basically let our

is read that file so basically let our

is read that file so basically let our python program

python program

python program read the contents of that file right

read the contents of that file right

read the contents of that file right here

here

here because we want to write some logic

because we want to write some logic

because we want to write some logic based on the values

based on the values

based on the values that are in this inventory file right we

that are in this inventory file right we

that are in this inventory file right we want to calculate stuff we want to

want to calculate stuff we want to

want to calculate stuff we want to list some stuff and so on so basically

list some stuff and so on so basically

list some stuff and so on so basically we want to work with these values and in

we want to work with these values and in

we want to work with these values and in order to do that we need to

order to do that we need to

order to do that we need to read all of these values into our

read all of these values into our

read all of these values into our program so that we have them available

program so that we have them available

program so that we have them available so how do we do that now there is

so how do we do that now there is

so how do we do that now there is actually a

actually a

actually a built-in module in python that allows

built-in module in python that allows

built-in module in python that allows you to work with files

you to work with files

you to work with files generally right it's not specific for a

generally right it's not specific for a

generally right it's not specific for a spreadsheet

spreadsheet

spreadsheet or for any other file type it's for

or for any other file type it's for

or for any other file type it's for different types of files

different types of files

different types of files generally however there is an external

generally however there is an external

generally however there is an external package

package

package that allows you to work with

that allows you to work with

that allows you to work with spreadsheets

spreadsheets

spreadsheets specifically and the obvious advantage

specifically and the obvious advantage

specifically and the obvious advantage is that

is that

is that that external module that allows you to

that external module that allows you to

that external module that allows you to work with spreadsheets or

work with spreadsheets or

work with spreadsheets or was created to work with spreadsheets

was created to work with spreadsheets

was created to work with spreadsheets specifically

specifically

specifically has much more functions and is much

has much more functions and is much

has much more functions and is much easier to use

easier to use

easier to use if you are working with spreadsheets

if you are working with spreadsheets

if you are working with spreadsheets compared to this built-in file module

compared to this built-in file module

compared to this built-in file module so that's one of the cases where you may

so that's one of the cases where you may

so that's one of the cases where you may have multiple ways of

have multiple ways of

have multiple ways of actually implementing some functionality

actually implementing some functionality

actually implementing some functionality for

for

for application and then you have to make

application and then you have to make

application and then you have to make this decision of maybe finding a better

this decision of maybe finding a better

this decision of maybe finding a better package or better module

package or better module

package or better module which is available externally that will

which is available externally that will

which is available externally that will make it easier for you

make it easier for you

make it easier for you to implement that functionality so

to implement that functionality so

to implement that functionality so that's what we're gonna do for our

that's what we're gonna do for our

that's what we're gonna do for our project

project

project we're going to choose the package that

we're going to choose the package that

we're going to choose the package that is actually made for working with

is actually made for working with

is actually made for working with spreadsheets

spreadsheets

spreadsheets we're going to use that one and it's

we're going to use that one and it's

we're going to use that one and it's called open

called open

called open pi xl and if i

pi xl and if i

pi xl and if i search for it this is the package that

search for it this is the package that

search for it this is the package that we're looking for

we're looking for

we're looking for and if i click inside basically we have

and if i click inside basically we have

and if i click inside basically we have some information

some information

some information about this package so here we see a

about this package so here we see a

about this package so here we see a description

description

description let's actually make this bigger

let's actually make this bigger

let's actually make this bigger description

description

description library to read write excel

library to read write excel

library to read write excel files with all these formats

files with all these formats

files with all these formats so this is the library that we're going

so this is the library that we're going

so this is the library that we're going to be using in the same way as we did

to be using in the same way as we did

to be using in the same way as we did before

before

before we're going to copy that command and

we're going to copy that command and

we're going to copy that command and execute it from pycharms

execute it from pycharms

execute it from pycharms integrated terminal so from here i'm

integrated terminal so from here i'm

integrated terminal so from here i'm gonna

gonna

gonna execute this pip command and install

execute this pip command and install

execute this pip command and install our module and as you see

our module and as you see

our module and as you see successfully installed open pi xl

successfully installed open pi xl

successfully installed open pi xl and this is the version of the module

and this is the version of the module

and this is the version of the module that we installed and

that we installed and

that we installed and in external libraries site packages you

in external libraries site packages you

in external libraries site packages you should be able to see

should be able to see

should be able to see our open pi excel package

our open pi excel package

our open pi excel package and now because the package is available

and now because the package is available

and now because the package is available locally i can do

locally i can do

locally i can do import and open

import and open

import and open pi excel again i get a suggestion from

pi excel again i get a suggestion from

pi excel again i get a suggestion from pycharm because the module is there

pycharm because the module is there

pycharm because the module is there and now we are able to use that package

and now we are able to use that package

and now we are able to use that package for our application and one small note

for our application and one small note

for our application and one small note here if you're wondering

here if you're wondering

here if you're wondering why there are some packages with

why there are some packages with

why there are some packages with basically a dot

basically a dot

basically a dot inside and some without these are the

inside and some without these are the

inside and some without these are the packages

packages

packages that we install python packages and we

that we install python packages and we

that we install python packages and we know that because there's this

know that because there's this

know that because there's this init python file inside and the ones

init python file inside and the ones

init python file inside and the ones without the dot they're just folders

without the dot they're just folders

without the dot they're just folders with bunch of files inside but they're

with bunch of files inside but they're

with bunch of files inside but they're not python packages so to say

not python packages so to say

not python packages so to say and inside some of those packages we see

and inside some of those packages we see

and inside some of those packages we see other packages as well with their own

other packages as well with their own

other packages as well with their own init file

init file

init file so basically hierarchy of multiple

so basically hierarchy of multiple

so basically hierarchy of multiple packages

packages

packages and at this point i'm going to say that

and at this point i'm going to say that

and at this point i'm going to say that the word

the word

the word library basically describes package

library basically describes package

library basically describes package that includes multiple other packages so

that includes multiple other packages so

that includes multiple other packages so basically which has a hierarchy of

basically which has a hierarchy of

basically which has a hierarchy of packages

packages

packages so we have module which is basically

so we have module which is basically

so we have module which is basically just one python file

just one python file

just one python file that we can use in our project then we

that we can use in our project then we

that we can use in our project then we have package which is

have package which is

have package which is a hierarchy of multiple modules with an

a hierarchy of multiple modules with an

a hierarchy of multiple modules with an init python file inside and then we have

init python file inside and then we have

init python file inside and then we have library which is basically

library which is basically

library which is basically multiple packages together in a

multiple packages together in a

multiple packages together in a hierarchy

hierarchy

hierarchy just like we see right here so note the

just like we see right here so note the

just like we see right here so note the difference

difference

difference so you don't get confused when you see

so you don't get confused when you see

so you don't get confused when you see library package and module

library package and module

library package and module especially if used interchangeably

great so now we have our module in place

great so now we have our module in place so let's use it now to read our

so let's use it now to read our

so let's use it now to read our spreadsheet file

spreadsheet file

spreadsheet file and again you basically have to know the

and again you basically have to know the

and again you basically have to know the function names

function names

function names to do that if you don't you can do dot

to do that if you don't you can do dot

to do that if you don't you can do dot and get suggestions

and get suggestions

and get suggestions and load workbook is actually the

and load workbook is actually the

and load workbook is actually the function that we need

function that we need

function that we need in order to read our spreadsheet file so

in order to read our spreadsheet file so

in order to read our spreadsheet file so i'm going to choose this

i'm going to choose this

i'm going to choose this function and obviously we need to tell

function and obviously we need to tell

function and obviously we need to tell this function

this function

this function which file it should read so as a

which file it should read so as a

which file it should read so as a parameter

parameter

parameter we're going to say please

we're going to say please

we're going to say please load inventory file and we even get a

load inventory file and we even get a

load inventory file and we even get a suggestion because we have this

suggestion because we have this

suggestion because we have this inventory file here

inventory file here

inventory file here and there you go now this function will

and there you go now this function will

and there you go now this function will load the workbook and all its contents

load the workbook and all its contents

load the workbook and all its contents and later we obviously want to do

and later we obviously want to do

and later we obviously want to do something with that content

something with that content

something with that content so in order to be able to do that we

so in order to be able to do that we

so in order to be able to do that we need to save it first as a variable

need to save it first as a variable

need to save it first as a variable and let's actually call it inventory

and let's actually call it inventory

and let's actually call it inventory file like this and this will give us the

file like this and this will give us the

file like this and this will give us the file contents

file contents

file contents now let's actually open that file again

and let's see exactly what we need so we

and let's see exactly what we need so we can have multiple

can have multiple

can have multiple such sheets basically per file so we

such sheets basically per file so we

such sheets basically per file so we need to tell the program which one it

need to tell the program which one it

need to tell the program which one it should use

should use

should use exactly so for example if this was

exactly so for example if this was

exactly so for example if this was called a product list

called a product list

called a product list you would use that name but we're gonna

you would use that name but we're gonna

you would use that name but we're gonna go with sheet

go with sheet

go with sheet one so we're gonna use that name

one so we're gonna use that name

one so we're gonna use that name basically

basically

basically and we're gonna grab that using

and we're gonna grab that using

and we're gonna grab that using following syntax and you remember this

following syntax and you remember this

following syntax and you remember this syntax probably from using a dictionary

syntax probably from using a dictionary

syntax probably from using a dictionary so this will give us this one specific

so this will give us this one specific

so this will give us this one specific sheet and all the information inside

sheet and all the information inside

sheet and all the information inside and we can also save that into a

and we can also save that into a

and we can also save that into a variable so let's actually call that

variable so let's actually call that

variable so let's actually call that product list so now we have read the

product list so now we have read the

product list so now we have read the whole file then we have read this

whole file then we have read this

whole file then we have read this specific sheet of that file

specific sheet of that file

specific sheet of that file and now we have all this information in

and now we have all this information in

and now we have all this information in that variable

that variable

that variable so now we can read any of those values

so now we can read any of those values

so now we can read any of those values and

and

and do calculations etc using that variable

so let's get to our first task and the

so let's get to our first task and the first task is basically to calculate

first task is basically to calculate

first task is basically to calculate how many products we have per supplier

how many products we have per supplier

how many products we have per supplier and then list the names of the suppliers

and then list the names of the suppliers

and then list the names of the suppliers with that

with that

with that respective number of products so let's

respective number of products so let's

respective number of products so let's go back and do that

go back and do that

go back and do that so the results what we want to get is

so the results what we want to get is

so the results what we want to get is basically

basically

basically products or number of products

products or number of products

products or number of products per supplier right that's basically what

per supplier right that's basically what

per supplier right that's basically what we want to get as a result

we want to get as a result

we want to get as a result so we're going to create that variable

so we're going to create that variable

so we're going to create that variable and we're going to set it

and we're going to set it

and we're going to set it to an empty dictionary so

to an empty dictionary so

to an empty dictionary so by the end our program should give us

by the end our program should give us

by the end our program should give us something like this

something like this

something like this a dictionary where the name of the

a dictionary where the name of the

a dictionary where the name of the company is the key

company is the key

company is the key and the value is basically product count

and the value is basically product count

and the value is basically product count for that company and since we have

for that company and since we have

for that company and since we have three suppliers or three companies we're

three suppliers or three companies we're

three suppliers or three companies we're gonna end up with

gonna end up with

gonna end up with a dictionary with three key value pairs

a dictionary with three key value pairs

a dictionary with three key value pairs per

per

per company so we're starting with an empty

company so we're starting with an empty

company so we're starting with an empty dictionary for products per supplier and

dictionary for products per supplier and

dictionary for products per supplier and now let's see how we can

now let's see how we can

now let's see how we can programmatically calculate this

programmatically calculate this

programmatically calculate this first of all what we need is we need to

first of all what we need is we need to

first of all what we need is we need to go through each of these lines basically

go through each of these lines basically

go through each of these lines basically so we have these rows so we need to go

so we have these rows so we need to go

so we have these rows so we need to go through each and every

through each and every

through each and every row in order in sequence and we need to

row in order in sequence and we need to

row in order in sequence and we need to get

get

get or check a supplier name for that row

or check a supplier name for that row

or check a supplier name for that row and you remember whenever we execute a

and you remember whenever we execute a

and you remember whenever we execute a logic

logic

logic on multiple values over and over again

on multiple values over and over again

on multiple values over and over again so basically same logic or same function

so basically same logic or same function

so basically same logic or same function gets executed

gets executed

gets executed for multiple different values for a

for multiple different values for a

for multiple different values for a number of times

number of times

number of times that's basically a use case for a loop

that's basically a use case for a loop

that's basically a use case for a loop right so we're looping

right so we're looping

right so we're looping through those rows and we're doing the

through those rows and we're doing the

through those rows and we're doing the same thing

same thing

same thing per row which is getting the name of the

per row which is getting the name of the

per row which is getting the name of the supplier now

supplier now

supplier now as you also remember loops have

as you also remember loops have

as you also remember loops have conditions right

conditions right

conditions right we need to tell the loop how many times

we need to tell the loop how many times

we need to tell the loop how many times it should execute

it should execute

it should execute that specific logic and if we check our

that specific logic and if we check our

that specific logic and if we check our file here

file here

file here how many times we want to execute the

how many times we want to execute the

how many times we want to execute the logic the answer is

logic the answer is

logic the answer is as many times as the number of products

as many times as the number of products

as many times as the number of products so

so

so if we scroll down we have 74

if we scroll down we have 74

if we scroll down we have 74 products so we need to do that 74 times

products so we need to do that 74 times

products so we need to do that 74 times for each product so basically as many

for each product so basically as many

for each product so basically as many times

times

times as the number of product and obviously

as the number of product and obviously

as the number of product and obviously we want this program to work for

we want this program to work for

we want this program to work for any spreadsheet file right with any

any spreadsheet file right with any

any spreadsheet file right with any number of products so we need to

number of products so we need to

number of products so we need to calculate or we need to read that value

calculate or we need to read that value

calculate or we need to read that value also from the file

also from the file

also from the file so basically we need to read how many

so basically we need to read how many

so basically we need to read how many products are on this list

products are on this list

products are on this list so let's see how we can do that first of

so let's see how we can do that first of

so let's see how we can do that first of all we're using

all we're using

all we're using for loop to execute the logic for

for loop to execute the logic for

for loop to execute the logic for specific

specific

specific number of times and if you remember from

number of times and if you remember from

number of times and if you remember from for loop syntax

for loop syntax

for loop syntax four then we have the specific item

four then we have the specific item

four then we have the specific item so what is an item in our case our item

so what is an item in our case our item

so what is an item in our case our item is a row right product row is going to

is a row right product row is going to

is a row right product row is going to be an

be an

be an item of iteration so looping basically

item of iteration so looping basically

item of iteration so looping basically so we can call our item

so we can call our item

so we can call our item products row and then comes in

products row and then comes in

products row and then comes in and now we need that condition how many

and now we need that condition how many

and now we need that condition how many times and again this should be generic

times and again this should be generic

times and again this should be generic so we need to calculate or we need to

so we need to calculate or we need to

so we need to calculate or we need to read

read

read the number of lines here number of rows

the number of lines here number of rows

the number of lines here number of rows here from the file

here from the file

here from the file and the way we can read that is remember

and the way we can read that is remember

and the way we can read that is remember we have all the information we need in

we have all the information we need in

we have all the information we need in that

that

that one specific variable which is product

one specific variable which is product

one specific variable which is product list

list

list and that variable has

and that variable has

and that variable has the value for number of rows which is

the value for number of rows which is

the value for number of rows which is called

called

called max row now how do i know that

max row now how do i know that

max row now how do i know that max row attribute is available for

max row attribute is available for

max row attribute is available for product

product

product list i basically just looked it up on

list i basically just looked it up on

list i basically just looked it up on the documentation of the module

the documentation of the module

the documentation of the module and as i previously also mentioned

and as i previously also mentioned

and as i previously also mentioned whenever you're using a

whenever you're using a

whenever you're using a module this module will have a

module this module will have a

module this module will have a documentation so

documentation so

documentation so if you need some functionality if you

if you need some functionality if you

if you need some functionality if you need some values

need some values

need some values you can basically just search inside the

you can basically just search inside the

you can basically just search inside the documentation

documentation

documentation which functions and variables are

which functions and variables are

which functions and variables are available to

available to

available to get the functionality or values that you

get the functionality or values that you

get the functionality or values that you need

need

need and we can actually test it we can print

and we can actually test it we can print

and we can actually test it we can print it out

it out

it out like this

and as you see here 75 so basically max

and as you see here 75 so basically max row will always give us the number of

row will always give us the number of

row will always give us the number of lines or number of rows

lines or number of rows

lines or number of rows in that specific sheet so we know how

in that specific sheet so we know how

in that specific sheet so we know how many times to

many times to

many times to iterate now whenever we're providing a

iterate now whenever we're providing a

iterate now whenever we're providing a specific

specific

specific number in a for loop like 75 for example

number in a for loop like 75 for example

number in a for loop like 75 for example in this case we need to

in this case we need to

in this case we need to put that number in a range like this

put that number in a range like this

put that number in a range like this so we can't just say 70 or in this case

so we can't just say 70 or in this case

so we can't just say 70 or in this case max row now why do we need a range here

max row now why do we need a range here

max row now why do we need a range here and why is number just not enough

and why is number just not enough

and why is number just not enough because the for loop is for iterating

because the for loop is for iterating

because the for loop is for iterating over a list and the range will create

over a list and the range will create

over a list and the range will create a list of numbers to iterate through

a list of numbers to iterate through

a list of numbers to iterate through in our case range of 75

in our case range of 75

in our case range of 75 will create a list of numbers or

will create a list of numbers or

will create a list of numbers or sequence of numbers

sequence of numbers

sequence of numbers from 0 to 74. and with that we're going

from 0 to 74. and with that we're going

from 0 to 74. and with that we're going to have

to have

to have a valid for loop where for each

a valid for loop where for each

a valid for loop where for each item in this list of numbers

item in this list of numbers

item in this list of numbers some logic will be executed so that's

some logic will be executed so that's

some logic will be executed so that's why we need a range here

why we need a range here

why we need a range here and now there's one more thing that we

and now there's one more thing that we

and now there's one more thing that we need to fix we go back to our

need to fix we go back to our

need to fix we go back to our spreadsheet

spreadsheet

spreadsheet you see that the first row so this is

you see that the first row so this is

you see that the first row so this is going to be the first row basically

going to be the first row basically

going to be the first row basically does not actually include the product

does not actually include the product

does not actually include the product information

information

information it just includes the titles for each

it just includes the titles for each

it just includes the titles for each column

column

column right so we actually do not want to read

right so we actually do not want to read

right so we actually do not want to read this line we want to skip it and we want

this line we want to skip it and we want

this line we want to skip it and we want to start from the second row

to start from the second row

to start from the second row so instead of starting for loop from the

so instead of starting for loop from the

so instead of starting for loop from the first row

first row

first row we want to start it from the second row

we want to start it from the second row

we want to start it from the second row and in order to

and in order to

and in order to tell python to start at row 2

tell python to start at row 2

tell python to start at row 2 in the range function we're going to

in the range function we're going to

in the range function we're going to pass first parameter

pass first parameter

pass first parameter 2. so basically this will give us a new

2. so basically this will give us a new

2. so basically this will give us a new range of numbers

range of numbers

range of numbers starting from 2 instead of starting from

starting from 2 instead of starting from

starting from 2 instead of starting from 0. and since we're using those

0. and since we're using those

0. and since we're using those numbers in the range as an index for the

numbers in the range as an index for the

numbers in the range as an index for the rows

rows

rows the first number is going to be 2 so

the first number is going to be 2 so

the first number is going to be 2 so we're going to start iterating from the

we're going to start iterating from the

we're going to start iterating from the second row

second row

second row so this will be the start point and this

so this will be the start point and this

so this will be the start point and this will be the end point

will be the end point

will be the end point so basically from here to the end

so basically from here to the end

so basically from here to the end now there are two things specific

now there are two things specific

now there are two things specific to a range that you should be aware of

to a range that you should be aware of

to a range that you should be aware of first of all when we do not

first of all when we do not

first of all when we do not provide the start index basically

provide the start index basically

provide the start index basically the start number in the range by default

the start number in the range by default

the start number in the range by default it's actually

it's actually

it's actually zero so it's not one but it's zero

zero so it's not one but it's zero

zero so it's not one but it's zero and obviously we don't have a line zero

and obviously we don't have a line zero

and obviously we don't have a line zero here

here

here so if we executed it with the default

so if we executed it with the default

so if we executed it with the default one

one

one we would get an error so that's one

we would get an error so that's one

we would get an error so that's one thing to consider that

thing to consider that

thing to consider that range actually by default starts at 0

range actually by default starts at 0

range actually by default starts at 0 and not 1. but for us it doesn't matter

and not 1. but for us it doesn't matter

and not 1. but for us it doesn't matter because we're skipping the first one

because we're skipping the first one

because we're skipping the first one anyways and we're starting from line 2

anyways and we're starting from line 2

anyways and we're starting from line 2 because our spreadsheet doesn't have

because our spreadsheet doesn't have

because our spreadsheet doesn't have line 0

line 0

line 0 obviously another specific of the range

obviously another specific of the range

obviously another specific of the range is that

is that

is that the second value here basically the last

the second value here basically the last

the second value here basically the last number of execution in the loop in our

number of execution in the loop in our

number of execution in the loop in our case this is going to be 75

case this is going to be 75

case this is going to be 75 because we have 75 lines and we printed

because we have 75 lines and we printed

because we have 75 lines and we printed that out here

that out here

that out here that number is actually exclusive

that number is actually exclusive

that number is actually exclusive it's not inclusive that means that

it's not inclusive that means that

it's not inclusive that means that the range will execute from line 2

the range will execute from line 2

the range will execute from line 2 to 75 exclusive so basically

to 75 exclusive so basically

to 75 exclusive so basically till here this line will not be included

till here this line will not be included

till here this line will not be included in the loop

in the loop

in the loop again that's a specification of the

again that's a specification of the

again that's a specification of the range

range

range which we need to fix and

which we need to fix and

which we need to fix and basically want to tell you know what we

basically want to tell you know what we

basically want to tell you know what we want that iteration

want that iteration

want that iteration including the last number as well

including the last number as well

including the last number as well including that max row

including that max row

including that max row and a simple fix for that is going to be

and a simple fix for that is going to be

and a simple fix for that is going to be to

to

to do plus one here so basically whatever

do plus one here so basically whatever

do plus one here so basically whatever the max row is we want to include that

the max row is we want to include that

the max row is we want to include that one as well

one as well

one as well so we want to add one to it so now we

so we want to add one to it so now we

so we want to add one to it so now we have a range

have a range

have a range starting from two and ending in 76

starting from two and ending in 76

starting from two and ending in 76 exclusive so obviously the 76th

exclusive so obviously the 76th

exclusive so obviously the 76th line will not be red and

line will not be red and

line will not be red and this will now give us a range that we

this will now give us a range that we

this will now give us a range that we need

and now that we have condition for the

and now that we have condition for the loop and we have set

loop and we have set

loop and we have set how many times it should execute let's

how many times it should execute let's

how many times it should execute let's actually execute the logic

actually execute the logic

actually execute the logic itself so what is the first information

itself so what is the first information

itself so what is the first information we need from that

we need from that

we need from that product row for each row we basically

product row for each row we basically

product row for each row we basically need the supplier name

need the supplier name

need the supplier name so that we can increment or start

so that we can increment or start

so that we can increment or start counting how many

counting how many

counting how many products this supplier has so we need

products this supplier has so we need

products this supplier has so we need this

this

this one two three fourth column and the

one two three fourth column and the

one two three fourth column and the value in that fourth column

value in that fourth column

value in that fourth column for each and every row right

for each and every row right

for each and every row right let's go back to editor how do we get a

let's go back to editor how do we get a

let's go back to editor how do we get a value

value

value in the cell you have to imagine when we

in the cell you have to imagine when we

in the cell you have to imagine when we iterate we have

iterate we have

iterate we have one row per iteration

one row per iteration

one row per iteration so right here we actually have this

so right here we actually have this

so right here we actually have this product row which is just

product row which is just

product row which is just one row and we have four columns here

one row and we have four columns here

one row and we have four columns here and we want

and we want

and we want value in this specific cell and

value in this specific cell and

value in this specific cell and we can get it using first of all product

we can get it using first of all product

we can get it using first of all product list

list

list because again we have all the

because again we have all the

because again we have all the information here so in this list

information here so in this list

information here so in this list we need a cell right we need a value of

we need a cell right we need a value of

we need a cell right we need a value of a

a

a cell so that's the name of the function

cell so that's the name of the function

cell so that's the name of the function and the cell basically takes two

and the cell basically takes two

and the cell basically takes two parameters again product list

parameters again product list

parameters again product list contains the whole sheet here so the

contains the whole sheet here so the

contains the whole sheet here so the whole list

whole list

whole list with all the rows and columns and we can

with all the rows and columns and we can

with all the rows and columns and we can get a specific

get a specific

get a specific cell value so whatever we are doesn't

cell value so whatever we are doesn't

cell value so whatever we are doesn't really matter

really matter

really matter from that variable by providing two

from that variable by providing two

from that variable by providing two values

values

values the row number and the column number

the row number and the column number

the row number and the column number that's it

that's it

that's it so row nine column one basically will be

so row nine column one basically will be

so row nine column one basically will be this specific value row five column

this specific value row five column

this specific value row five column four will be this specific value so

four will be this specific value so

four will be this specific value so for each iteration we're gonna do

for each iteration we're gonna do

for each iteration we're gonna do exactly

exactly

exactly that so for our case the supplier is

that so for our case the supplier is

that so for our case the supplier is always column four

always column four

always column four and the row is dynamic because we are

and the row is dynamic because we are

and the row is dynamic because we are iterating

iterating

iterating and therefore we're going to use

and therefore we're going to use

and therefore we're going to use whatever row we're at at the current

whatever row we're at at the current

whatever row we're at at the current iteration

iteration

iteration so that's the first parameter and column

so that's the first parameter and column

so that's the first parameter and column 4 as i said and this will give us

4 as i said and this will give us

4 as i said and this will give us the supplier name for each and every

the supplier name for each and every

the supplier name for each and every row so we can grab that value like this

row so we can grab that value like this

row so we can grab that value like this and this is going to be supplier

name so we can save it in a variable

name so we can save it in a variable as a next step we're going to start

as a next step we're going to start

as a next step we're going to start building

building

building how many products each supplier has

how many products each supplier has

how many products each supplier has we're going to start building a

we're going to start building a

we're going to start building a dictionary

dictionary

dictionary with the name of the supplier and then

with the name of the supplier and then

with the name of the supplier and then how many products they have

how many products they have

how many products they have so we're going to be building this

so we're going to be building this

so we're going to be building this dictionary here

dictionary here

dictionary here so this is a reminder now for what i

so this is a reminder now for what i

so this is a reminder now for what i said previously

said previously

said previously that you don't need knowledge of math in

that you don't need knowledge of math in

that you don't need knowledge of math in programming

programming

programming rather you need logical thinking right

rather you need logical thinking right

rather you need logical thinking right so you're going to get tasks like this

so you're going to get tasks like this

so you're going to get tasks like this where you have to

where you have to

where you have to basically logically decide how you are

basically logically decide how you are

basically logically decide how you are going to do a certain task

going to do a certain task

going to do a certain task and think all this through right so

and think all this through right so

and think all this through right so programming is more about logic rather

programming is more about logic rather

programming is more about logic rather than pure calculation or math

than pure calculation or math

than pure calculation or math which is actually more interesting and

which is actually more interesting and

which is actually more interesting and cooler and that's exactly

cooler and that's exactly

cooler and that's exactly what we're going to need in this example

what we're going to need in this example

what we're going to need in this example we're going to need some

we're going to need some

we're going to need some logical thinking to basically build this

logical thinking to basically build this

logical thinking to basically build this application

application

application so bear with me on this one the first

so bear with me on this one the first

so bear with me on this one the first thing we need to check here

thing we need to check here

thing we need to check here so think about this iteration on the

so think about this iteration on the

so think about this iteration on the first time

first time

first time and second time the first time the list

and second time the first time the list

and second time the first time the list or the dictionary is actually

or the dictionary is actually

or the dictionary is actually empty so we want to add the first

empty so we want to add the first

empty so we want to add the first supplier to the list right away right

supplier to the list right away right

supplier to the list right away right so we're gonna grab that and the syntax

so we're gonna grab that and the syntax

so we're gonna grab that and the syntax for

for

for adding a new entry in a dictionary is

adding a new entry in a dictionary is

adding a new entry in a dictionary is like this where we have a key

like this where we have a key

like this where we have a key and a value here so basically what we

and a value here so basically what we

and a value here so basically what we want to end up with

want to end up with

want to end up with is supplier name like a

is supplier name like a

is supplier name like a company and

company and

company and number of products for that supplier

number of products for that supplier

number of products for that supplier that's the

that's the

that's the dictionary that we want to end up with

dictionary that we want to end up with

dictionary that we want to end up with then it's going to be

then it's going to be

then it's going to be bbb company and so on

so the very first supplier goes directly

so the very first supplier goes directly into the list

into the list

into the list and we're going to need the name of that

and we're going to need the name of that

and we're going to need the name of that supplier we don't know what it's going

supplier we don't know what it's going

supplier we don't know what it's going to be

to be

to be so name as a key

so name as a key

so name as a key and value is going to be

and value is going to be

and value is going to be 1 at the beginning right this is the

1 at the beginning right this is the

1 at the beginning right this is the very first iteration

very first iteration

very first iteration so after the first it iteration we're

so after the first it iteration we're

so after the first it iteration we're gonna have

gonna have

gonna have the first company name supplier name and

the first company name supplier name and

the first company name supplier name and count one for that on the second loop

count one for that on the second loop

count one for that on the second loop second iteration basically if

second iteration basically if

second iteration basically if the next line is a different supplier

the next line is a different supplier

the next line is a different supplier like here for example then a new entry

like here for example then a new entry

like here for example then a new entry will be added

will be added

will be added because we have a new key now with

because we have a new key now with

because we have a new key now with count one right so now we're gonna have

count one right so now we're gonna have

count one right so now we're gonna have company a

company a

company a with one product company b with one

with one product company b with one

with one product company b with one product

product

product now what happens when on the next

now what happens when on the next

now what happens when on the next iteration

iteration

iteration we get company a again right

we get company a again right

we get company a again right what we want to happen is

what we want to happen is

what we want to happen is company a the product count to

company a the product count to

company a the product count to increase to two right because now we

increase to two right because now we

increase to two right because now we found another product that

found another product that

found another product that is supplied by the same company however

is supplied by the same company however

is supplied by the same company however with this land we are actually

with this land we are actually

with this land we are actually overriding and setting it

overriding and setting it

overriding and setting it back to one so how do we make sure that

back to one so how do we make sure that

back to one so how do we make sure that number of products gets incremented

number of products gets incremented

number of products gets incremented instead of always setting it to one

instead of always setting it to one

instead of always setting it to one what we're going to do is before we

what we're going to do is before we

what we're going to do is before we execute this line

execute this line

execute this line we're going to check is it a new

we're going to check is it a new

we're going to check is it a new supplier or

supplier or

supplier or an existing one because that makes a

an existing one because that makes a

an existing one because that makes a difference

difference

difference so how do we know if it's a new one or

so how do we know if it's a new one or

so how do we know if it's a new one or an existing one

an existing one

an existing one we can look that name up in the

we can look that name up in the

we can look that name up in the dictionary

dictionary

dictionary if we have already edited that name in

if we have already edited that name in

if we have already edited that name in the dictionary then it's going to be

the dictionary then it's going to be

the dictionary then it's going to be there

there

there and we can do that very easily again

and we can do that very easily again

and we can do that very easily again with the syntax

with the syntax

with the syntax if supplier name in

if supplier name in

if supplier name in the dictionary it's actually very

the dictionary it's actually very

the dictionary it's actually very readable syntax that says is the

readable syntax that says is the

readable syntax that says is the supplier

supplier

supplier already added to the list or is it a new

already added to the list or is it a new

already added to the list or is it a new one

one

one so if this is true again

so if this is true again

so if this is true again remember if conditional so if this

remember if conditional so if this

remember if conditional so if this is true statement if the supplier name

is true statement if the supplier name

is true statement if the supplier name is already there

is already there

is already there then it is an existing one so we need to

then it is an existing one so we need to

then it is an existing one so we need to increment

increment

increment the product number instead of setting it

the product number instead of setting it

the product number instead of setting it to one

to one

to one so instead of assigning a new value we

so instead of assigning a new value we

so instead of assigning a new value we want to

want to

want to grab that value the existing one and

grab that value the existing one and

grab that value the existing one and basically add

basically add

basically add one to it right just increment by one so

one to it right just increment by one so

one to it right just increment by one so getting a value from a dictionary you

getting a value from a dictionary you

getting a value from a dictionary you probably remember the syntax already

probably remember the syntax already

probably remember the syntax already using the key and we can save it into

using the key and we can save it into

using the key and we can save it into a variable let's call it current

a variable let's call it current

a variable let's call it current number of products

like this remember we're using a key

like this remember we're using a key in order to get the value and the key is

in order to get the value and the key is

in order to get the value and the key is the supplier name

the supplier name

the supplier name value is the product count so this will

value is the product count so this will

value is the product count so this will give us

give us

give us the current number of products on the

the current number of products on the

the current number of products on the first iteration this will be one

first iteration this will be one

first iteration this will be one or after the first iteration we're going

or after the first iteration we're going

or after the first iteration we're going to have one product for that specific

to have one product for that specific

to have one product for that specific supplier

supplier

supplier and if we already have that supplier

and if we already have that supplier

and if we already have that supplier in the dictionary we want to increment

in the dictionary we want to increment

in the dictionary we want to increment the number of products for that specific

the number of products for that specific

the number of products for that specific supplier by one

supplier by one

supplier by one because we just found another product

because we just found another product

because we just found another product from that supplier

from that supplier

from that supplier so we want this value to now be

so we want this value to now be

so we want this value to now be plus one right so current number of

plus one right so current number of

plus one right so current number of products

products

products plus one so that's the new value that we

plus one so that's the new value that we

plus one so that's the new value that we want

want

want for the existing for this current

for the existing for this current

for the existing for this current supplier and how do we assign it back

supplier and how do we assign it back

supplier and how do we assign it back to the dictionary again we grab that

to the dictionary again we grab that

to the dictionary again we grab that and assign it so as you see

and assign it so as you see

and assign it so as you see taking the value from the dictionary has

taking the value from the dictionary has

taking the value from the dictionary has the same syntax as

the same syntax as

the same syntax as setting that value in the dictionary

setting that value in the dictionary

setting that value in the dictionary in fact we could actually use a shortcut

in fact we could actually use a shortcut

in fact we could actually use a shortcut here

here

here so instead of current numproducts we

so instead of current numproducts we

so instead of current numproducts we could just

could just

could just take that value and add plus to it and

take that value and add plus to it and

take that value and add plus to it and then

then

then set it back as a new value and

set it back as a new value and

set it back as a new value and this will basically just give us a

this will basically just give us a

this will basically just give us a one-liner for the logic

one-liner for the logic

one-liner for the logic depends on the taste whether this looks

depends on the taste whether this looks

depends on the taste whether this looks nice or not

nice or not

nice or not or whether it's better to have a new

or whether it's better to have a new

or whether it's better to have a new variable and

variable and

variable and increment the value like this let's

increment the value like this let's

increment the value like this let's actually leave it like this

actually leave it like this

actually leave it like this so this logic will take care of adding a

so this logic will take care of adding a

so this logic will take care of adding a product count

product count

product count every time we find another product for

every time we find another product for

every time we find another product for the same supplier

the same supplier

the same supplier however now we have to decide what

however now we have to decide what

however now we have to decide what happens

happens

happens when it's a new supplier so if this

when it's a new supplier so if this

when it's a new supplier so if this condition

condition

condition is false if the supplier name is not on

is false if the supplier name is not on

is false if the supplier name is not on the list

the list

the list and this is going to be the case on the

and this is going to be the case on the

and this is going to be the case on the very first iteration

very first iteration

very first iteration as well because the dictionary is

as well because the dictionary is

as well because the dictionary is basically

basically

basically empty so there are no supplier names and

empty so there are no supplier names and

empty so there are no supplier names and for that case

for that case

for that case else we're going to do what we had

else we're going to do what we had

else we're going to do what we had before

before

before which is just setting that number to one

which is just setting that number to one

which is just setting that number to one right this is going to be the first

right this is going to be the first

right this is going to be the first value so this will do

value so this will do

value so this will do two things basically it will create

two things basically it will create

two things basically it will create a new entry in this dictionary for this

a new entry in this dictionary for this

a new entry in this dictionary for this new supplier

new supplier

new supplier and it will set the product count number

and it will set the product count number

and it will set the product count number to one for that new supplier and that's

to one for that new supplier and that's

to one for that new supplier and that's it that's actually our logic

it that's actually our logic

it that's actually our logic and let's actually try this out and

and let's actually try this out and

and let's actually try this out and print it out

print it out

print it out so right here i'm gonna print

so right here i'm gonna print

so right here i'm gonna print adding a new supplier

adding a new supplier

adding a new supplier and this is going to happen three times

and this is going to happen three times

and this is going to happen three times because we have three suppliers

because we have three suppliers

because we have three suppliers so we can safely print it because just

so we can safely print it because just

so we can safely print it because just gonna happen three times

gonna happen three times

gonna happen three times there is one more thing we need to fix

there is one more thing we need to fix

there is one more thing we need to fix here and that is

here and that is

here and that is getting the value from the cell so if we

getting the value from the cell so if we

getting the value from the cell so if we actually

actually

actually execute this now let's comment this out

execute this now let's comment this out

execute this now let's comment this out and actually print out

and actually print out

and actually print out what the supplier name here is

what the supplier name here is

what the supplier name here is let's actually get rid of this line we

let's actually get rid of this line we

let's actually get rid of this line we don't need this

don't need this

don't need this and run the program you see here we have

and run the program you see here we have

and run the program you see here we have cell information so it's not actually

cell information so it's not actually

cell information so it's not actually the

the

the the value the name of the supplier but

the value the name of the supplier but

the value the name of the supplier but it's just

it's just

it's just the object cell and the reason for that

the object cell and the reason for that

the object cell and the reason for that is because we're accessing a cell but

is because we're accessing a cell but

is because we're accessing a cell but we're not actually extracting or getting

we're not actually extracting or getting

we're not actually extracting or getting the value out of it

the value out of it

the value out of it and we can do that using this value

and we can do that using this value

and we can do that using this value attribute on that complete object

attribute on that complete object

attribute on that complete object again something that you can look up in

again something that you can look up in

again something that you can look up in the documentation of

the documentation of

the documentation of this open pi xl module

this open pi xl module

this open pi xl module so now let's run it again and now we

so now let's run it again and now we

so now let's run it again and now we have

have

have the actual values of that cell

the actual values of that cell

the actual values of that cell and this will take care of that small

and this will take care of that small

and this will take care of that small problem and now we are ready to

problem and now we are ready to

problem and now we are ready to execute our

execute our

execute our program and after the for loop actually

program and after the for loop actually

program and after the for loop actually let's print out the

let's print out the

let's print out the dictionary because we want to see the

dictionary because we want to see the

dictionary because we want to see the results of the dictionary that we are

results of the dictionary that we are

results of the dictionary that we are building here

building here

building here and i'm going to execute it now

and i'm going to execute it now

and i'm going to execute it now and there you go first of all we have

and there you go first of all we have

and there you go first of all we have three times adding a new supplier

three times adding a new supplier

three times adding a new supplier because we have three suppliers and this

because we have three suppliers and this

because we have three suppliers and this is the

is the

is the resulting dictionary and it looks

resulting dictionary and it looks

resulting dictionary and it looks actually very good

actually very good

actually very good first we have company a because this was

first we have company a because this was

first we have company a because this was the first on the list

the first on the list

the first on the list and we have number of products that were

and we have number of products that were

and we have number of products that were counted

counted

counted for that company then we have the second

for that company then we have the second

for that company then we have the second one

one

one with number of products and the third

with number of products and the third

with number of products and the third one

one

one so it looks like our program did exactly

so it looks like our program did exactly

so it looks like our program did exactly what we wanted

so that takes care of the first exercise

so that takes care of the first exercise now i want to note here

now i want to note here

now i want to note here one small thing which is an alternative

one small thing which is an alternative

one small thing which is an alternative syntax for

syntax for

syntax for getting values from a dictionary which

getting values from a dictionary which

getting values from a dictionary which is actually

is actually

is actually a more recommended way of doing it which

a more recommended way of doing it which

a more recommended way of doing it which is instead of

is instead of

is instead of having these brackets here

having these brackets here

having these brackets here to have a get method right

to have a get method right

to have a get method right to use a get function

with the key name so now you see the

with the key name so now you see the difference between those two

difference between those two

difference between those two so this is setting the value of that key

so this is setting the value of that key

so this is setting the value of that key again remember key is this one here and

again remember key is this one here and

again remember key is this one here and this is the value

this is the value

this is the value so we are accessing the value of the

so we are accessing the value of the

so we are accessing the value of the dictionary using that key

dictionary using that key

dictionary using that key and get function is actually

and get function is actually

and get function is actually another way of grabbing this value out

another way of grabbing this value out

another way of grabbing this value out of a dictionary using the key name

of a dictionary using the key name

of a dictionary using the key name again if i execute this i should see

again if i execute this i should see

again if i execute this i should see the same result

after the first exercise basically we

after the first exercise basically we see from which company

see from which company

see from which company from which supplier we have the most

from which supplier we have the most

from which supplier we have the most product or the highest number of

product or the highest number of

product or the highest number of products now in the second exercise

products now in the second exercise

products now in the second exercise we're going to calculate

we're going to calculate

we're going to calculate the total inventory value per supplier

the total inventory value per supplier

the total inventory value per supplier meaning in our list for each product we

meaning in our list for each product we

meaning in our list for each product we have

have

have number of units for the product and the

number of units for the product and the

number of units for the product and the price so basically for

price so basically for

price so basically for each supplier we want to calculate how

each supplier we want to calculate how

each supplier we want to calculate how much is the total

much is the total

much is the total value of inventory of their products

value of inventory of their products

value of inventory of their products of all their products and again as a

of all their products and again as a

of all their products and again as a result

result

result we want to create a dictionary that

we want to create a dictionary that

we want to create a dictionary that basically tells

basically tells

basically tells us that value per company let's go ahead

us that value per company let's go ahead

us that value per company let's go ahead and do that

and do that

and do that so this was calculation

calculation for number

calculation for number of products per

of products per

of products per supplier

and here we're going to give us some

and here we're going to give us some space

and do calculation

and do calculation total value per

total value per

total value per supplier or total value of inventory

supplier or total value of inventory

supplier or total value of inventory per supplier that's what we want to

per supplier that's what we want to

per supplier that's what we want to calculate

calculate

calculate so just like we did before we're going

so just like we did before we're going

so just like we did before we're going to create a new dictionary now

to create a new dictionary now

to create a new dictionary now and we're going to call it appropriately

and we're going to call it appropriately

and we're going to call it appropriately total value

total value

total value per supplier

per supplier

per supplier and start with an empty dictionary

and start with an empty dictionary

and start with an empty dictionary again for starting in an easy way let's

again for starting in an easy way let's

again for starting in an easy way let's consider the first

consider the first

consider the first very first iteration for the first

very first iteration for the first

very first iteration for the first supplier

supplier

supplier how are we going to calculate for the

how are we going to calculate for the

how are we going to calculate for the first supplier

first supplier

first supplier for the first product so i'm going to

for the first product so i'm going to

for the first product so i'm going to take this new dictionary and

take this new dictionary and

take this new dictionary and with our familiar syntax i'm gonna do

with our familiar syntax i'm gonna do

with our familiar syntax i'm gonna do supplier name so that's gonna be our key

supplier name so that's gonna be our key

supplier name so that's gonna be our key and the value

and the value

and the value of the very first iteration for the

of the very first iteration for the

of the very first iteration for the first product

first product

first product is going to be inventory

is going to be inventory

is going to be inventory times price so for the first product

times price so for the first product

times price so for the first product we're going to calculate how much

we're going to calculate how much

we're going to calculate how much or how many of the product items we have

or how many of the product items we have

or how many of the product items we have and

and

and number of price right that will give us

number of price right that will give us

number of price right that will give us value of the total inventory for

value of the total inventory for

value of the total inventory for that one specific product and that means

that one specific product and that means

that one specific product and that means we need those two values

we need those two values

we need those two values right now we're just getting the value

right now we're just getting the value

right now we're just getting the value of the supplier

of the supplier

of the supplier so we need inventory

i'm actually going to copy this so we

i'm actually going to copy this so we need

need

need cell for product row and

cell for product row and

cell for product row and column inventory is on column two

column inventory is on column two

column inventory is on column two and value so whatever the product row is

and value so whatever the product row is

and value so whatever the product row is going to be so for each product

going to be so for each product

going to be so for each product basically for each row

basically for each row

basically for each row we need always the second column so all

we need always the second column so all

we need always the second column so all these values here

these values here

these values here and then we need price which

and then we need price which

and then we need price which going to be product list cell

going to be product list cell

going to be product list cell and we are looking for

the third column for every row

the third column for every row number three and value

number three and value

number three and value so now we have inventory and price per

so now we have inventory and price per

so now we have inventory and price per product and the way to calculate

product and the way to calculate

product and the way to calculate value is basically inventory that's the

value is basically inventory that's the

value is basically inventory that's the number of

number of

number of product items times price very easy

product items times price very easy

product items times price very easy that will give us the first value

that will give us the first value

that will give us the first value for the first supplier now again the

for the first supplier now again the

for the first supplier now again the same way

same way

same way if we are getting a new supplier so

if we are getting a new supplier so

if we are getting a new supplier so basically in the next iteration

basically in the next iteration

basically in the next iteration if it's a new supplier then this line

if it's a new supplier then this line

if it's a new supplier then this line will get executed and everything is fine

will get executed and everything is fine

will get executed and everything is fine however if it's an existing supplier

however if it's an existing supplier

however if it's an existing supplier that we already have in the dictionary

that we already have in the dictionary

that we already have in the dictionary then we have to add to that previous

then we have to add to that previous

then we have to add to that previous value right instead of setting a new one

value right instead of setting a new one

value right instead of setting a new one so we're going to do very similar logic

so we're going to do very similar logic

so we're going to do very similar logic as we did here

as we did here

as we did here so we have the supplier name we're

so we have the supplier name we're

so we have the supplier name we're checking

checking

checking is it a new supplier or an old one an

is it a new supplier or an old one an

is it a new supplier or an old one an existing one

existing one

existing one this time in our new dictionary

this time in our new dictionary

this time in our new dictionary and if it is we're gonna

and if it is we're gonna

and if it is we're gonna grab that old or existing value

grab that old or existing value

grab that old or existing value again using this get syntax here

existing value now is hundred we want to

existing value now is hundred we want to add to that hundred right

add to that hundred right

add to that hundred right so we're gonna grab that value this is

so we're gonna grab that value this is

so we're gonna grab that value this is going to be current

going to be current

going to be current total value

total value

total value and then we're going to add to that

and then we're going to add to that

and then we're going to add to that current total value

the inventory value for the current

the inventory value for the current product and assign it back to

product and assign it back to

product and assign it back to our dictionary

now our variable names a little bit

now our variable names a little bit long so the code kind of looks a bit

long so the code kind of looks a bit

long so the code kind of looks a bit cluttered

cluttered

cluttered but it's easy to read and descriptive so

but it's easy to read and descriptive so

but it's easy to read and descriptive so you can also go for shorter variable

you can also go for shorter variable

you can also go for shorter variable names to have a cleaner code

names to have a cleaner code

names to have a cleaner code again matter of taste i usually name the

again matter of taste i usually name the

again matter of taste i usually name the variables

variables

variables something descriptive something that

something descriptive something that

something descriptive something that basically really

basically really

basically really differentiates or says what the value is

differentiates or says what the value is

differentiates or says what the value is about

about

about and that basically takes care of

and that basically takes care of

and that basically takes care of existing suppliers or the suppliers that

existing suppliers or the suppliers that

existing suppliers or the suppliers that we already

we already

we already have in the dictionary else we do

have in the dictionary else we do

have in the dictionary else we do this and this is complaining about

this and this is complaining about

this and this is complaining about too many blank lines so let's fix that

too many blank lines so let's fix that

too many blank lines so let's fix that and

and

and that's basically our logic again to go

that's basically our logic again to go

that's basically our logic again to go through it once

through it once

through it once for new suppliers again this is going to

for new suppliers again this is going to

for new suppliers again this is going to happen three times because we have three

happen three times because we have three

happen three times because we have three suppliers

suppliers

suppliers we are basically setting the total

we are basically setting the total

we are basically setting the total inventory price or inventory value for

inventory price or inventory value for

inventory price or inventory value for that specific product

that specific product

that specific product because remember we are iterating

because remember we are iterating

because remember we are iterating through products

through products

through products and then every time a new product

and then every time a new product

and then every time a new product iteration happens for the same supplier

iteration happens for the same supplier

iteration happens for the same supplier we basically just

we basically just

we basically just add an inventory price or total value

add an inventory price or total value

add an inventory price or total value for that specific product

for that specific product

for that specific product for what we already have in the

for what we already have in the

for what we already have in the dictionary

dictionary

dictionary for that specific supplier so now

for that specific supplier so now

for that specific supplier so now let's again print out

let's again print out

let's again print out our dictionary

our dictionary

our dictionary let's actually print both values

so the first dictionary is this one

so the first dictionary is this one right here

right here

right here supplier and number of products second

supplier and number of products second

supplier and number of products second one

one

one is going to be supplier and total value

is going to be supplier and total value

is going to be supplier and total value of all the products they have in the

of all the products they have in the

of all the products they have in the inventory

inventory

inventory with us execute and there you go we have

with us execute and there you go we have

with us execute and there you go we have both dictionaries printed here and here

both dictionaries printed here and here

both dictionaries printed here and here you see

you see

you see for each company we have the value

for each company we have the value

for each company we have the value in price basically right here the value

in price basically right here the value

in price basically right here the value for the total inventory of all the

for the total inventory of all the

for the total inventory of all the products they have

products they have

products they have on this list and we see that value

on this list and we see that value

on this list and we see that value per supplier and the values are

per supplier and the values are

per supplier and the values are decimal numbers with cent precision so

decimal numbers with cent precision so

decimal numbers with cent precision so 95

95

95 cents 47 cents because the prices

cents 47 cents because the prices

cents 47 cents because the prices are obviously like this as well and if

are obviously like this as well and if

are obviously like this as well and if you're wondering this

you're wondering this

you're wondering this comma here is actually a german format

comma here is actually a german format

comma here is actually a german format for number precision so this is going to

for number precision so this is going to

for number precision so this is going to be actually equivalent to

be actually equivalent to

be actually equivalent to english dot and we don't have to worry

english dot and we don't have to worry

english dot and we don't have to worry about this actually because

about this actually because

about this actually because python reads it and

python reads it and

python reads it and interprets it correctly so no problem

interprets it correctly so no problem

interprets it correctly so no problem with

with

with different language formats so that takes

different language formats so that takes

different language formats so that takes care of

care of

care of our second calculation

our second calculation

our second calculation now the third logic we're going to write

now the third logic we're going to write

now the third logic we're going to write is basically printing out

is basically printing out

is basically printing out all the products that have inventory

all the products that have inventory

all the products that have inventory less than 10

less than 10

less than 10 like this ones here for example so

like this ones here for example so

like this ones here for example so the logic for that is actually going to

the logic for that is actually going to

the logic for that is actually going to be pretty easy

be pretty easy

be pretty easy what we need as a result is again a

what we need as a result is again a

what we need as a result is again a dictionary

dictionary

dictionary let's call it products which have

let's call it products which have

let's call it products which have inventory under 10

like this and the value in the

like this and the value in the dictionary

dictionary

dictionary should be the product number

should be the product number

should be the product number which we have in the first column and

which we have in the first column and

which we have in the first column and the inventory count so let's get rid of

the inventory count so let's get rid of

the inventory count so let's get rid of these print statements

these print statements

these print statements and let's do calculation

and let's do calculation

and let's do calculation or we can do logic products

or we can do logic products

or we can do logic products with inventory less than

with inventory less than

with inventory less than 10. so basically as i said for each

10. so basically as i said for each

10. so basically as i said for each product

product

product which has inventory under 10 we want to

which has inventory under 10 we want to

which has inventory under 10 we want to print out

print out

print out or we want to save in a dictionary the

or we want to save in a dictionary the

or we want to save in a dictionary the product number

product number

product number and the inventory count so

and the inventory count so

and the inventory count so we have the inventory count already the

we have the inventory count already the

we have the inventory count already the value

value

value from the cell but we don't have the

from the cell but we don't have the

from the cell but we don't have the product number

product number

product number we're not accessing it so let's actually

we're not accessing it so let's actually

we're not accessing it so let's actually do that

do that

do that product number

product number

product number and we already know how this works

and we already know how this works

and we already know how this works this is going to be the first column

this is going to be the first column

this is going to be the first column right

right

right this one here and this gives us

this one here and this gives us

this one here and this gives us product number and now in our dictionary

product number and now in our dictionary

product number and now in our dictionary products under 10

products under 10

products under 10 we want to add value like this product

we want to add value like this product

we want to add value like this product number

number

number and it's going to be set to value of the

and it's going to be set to value of the

and it's going to be set to value of the inventory

inventory

inventory like this however we don't want it for

like this however we don't want it for

like this however we don't want it for every

every

every product we wanted only for products with

product we wanted only for products with

product we wanted only for products with inventory less than 10

inventory less than 10

inventory less than 10 and that's going to be an easy if

and that's going to be an easy if

and that's going to be an easy if conditional here

conditional here

conditional here if inventory again remember

if inventory again remember

if inventory again remember this logic all this logic happens for

this logic all this logic happens for

this logic all this logic happens for each product row right so all these get

each product row right so all these get

each product row right so all these get executed

executed

executed for each of these rows so basically we

for each of these rows so basically we

for each of these rows so basically we have inventory number

have inventory number

have inventory number on each iteration for each specific

on each iteration for each specific

on each iteration for each specific product

product

product and that's why we can just say if

and that's why we can just say if

and that's why we can just say if inventory is less than 10

inventory is less than 10

inventory is less than 10 so if the value on that specific row is

so if the value on that specific row is

so if the value on that specific row is less than 10

less than 10

less than 10 we want to add that product

we want to add that product

we want to add that product the current product that we are

the current product that we are

the current product that we are iterating on

iterating on

iterating on on the list and set the value of

on the list and set the value of

on the list and set the value of inventory as well

inventory as well

inventory as well again we have some complaining here

again we have some complaining here

again we have some complaining here because of the lines

because of the lines

because of the lines and this will be the logic basically

and this will be the logic basically

and this will be the logic basically and a use case for this type of

and a use case for this type of

and a use case for this type of calculation would be

calculation would be

calculation would be if we find products that have inventory

if we find products that have inventory

if we find products that have inventory which are less than 10

which are less than 10

which are less than 10 means we need to reorder them right

means we need to reorder them right

means we need to reorder them right because they're going to get out of

because they're going to get out of

because they're going to get out of stock soon

stock soon

stock soon and now at the end

and now at the end

and now at the end let's print the list of all the products

let's print the list of all the products

let's print the list of all the products that have

that have

that have inventory less than 10. so i'm going to

inventory less than 10. so i'm going to

inventory less than 10. so i'm going to execute it

execute it

execute it and here we have the product number and

and here we have the product number and

and here we have the product number and inventory count so we have three

inventory count so we have three

inventory count so we have three products basically

products basically

products basically which have inventory less than 10 and

which have inventory less than 10 and

which have inventory less than 10 and let's actually

let's actually

let's actually check that product number 25 right here

check that product number 25 right here

check that product number 25 right here which has inventory of seven and product

which has inventory of seven and product

which has inventory of seven and product number

number

number 30 inventory of six

30 inventory of six

30 inventory of six and the third one as well now you're

and the third one as well now you're

and the third one as well now you're probably wondering why we have this dot

probably wondering why we have this dot

probably wondering why we have this dot zero here because by default those

zero here because by default those

zero here because by default those values are interpreted as

values are interpreted as

values are interpreted as float numbers and not integers if we

float numbers and not integers if we

float numbers and not integers if we wanted to we can actually fix that

wanted to we can actually fix that

wanted to we can actually fix that using the integer function

using the integer function

using the integer function in both cases like this

in both cases like this

in both cases like this let's execute it again and we have the

let's execute it again and we have the

let's execute it again and we have the integers and not floats

and finally as a last exercise what

and finally as a last exercise what we're going to do is we're going to

we're going to do is we're going to

we're going to do is we're going to actually

actually

actually add some value inside that spreadsheet

add some value inside that spreadsheet

add some value inside that spreadsheet till now we have been reading the values

till now we have been reading the values

till now we have been reading the values and doing some calculations and just

and doing some calculations and just

and doing some calculations and just printing the result

printing the result

printing the result on the terminal as the last exercise

on the terminal as the last exercise

on the terminal as the last exercise we're actually going to create a new

we're actually going to create a new

we're actually going to create a new column here for every row and we're

column here for every row and we're

column here for every row and we're going to

going to

going to calculate basically the total price of

calculate basically the total price of

calculate basically the total price of inventory

inventory

inventory right the number of units times the

right the number of units times the

right the number of units times the price and we're going to

price and we're going to

price and we're going to basically set the value for each product

basically set the value for each product

basically set the value for each product inventory multiplied by price so

inventory multiplied by price so

inventory multiplied by price so how do we add a column or how do we make

how do we add a column or how do we make

how do we add a column or how do we make changes

changes

changes to a file it's actually pretty easy

to a file it's actually pretty easy

to a file it's actually pretty easy the same way as we were grabbing the

the same way as we were grabbing the

the same way as we were grabbing the value from this

value from this

value from this file and basically reading the values we

file and basically reading the values we

file and basically reading the values we can

can

can add values to it and add columns and

add values to it and add columns and

add values to it and add columns and rows etc

rows etc

rows etc so to add a fifth column

so to add a fifth column

so to add a fifth column we're gonna do product list cell

we're gonna do product list cell

we're gonna do product list cell product row this is going to be the

product row this is going to be the

product row this is going to be the number of the row and

number of the row and

number of the row and a column number so the same way we

a column number so the same way we

a column number so the same way we accessed

accessed

accessed the cells for all other values we can

the cells for all other values we can

the cells for all other values we can basically

basically

basically access the cell on column five

access the cell on column five

access the cell on column five which has an empty value right so

which has an empty value right so

which has an empty value right so we're not actually creating a new column

we're not actually creating a new column

we're not actually creating a new column we're just grabbing

we're just grabbing

we're just grabbing a value of a column five which happens

a value of a column five which happens

a value of a column five which happens to be

to be

to be empty and we are overriding that value

empty and we are overriding that value

empty and we are overriding that value and we could

and we could

and we could do the same actually for any other

do the same actually for any other

do the same actually for any other columns here right we can overwrite all

columns here right we can overwrite all

columns here right we can overwrite all these values

these values

these values if we wanted to so that's basically what

if we wanted to so that's basically what

if we wanted to so that's basically what we're doing

we're doing

we're doing so we're grabbing that cell and we can

so we're grabbing that cell and we can

so we're grabbing that cell and we can now save it into a variable

now save it into a variable

now save it into a variable let's actually call it inventory

price so now that cell

price so now that cell is saved into that variable so we can

is saved into that variable so we can

is saved into that variable so we can reference it

reference it

reference it and note here that i didn't add dot

and note here that i didn't add dot

and note here that i didn't add dot value at the end

value at the end

value at the end because if we want to update the cell

because if we want to update the cell

because if we want to update the cell we need the whole cell object right so

we need the whole cell object right so

we need the whole cell object right so that we can

that we can

that we can actually set a value on that so how do

actually set a value on that so how do

actually set a value on that so how do we set a value

we set a value

we set a value for that specific cell so again note

for that specific cell so again note

for that specific cell so again note that this is

that this is

that this is iteration so for each product row

iteration so for each product row

iteration so for each product row the value will be set so how do we set

the value will be set so how do we set

the value will be set so how do we set the cell value i'm just going to grab

the cell value i'm just going to grab

the cell value i'm just going to grab this

this

this variable here inventory price which is

variable here inventory price which is

variable here inventory price which is representing the cell

representing the cell

representing the cell in column five for each iteration

in column five for each iteration

in column five for each iteration and right here at the end because this

and right here at the end because this

and right here at the end because this is our last exercise

is our last exercise

is our last exercise let's write this is a logic

let's write this is a logic

let's write this is a logic or basically add value for

or basically add value for

or basically add value for total inventory price

total inventory price

total inventory price and the way we set the value in a cell

and the way we set the value in a cell

and the way we set the value in a cell is dot value equals

is dot value equals

is dot value equals and the calculation for that is actually

and the calculation for that is actually

and the calculation for that is actually very easy we already did it here

very easy we already did it here

very easy we already did it here inventory times the price for that

inventory times the price for that

inventory times the price for that specific product

specific product

specific product and that's it so we're using that dot

and that's it so we're using that dot

and that's it so we're using that dot value here

value here

value here in order to set the value instead of

in order to set the value instead of

in order to set the value instead of grabbing the value

grabbing the value

grabbing the value and that will actually update and

and that will actually update and

and that will actually update and add this calculation a result of the

add this calculation a result of the

add this calculation a result of the calculation

calculation

calculation on each line on this column but note

on each line on this column but note

on each line on this column but note that this will only

that this will only

that this will only change the value in a temporary file but

change the value in a temporary file but

change the value in a temporary file but it's not going to save

it's not going to save

it's not going to save anything right so what we want to do at

anything right so what we want to do at

anything right so what we want to do at the end

the end

the end if we want this change to persist to

if we want this change to persist to

if we want this change to persist to actually be

actually be

actually be saved we want to explicitly save the

saved we want to explicitly save the

saved we want to explicitly save the file

file

file so for example if i manually did

so for example if i manually did

so for example if i manually did something here added some value

something here added some value

something here added some value i would need to save it here as well

i would need to save it here as well

i would need to save it here as well right so that's exactly what we need to

right so that's exactly what we need to

right so that's exactly what we need to do

do

do here but programmatically using python

here but programmatically using python

here but programmatically using python so how do we save a file using python

so how do we save a file using python

so how do we save a file using python again

again

again this package or this module that we use

this package or this module that we use

this package or this module that we use here

here

here also gives us a function that we can use

also gives us a function that we can use

also gives us a function that we can use to save the file

to save the file

to save the file and since we're doing an operation on a

and since we're doing an operation on a

and since we're doing an operation on a file and not a sheet here

file and not a sheet here

file and not a sheet here we're going to grab that variable in

we're going to grab that variable in

we're going to grab that variable in file

file

file and here at the end we're going to call

and here at the end we're going to call

and here at the end we're going to call a save function on it and this will save

a save function on it and this will save

a save function on it and this will save the file changes

the file changes

the file changes however we're not overriding the same

however we're not overriding the same

however we're not overriding the same file the existing inventory file

file the existing inventory file

file the existing inventory file we're creating a new one and because of

we're creating a new one and because of

we're creating a new one and because of that we need to provide

that we need to provide

that we need to provide a name of the new file that is going to

a name of the new file that is going to

a name of the new file that is going to be created

be created

be created with the save function and we're going

with the save function and we're going

with the save function and we're going to call that

to call that

to call that file let's say inventory

with total value

with total value and extension

the same extension as we have here so

the same extension as we have here so this line will now save the changes and

this line will now save the changes and

this line will now save the changes and create a new file

create a new file

create a new file from the original one which has these

from the original one which has these

from the original one which has these values generated basically

values generated basically

values generated basically so now that we are done with the fourth

so now that we are done with the fourth

so now that we are done with the fourth exercise let's actually print out

exercise let's actually print out

exercise let's actually print out everything

that we've done so far i'm gonna take

that we've done so far i'm gonna take all those values

so this is going to be execution of all

so this is going to be execution of all our logic

our logic

our logic printing these three dictionaries here

printing these three dictionaries here

printing these three dictionaries here and then updating

and then updating

and then updating the spreadsheet file and saving it into

the spreadsheet file and saving it into

the spreadsheet file and saving it into a new file

a new file

a new file so with this let's actually execute our

so with this let's actually execute our

so with this let's actually execute our program and see what happened

program and see what happened

program and see what happened first of all we have all those three

first of all we have all those three

first of all we have all those three dictionaries listed here

dictionaries listed here

dictionaries listed here or printed here with the values

or printed here with the values

or printed here with the values and if we pull this aside

and if we pull this aside

and if we pull this aside here you see a new file got generated

here you see a new file got generated

here you see a new file got generated with the name

with the name

with the name inventory with total value and if we

inventory with total value and if we

inventory with total value and if we open this file

open this file

open this file we should see that for each row a new

we should see that for each row a new

we should see that for each row a new column was generated and filled with

column was generated and filled with

column was generated and filled with values

values

values which is calculated for each product's

which is calculated for each product's

which is calculated for each product's inventory and price

inventory and price

inventory and price so that's basically our project that's

so that's basically our project that's

so that's basically our project that's how you work with

how you work with

how you work with files in python specifically with

files in python specifically with

files in python specifically with spreadsheet

spreadsheet

spreadsheet files and as i said at the beginning

files and as i said at the beginning

files and as i said at the beginning this could be actually very useful

this could be actually very useful

this could be actually very useful automation logic when you're working at

automation logic when you're working at

automation logic when you're working at a company where there are lots of

a company where there are lots of

a company where there are lots of excel files or spreadsheet files that

excel files or spreadsheet files that

excel files or spreadsheet files that employees have to work with

employees have to work with

employees have to work with and manually update stuff inside

in this part we're going to learn the

in this part we're going to learn the concept of objects and

concept of objects and

concept of objects and classes in python and generally object

classes in python and generally object

classes in python and generally object oriented

oriented

oriented let's consider an example of an

let's consider an example of an

let's consider an example of an application with

application with

application with lots of users for example linkedin right

lots of users for example linkedin right

lots of users for example linkedin right we have

we have

we have users and each user will have some

users and each user will have some

users and each user will have some information for example

information for example

information for example email address

password

password maybe a current job title

maybe a current job title

maybe a current job title work experience a set of skills and so

work experience a set of skills and so

work experience a set of skills and so on

on

on right so each user will have all this

right so each user will have all this

right so each user will have all this information but

information but

information but obviously the actual values the actual

obviously the actual values the actual

obviously the actual values the actual information will be different

information will be different

information will be different for each user in addition to that users

for each user in addition to that users

for each user in addition to that users are able to do something with their own

are able to do something with their own

are able to do something with their own information right

information right

information right so for example a user can change their

so for example a user can change their

so for example a user can change their password

change their current job title add a new

change their current job title add a new skill

and again basically do stuff with their

and again basically do stuff with their own

own

own personal information and our program

personal information and our program

personal information and our program will be

will be

will be able to handle this user information

able to handle this user information

able to handle this user information plus

plus

plus user changing their information right so

user changing their information right so

user changing their information right so this will be

this will be

this will be user data and in order to do something

user data and in order to do something

user data and in order to do something so to perform some action we would have

so to perform some action we would have

so to perform some action we would have functions for that right

functions for that right

functions for that right so all of these will actually be

so all of these will actually be

so all of these will actually be functions however as i mentioned

functions however as i mentioned

functions however as i mentioned every user will have their own data and

every user will have their own data and

every user will have their own data and whenever a new user basically registers

whenever a new user basically registers

whenever a new user basically registers for an application

for an application

for an application all these data should be gathered for

all these data should be gathered for

all these data should be gathered for that new user

that new user

that new user and saved in the application so

and saved in the application so

and saved in the application so basically that means that

basically that means that

basically that means that in our program we need some way to

in our program we need some way to

in our program we need some way to define

define

define kind of a blueprint for a user for all

kind of a blueprint for a user for all

kind of a blueprint for a user for all the data

the data

the data user information and user behavior right

user information and user behavior right

user information and user behavior right things that the user can do in the

things that the user can do in the

things that the user can do in the application

application

application because if we have thousand users in our

because if we have thousand users in our

because if we have thousand users in our application obviously we can't

application obviously we can't

application obviously we can't write the same logic and same variables

write the same logic and same variables

write the same logic and same variables thousand times right we want to have a

thousand times right we want to have a

thousand times right we want to have a blueprint once

blueprint once

blueprint once and then we can use the blueprint for

and then we can use the blueprint for

and then we can use the blueprint for all those thousand users

all those thousand users

all those thousand users and that blueprint for a user is called

and that blueprint for a user is called

and that blueprint for a user is called a class

a class

a class and the specific implementation of that

and the specific implementation of that

and the specific implementation of that blueprint

blueprint

blueprint is called an object so think of this

is called an object so think of this

is called an object so think of this like a blueprint of a building right you

like a blueprint of a building right you

like a blueprint of a building right you can have a blueprint

can have a blueprint

can have a blueprint once which is like a general description

once which is like a general description

once which is like a general description of

of

of building with doors and windows and

building with doors and windows and

building with doors and windows and everything that

everything that

everything that every single building has and then the

every single building has and then the

every single building has and then the specific implementation

specific implementation

specific implementation of that blueprint will be the actual

of that blueprint will be the actual

of that blueprint will be the actual built ready buildings right

built ready buildings right

built ready buildings right so that's the same concept we're going

so that's the same concept we're going

so that's the same concept we're going to create a class

to create a class

to create a class blueprint for a user and the user class

blueprint for a user and the user class

blueprint for a user and the user class blueprint will define

blueprint will define

blueprint will define what information a user has

what information a user has

what information a user has and what actions user can perform in the

and what actions user can perform in the

and what actions user can perform in the application

application

application and object then will contain the actual

and object then will contain the actual

and object then will contain the actual information

information

information like this information right here

like this information right here

like this information right here for each specific user so let's clean

for each specific user so let's clean

for each specific user so let's clean all these up

all these up

all these up and let's now actually create class

and let's now actually create class

and let's now actually create class user

so let's create a new file in our

so let's create a new file in our project and let's actually call it

project and let's actually call it

project and let's actually call it user dot pi so this is going to be our

user dot pi so this is going to be our

user dot pi so this is going to be our user class

user class

user class and inside that i'm going to paste in

and inside that i'm going to paste in

and inside that i'm going to paste in this piece of code that basically will

this piece of code that basically will

this piece of code that basically will represent

represent

represent data for the user and some behavior

data for the user and some behavior

data for the user and some behavior these pieces of data are also called

these pieces of data are also called

these pieces of data are also called attributes

attributes

attributes for that class so now let's turn

for that class so now let's turn

for that class so now let's turn all of these into a class so first of

all of these into a class so first of

all of these into a class so first of all

all

all we create a class using class special

we create a class using class special

we create a class using class special work and you also see the syntax

work and you also see the syntax

work and you also see the syntax highlighting

highlighting

highlighting and we're going to call that user

and we're going to call that user

and we're going to call that user and you know the syntax already for

and you know the syntax already for

and you know the syntax already for functions um etc

functions um etc

functions um etc with indentation so this is going to be

with indentation so this is going to be

with indentation so this is going to be where our class definition goes

where our class definition goes

where our class definition goes now note here the capital letter for u

now note here the capital letter for u

now note here the capital letter for u for user

for user

for user and lowercase user in the

and lowercase user in the

and lowercase user in the python file name so a standard

python file name so a standard

python file name so a standard convention is that we call classes with

convention is that we call classes with

convention is that we call classes with a capital letter

a capital letter

a capital letter and the file names are written in

and the file names are written in

and the file names are written in lowercase letters

lowercase letters

lowercase letters and now all of these should actually go

and now all of these should actually go

and now all of these should actually go inside that

inside that

inside that indentation right like this now we said

indentation right like this now we said

indentation right like this now we said that

that

that class is a blueprint for specific

class is a blueprint for specific

class is a blueprint for specific objects

objects

objects and blueprint cannot actually have

and blueprint cannot actually have

and blueprint cannot actually have specific

specific

specific values right so all these needs to

values right so all these needs to

values right so all these needs to be removed so in the blueprint we don't

be removed so in the blueprint we don't

be removed so in the blueprint we don't have any specific values we just have

have any specific values we just have

have any specific values we just have the attributes

the attributes

the attributes so basically we say this user will have

so basically we say this user will have

so basically we say this user will have an email

an email

an email name password and current job title the

name password and current job title the

name password and current job title the actual values of those attributes

actual values of those attributes

actual values of those attributes will be then set when we create an

will be then set when we create an

will be then set when we create an object from the blueprint

object from the blueprint

object from the blueprint however we need a function that will

however we need a function that will

however we need a function that will actually

actually

actually take those specific values and assign

take those specific values and assign

take those specific values and assign them

them

them to an object which is created from the

to an object which is created from the

to an object which is created from the blueprint

blueprint

blueprint and we're gonna create that function

and we're gonna create that function

and we're gonna create that function right here in the class

right here in the class

right here in the class and that function actually is called

and that function actually is called

and that function actually is called init with

init with

init with underscore or two underscores at the

underscore or two underscores at the

underscore or two underscores at the beginning and

beginning and

beginning and at the end a couple of notes here first

at the end a couple of notes here first

at the end a couple of notes here first of all you see the syntax highlighting

of all you see the syntax highlighting

of all you see the syntax highlighting just changed

just changed

just changed to this different color second note is

to this different color second note is

to this different color second note is that these

that these

that these functions that start with underscore in

functions that start with underscore in

functions that start with underscore in python are special functions

python are special functions

python are special functions so python basically gives them some

so python basically gives them some

so python basically gives them some special meaning so it knows

special meaning so it knows

special meaning so it knows exactly what this init function is and

exactly what this init function is and

exactly what this init function is and we also have to call it init we can't

we also have to call it init we can't

we also have to call it init we can't just call it whatever we want and final

just call it whatever we want and final

just call it whatever we want and final note is that this init function in

note is that this init function in

note is that this init function in python is

python is

python is something called a constructor again we

something called a constructor again we

something called a constructor again we have a blueprint and we're constructing

have a blueprint and we're constructing

have a blueprint and we're constructing objects from the blueprint and this init

objects from the blueprint and this init

objects from the blueprint and this init function

function

function the constructive function will help us

the constructive function will help us

the constructive function will help us construct

construct

construct objects from that user class and now

objects from that user class and now

objects from that user class and now for a function syntax you know that we

for a function syntax you know that we

for a function syntax you know that we use

use

use these brackets right and when i

these brackets right and when i

these brackets right and when i start writing the bracket you see that

start writing the bracket you see that

start writing the bracket you see that self

self

self got automatically created as the

got automatically created as the

got automatically created as the parameter here

parameter here

parameter here and the reason is as i mentioned python

and the reason is as i mentioned python

and the reason is as i mentioned python knows what the init function is and that

knows what the init function is and that

knows what the init function is and that it's a

it's a

it's a constructor so it knows that it needs

constructor so it knows that it needs

constructor so it knows that it needs this

this

this self as a parameter again self is also a

self as a parameter again self is also a

self as a parameter again self is also a special

special

special word in python it has a special meaning

word in python it has a special meaning

word in python it has a special meaning and it actually

and it actually

and it actually refers to this class here

refers to this class here

refers to this class here right this entire class if i hover over

right this entire class if i hover over

right this entire class if i hover over it

it

it you see self points to the user class

you see self points to the user class

you see self points to the user class and it will basically just help us

and it will basically just help us

and it will basically just help us access

access

access and reference all the attributes and

and reference all the attributes and

and reference all the attributes and functions within that class

functions within that class

functions within that class so it's for special usage within that

so it's for special usage within that

so it's for special usage within that user class

user class

user class and we're going to see examples of how

and we're going to see examples of how

and we're going to see examples of how to use that in a second

to use that in a second

to use that in a second now you can think of those attributes as

now you can think of those attributes as

now you can think of those attributes as variables

variables

variables within the class because they belong to

within the class because they belong to

within the class because they belong to the class right they describe basically

the class right they describe basically

the class right they describe basically what attributes or what characteristics

what attributes or what characteristics

what attributes or what characteristics this

this

this class has and in order to define that

class has and in order to define that

class has and in order to define that these

these

these variables belong to the class we need to

variables belong to the class we need to

variables belong to the class we need to use

use

use self here so

and you see again syntax highlighting

and you see again syntax highlighting changed

changed

changed and the red line disappeared so

and the red line disappeared so

and the red line disappeared so basically we are defining

basically we are defining

basically we are defining that email name password and current job

that email name password and current job

that email name password and current job title

title

title belong to this class using this self

belong to this class using this self

belong to this class using this self keyword and now the last thing remaining

keyword and now the last thing remaining

keyword and now the last thing remaining in this constructor again remember

in this constructor again remember

in this constructor again remember constructor

constructor

constructor is to construct new objects so whenever

is to construct new objects so whenever

is to construct new objects so whenever a new object is created

a new object is created

a new object is created the specific values will be assigned

the specific values will be assigned

the specific values will be assigned to all these four variables right and

to all these four variables right and

to all these four variables right and those

those

those values those specific values will be

values those specific values will be

values those specific values will be passed into the constructor as

passed into the constructor as

passed into the constructor as parameters so email name

parameters so email name

parameters so email name password and current

password and current

password and current job title those four values

job title those four values

job title those four values must be provided to the constructor

must be provided to the constructor

must be provided to the constructor whenever we're creating

whenever we're creating

whenever we're creating a new object note that these

a new object note that these

a new object note that these names here could be different from this

names here could be different from this

names here could be different from this these are not the same these are just

these are not the same these are just

these are not the same these are just parameters and using these parameter

parameters and using these parameter

parameters and using these parameter values we are going to

values we are going to

values we are going to basically set the variables or

basically set the variables or

basically set the variables or attributes

attributes

attributes of the class like this

of the class like this

of the class like this and the warning is gone as well again as

and the warning is gone as well again as

and the warning is gone as well again as i mentioned this could be something else

i mentioned this could be something else

i mentioned this could be something else we could call it user email so it

we could call it user email so it

we could call it user email so it doesn't actually have to be

doesn't actually have to be

doesn't actually have to be the same it's just for convenience so

the same it's just for convenience so

the same it's just for convenience so this function will construct an object

this function will construct an object

this function will construct an object with parameters that we provide when we

with parameters that we provide when we

with parameters that we provide when we actually create it

actually create it

actually create it and we're going to see how to create an

and we're going to see how to create an

and we're going to see how to create an object later this is just the definition

object later this is just the definition

object later this is just the definition as remember when you define a function

as remember when you define a function

as remember when you define a function nothing actually happens

nothing actually happens

nothing actually happens until you call or you use that function

until you call or you use that function

until you call or you use that function so

so

so right here we're just defining that

right here we're just defining that

right here we're just defining that function so that we can use it

function so that we can use it

function so that we can use it later so constructor logic is

later so constructor logic is

later so constructor logic is done now we have these two functions

done now we have these two functions

done now we have these two functions that any user in our application

that any user in our application

that any user in our application can do right any user can change their

can do right any user can change their

can do right any user can change their password or change their job title

password or change their job title

password or change their job title and logically when change password

and logically when change password

and logically when change password happens

happens

happens by user basically user provides a new

by user basically user provides a new

by user basically user provides a new password

password

password in order to override the old one so the

in order to override the old one so the

in order to override the old one so the flow will be following

flow will be following

flow will be following the object will be created for the

the object will be created for the

the object will be created for the specific user

specific user

specific user so the initial data for that object will

so the initial data for that object will

so the initial data for that object will be provided

be provided

be provided so we'll have the user email name

so we'll have the user email name

so we'll have the user email name password and current job title

password and current job title

password and current job title and later at some point user may decide

and later at some point user may decide

and later at some point user may decide to change their password

to change their password

to change their password and their current job title and that

and their current job title and that

and their current job title and that means the

means the

means the initial data will be changed and that

initial data will be changed and that

initial data will be changed and that means

means

means that we're actually changing the

that we're actually changing the

that we're actually changing the attributes

self.password with a new password

self.password with a new password right so logic will be like this

right so logic will be like this

right so logic will be like this now we have red lines here why because

now we have red lines here why because

now we have red lines here why because we need

we need

we need this self as a parameter first of all we

this self as a parameter first of all we

this self as a parameter first of all we also have that

also have that

also have that as um note right here

as um note right here

as um note right here so just like here we need to actually

so just like here we need to actually

so just like here we need to actually pass that self as a parameter that's

pass that self as a parameter that's

pass that self as a parameter that's just how it is

just how it is

just how it is because we need to access attributes

because we need to access attributes

because we need to access attributes of that class in that function and

of that class in that function and

of that class in that function and new password will be

new password will be

new password will be new password variable will be the new

new password variable will be the new

new password variable will be the new password

password

password basically that user wants to set so this

basically that user wants to set so this

basically that user wants to set so this will change

will change

will change the initial password with the new one

the initial password with the new one

the initial password with the new one and the same way

and the same way

and the same way in change.title we have self as a first

in change.title we have self as a first

in change.title we have self as a first parameter

parameter

parameter we always need it in all the functions

we always need it in all the functions

we always need it in all the functions because

because

because otherwise we cannot access the

otherwise we cannot access the

otherwise we cannot access the attributes in the class

attributes in the class

attributes in the class and new job

so now let's review this class that we

so now let's review this class that we created

created

created first of all we have this class keyword

first of all we have this class keyword

first of all we have this class keyword here with a capital letter

here with a capital letter

here with a capital letter for user you already know the syntax

for user you already know the syntax

for user you already know the syntax with colon and then

with colon and then

with colon and then indentation so this all of these

indentation so this all of these

indentation so this all of these inside this indentation is class body

inside this indentation is class body

inside this indentation is class body so part of the class logic first we have

so part of the class logic first we have

so part of the class logic first we have this

this

this init constructor that sets the initial

init constructor that sets the initial

init constructor that sets the initial values

values

values of that class attributes whenever we

of that class attributes whenever we

of that class attributes whenever we create

create

create a specific object for that class right

a specific object for that class right

a specific object for that class right so this happens only when we construct a

so this happens only when we construct a

so this happens only when we construct a new object

new object

new object and then on that constructed object we

and then on that constructed object we

and then on that constructed object we can change password we can change

can change password we can change

can change password we can change job title and note that right now we

job title and note that right now we

job title and note that right now we have

have

have nothing basically hard coded we have no

nothing basically hard coded we have no

nothing basically hard coded we have no specific

specific

specific values here right everything is just

values here right everything is just

values here right everything is just parameterized

parameterized

parameterized and also this is just a definition for

and also this is just a definition for

and also this is just a definition for class and its functions nothing will

class and its functions nothing will

class and its functions nothing will actually happen when we execute this

actually happen when we execute this

actually happen when we execute this because we're not creating any user

because we're not creating any user

because we're not creating any user objects

objects

objects so if i right click here and execute

so if i right click here and execute

so if i right click here and execute this

this

this run user you see that

run user you see that

run user you see that nothing happened because the class

nothing happened because the class

nothing happened because the class definition was created

definition was created

definition was created but we're not doing anything with that

but we're not doing anything with that

but we're not doing anything with that class definition we're not creating

class definition we're not creating

class definition we're not creating new users so now let's actually go ahead

new users so now let's actually go ahead

new users so now let's actually go ahead and

and

and do that

in the same file in user.py

in the same file in user.py i would actually use that class

i would actually use that class

i would actually use that class blueprint to construct a new

blueprint to construct a new

blueprint to construct a new user object and creating an object from

user object and creating an object from

user object and creating an object from a class is actually very simple

a class is actually very simple

a class is actually very simple we just write name of the class and

we just write name of the class and

we just write name of the class and parentheses this is actually the same

parentheses this is actually the same

parentheses this is actually the same syntax as

syntax as

syntax as calling the function with parameters

calling the function with parameters

calling the function with parameters and the parameters that we need to give

and the parameters that we need to give

and the parameters that we need to give that

that

that class are these four values here

class are these four values here

class are these four values here and note that calling this user

and note that calling this user

and note that calling this user class function basically in the

class function basically in the

class function basically in the background we'll call

background we'll call

background we'll call init function right so the constructor

init function right so the constructor

init function right so the constructor will be called whenever we write this

will be called whenever we write this

will be called whenever we write this syntax with class name and parentheses

syntax with class name and parentheses

syntax with class name and parentheses and this init constructor as you see

and this init constructor as you see

and this init constructor as you see expects

expects

expects four parameters so we have to provide

four parameters so we have to provide

four parameters so we have to provide all those parameters

all those parameters

all those parameters right here in the parenthesis so let's

right here in the parenthesis so let's

right here in the parenthesis so let's actually provide them

actually provide them

actually provide them let's do user email

let's do user email

let's do user email like this

and a current job title again very

and a current job title again very similar to calling a function

similar to calling a function

similar to calling a function and this will actually construct a new

and this will actually construct a new

and this will actually construct a new object from the user class which has

object from the user class which has

object from the user class which has these four attributes with

these four attributes with

these four attributes with values that we just provided here and

values that we just provided here and

values that we just provided here and has these

has these

has these two functions that we can use

two functions that we can use

two functions that we can use to either change a password or change

to either change a password or change

to either change a password or change job title

job title

job title one note here is that functions that

one note here is that functions that

one note here is that functions that belong to a class

belong to a class

belong to a class are actually called methods so there's a

are actually called methods so there's a

are actually called methods so there's a special name for functions

special name for functions

special name for functions which are part of a class so we can

which are part of a class so we can

which are part of a class so we can refer to them as

refer to them as

refer to them as methods so user object basically gives

methods so user object basically gives

methods so user object basically gives us

us

us two methods that we can use now again if

two methods that we can use now again if

two methods that we can use now again if we execute this program now

we execute this program now

we execute this program now we will not see anything even though

we will not see anything even though

we will not see anything even though user will be created because

user will be created because

user will be created because we're not printing anything to the

we're not printing anything to the

we're not printing anything to the console we're not doing anything so

console we're not doing anything so

console we're not doing anything so let's do that run user nothing happens

let's do that run user nothing happens

let's do that run user nothing happens because

because

because we need to print a message or some kind

we need to print a message or some kind

we need to print a message or some kind of information

of information

of information so what i'm going to do now is inside

so what i'm going to do now is inside

so what i'm going to do now is inside that class

that class

that class i'm going to create a function or a

i'm going to create a function or a

i'm going to create a function or a method as we learned now

method as we learned now

method as we learned now that basically prints back some user

that basically prints back some user

that basically prints back some user information right

information right

information right prints me the name email and current job

prints me the name email and current job

prints me the name email and current job title because we don't want to display

title because we don't want to display

title because we don't want to display password so let's give us some space

password so let's give us some space

password so let's give us some space here

here

here and let's create a function called get

and let's create a function called get

and let's create a function called get user info so that we can see something

user info so that we can see something

user info so that we can see something and again as soon as i typed in

and again as soon as i typed in

and again as soon as i typed in these first parentheses self got

these first parentheses self got

these first parentheses self got generated

generated

generated because we need self in every function

because we need self in every function

because we need self in every function within the class

within the class

within the class and in the function body we're gonna

and in the function body we're gonna

and in the function body we're gonna print user information

print user information

print user information so let's say user

so let's say user

so let's say user and name of the user which we can access

and name of the user which we can access

and name of the user which we can access using self

using self

using self remember all the attributes that the

remember all the attributes that the

remember all the attributes that the object has can be accessed with

object has can be accessed with

object has can be accessed with this special word here so self

this special word here so self

this special word here so self dot name

dot name

dot name so user whatever the user's name is

so user whatever the user's name is

so user whatever the user's name is currently works

currently works

currently works as a and now we need the job description

as a and now we need the job description

as a and now we need the job description or job title

and you can contact

and you can contact them at and now we can

them at and now we can

them at and now we can use the email

so this message will be printed for the

so this message will be printed for the user

user

user again because this will be used for

again because this will be used for

again because this will be used for any user of our application the message

any user of our application the message

any user of our application the message these parts will be the same but each

these parts will be the same but each

these parts will be the same but each user will have their own different name

user will have their own different name

user will have their own different name different job title and different email

different job title and different email

different job title and different email address

address

address so all of these are

so all of these are

so all of these are and written as variables because we

and written as variables because we

and written as variables because we don't know these values up front

don't know these values up front

don't know these values up front so now we can actually use this function

so now we can actually use this function

so now we can actually use this function or method to print out information of a

or method to print out information of a

or method to print out information of a specific

specific

specific user so how do we use or how do we call

user so how do we use or how do we call

user so how do we use or how do we call that function of the user

that function of the user

that function of the user we first save it into a variable

we first save it into a variable

we first save it into a variable app user one

app user one

app user one or nana doesn't really matter let's call

or nana doesn't really matter let's call

or nana doesn't really matter let's call it app user one so it's generic

it app user one so it's generic

it app user one so it's generic so how do we use that function

so how do we use that function

so how do we use that function to print out the information about the

to print out the information about the

to print out the information about the user if i do

user if i do

user if i do app user one and dot

app user one and dot

app user one and dot you see that i have the attributes here

you see that i have the attributes here

you see that i have the attributes here the four attributes that

the four attributes that

the four attributes that our user object has or user class

our user object has or user class

our user object has or user class and we have these three methods of the

and we have these three methods of the

and we have these three methods of the class get user infor

class get user infor

class get user infor change job title and change password so

change job title and change password so

change job title and change password so using get

using get

using get info we can call this function

and if i execute this right here you see

and if i execute this right here you see user

user

user nanogenasia currently works as a devops

nanogenasia currently works as a devops

nanogenasia currently works as a devops engineer

engineer

engineer you can contact them at this email

you can contact them at this email

you can contact them at this email and now let's say we want to change

and now let's say we want to change

and now let's say we want to change job title of that user we do that in the

job title of that user we do that in the

job title of that user we do that in the same way

same way

same way app user one dot

app user one dot

app user one dot change job title and

change job title and

change job title and we're gonna provide the job title

we're gonna provide the job title

we're gonna provide the job title parameter

parameter

parameter note that even though you see two

note that even though you see two

note that even though you see two parameters here on that function

parameters here on that function

parameters here on that function this first parameter is passed in

this first parameter is passed in

this first parameter is passed in automatically so we don't have to

automatically so we don't have to

automatically so we don't have to basically pass that self right it's

basically pass that self right it's

basically pass that self right it's already done automatically we just have

already done automatically we just have

already done automatically we just have to worry about these parameters

to worry about these parameters

to worry about these parameters so new job title is let's say

so new job title is let's say

so new job title is let's say devops trainer

and now we can call that

and now we can call that user info method again

user info method again

user info method again and execute and you see first

and execute and you see first

and execute and you see first message printed here before we change

message printed here before we change

message printed here before we change the job title

the job title

the job title now it's devops trainer

now it's devops trainer

now it's devops trainer so that's how we can create a new

so that's how we can create a new

so that's how we can create a new object from a class and we can

object from a class and we can

object from a class and we can use methods of that object by first

use methods of that object by first

use methods of that object by first saving that object into a variable and

saving that object into a variable and

saving that object into a variable and then calling that function

then calling that function

then calling that function on that variable and obviously now this

on that variable and obviously now this

on that variable and obviously now this is just

is just

is just one user but if we had another one

user two that's actually

user two that's actually clean this up we can create

clean this up we can create

clean this up we can create a new user with different values

a new user with different values

a new user with different values like this

like this

like this they have their own email

own password and on

own password and on job title and again

we can create that user and basically

we can create that user and basically just use the methods defined in the

just use the methods defined in the

just use the methods defined in the class

class

class and in two different cases or for two

and in two different cases or for two

and in two different cases or for two different users

different users

different users obviously the user info will be

obviously the user info will be

obviously the user info will be different

different

different so let's execute this and right here you

so let's execute this and right here you

so let's execute this and right here you see the user

see the user

see the user information for both users and obviously

information for both users and obviously

information for both users and obviously if you have an application like

if you have an application like

if you have an application like linkedin you don't have two users or a

linkedin you don't have two users or a

linkedin you don't have two users or a thousand users

thousand users

thousand users you probably have millions of users and

you probably have millions of users and

you probably have millions of users and having

having

having a user definition once and

a user definition once and

a user definition once and reusing it every time a new user gets

reusing it every time a new user gets

reusing it every time a new user gets created or

created or

created or basically existing users do something in

basically existing users do something in

basically existing users do something in application

application

application is only possible when using classes

is only possible when using classes

is only possible when using classes and objects instead of just having all

and objects instead of just having all

and objects instead of just having all these logic

these logic

these logic non-structured throughout the code and

non-structured throughout the code and

non-structured throughout the code and again in this type of applications

again in this type of applications

again in this type of applications you would not have four attributes and

you would not have four attributes and

you would not have four attributes and three methods you will have

three methods you will have

three methods you will have probably hundreds of attributes and

probably hundreds of attributes and

probably hundreds of attributes and hundreds of such

hundreds of such

hundreds of such methods now as you see here

methods now as you see here

methods now as you see here we have created this user.pi

we have created this user.pi

we have created this user.pi file for user class but we're also

file for user class but we're also

file for user class but we're also creating these

creating these

creating these objects in the same file which actually

objects in the same file which actually

objects in the same file which actually doesn't make sense because

doesn't make sense because

doesn't make sense because the file should be only for defining the

the file should be only for defining the

the file should be only for defining the class right

class right

class right so all of this logic actually needs to

so all of this logic actually needs to

so all of this logic actually needs to move out from here

move out from here

move out from here and this should be just only for class

and this should be just only for class

and this should be just only for class definition

definition

definition so in the application again using an

so in the application again using an

so in the application again using an example of linkedin

example of linkedin

example of linkedin we would have class user and then we

we would have class user and then we

we would have class user and then we would have

would have

would have a class post right whenever someone

a class post right whenever someone

a class post right whenever someone posts something

posts something

posts something each post will have their own attributes

each post will have their own attributes

each post will have their own attributes like the actual

like the actual

like the actual message or text in that post the author

message or text in that post the author

message or text in that post the author who wrote the post how many likes it has

who wrote the post how many likes it has

who wrote the post how many likes it has etc

etc

etc as well as specific functions right for

as well as specific functions right for

as well as specific functions right for example

example

example changing the post commenting on the post

changing the post commenting on the post

changing the post commenting on the post etc

etc

etc so you will have separate file for each

so you will have separate file for each

so you will have separate file for each such class right in the application and

such class right in the application and

such class right in the application and then you would have

then you would have

then you would have one file somewhere else this could be a

one file somewhere else this could be a

one file somewhere else this could be a main dot pi

main dot pi

main dot pi where you would actually use all those

where you would actually use all those

where you would actually use all those different classes and create

different classes and create

different classes and create objects from those classes and that

objects from those classes and that

objects from those classes and that means that logic that we wrote here

means that logic that we wrote here

means that logic that we wrote here constructing a user object and then

constructing a user object and then

constructing a user object and then calling some functions on that

calling some functions on that

calling some functions on that will actually happen in another file in

will actually happen in another file in

will actually happen in another file in our case let's use

our case let's use

our case let's use main.pi and now let's see how we're

main.pi and now let's see how we're

main.pi and now let's see how we're going to do that

going to do that

going to do that i'm going to paste in the code that i

i'm going to paste in the code that i

i'm going to paste in the code that i copied from there

copied from there

copied from there and as soon as i paste in you see those

and as soon as i paste in you see those

and as soon as i paste in you see those red lines

red lines

red lines so basically main.pi says that it cannot

so basically main.pi says that it cannot

so basically main.pi says that it cannot find

find

find a reference to user so this file doesn't

a reference to user so this file doesn't

a reference to user so this file doesn't know anything about the user class

know anything about the user class

know anything about the user class so how do we fix that or how do we make

so how do we fix that or how do we make

so how do we fix that or how do we make this user class available

this user class available

this user class available in another file and if you remember

in another file and if you remember

in another file and if you remember when we needed to use modules or

when we needed to use modules or

when we needed to use modules or basically functions

basically functions

basically functions variables whatever from other files in

variables whatever from other files in

variables whatever from other files in python

python

python we use import to basically import those

we use import to basically import those

we use import to basically import those functions

functions

functions and make them available here or import

and make them available here or import

and make them available here or import the whole module

the whole module

the whole module to make its functions and variables

to make its functions and variables

to make its functions and variables available here

available here

available here and the same way we can import classes

and the same way we can import classes

and the same way we can import classes from another file import

from another file import

from another file import user and note here that i'm using the

user and note here that i'm using the

user and note here that i'm using the name of the file

name of the file

name of the file user lowercase and not the class name

user lowercase and not the class name

user lowercase and not the class name with capital user right

with capital user right

with capital user right so we are importing that file so now we

so we are importing that file so now we

so we are importing that file so now we can use

can use

can use anything that is defined in that file

anything that is defined in that file

anything that is defined in that file and one of them

and one of them

and one of them is class called user and the way we can

is class called user and the way we can

is class called user and the way we can access that class now is using the name

access that class now is using the name

access that class now is using the name of module and not the class

of module and not the class

of module and not the class user itself and this is basically

user itself and this is basically

user itself and this is basically exactly the same concept as we saw

exactly the same concept as we saw

exactly the same concept as we saw before

before

before because we are importing a module called

because we are importing a module called

because we are importing a module called user

user

user remember every python file that has

remember every python file that has

remember every python file that has functions or variables or classes inside

functions or variables or classes inside

functions or variables or classes inside is a module so we are importing a module

is a module so we are importing a module

is a module so we are importing a module and once we have that module imported

and once we have that module imported

and once we have that module imported now we can use

now we can use

now we can use and access functions variables or

and access functions variables or

and access functions variables or classes

classes

classes of that module and we can do that by

of that module and we can do that by

of that module and we can do that by copying the name of the module

copying the name of the module

copying the name of the module dot and there you go in the same way

dot and there you go in the same way

dot and there you go in the same way here so exactly the same concept whether

here so exactly the same concept whether

here so exactly the same concept whether this is a function or a class doesn't

this is a function or a class doesn't

this is a function or a class doesn't matter

matter

matter we use it the same way remember when we

we use it the same way remember when we

we use it the same way remember when we use the date

use the date

use the date time module with the syntax

time module with the syntax

time module with the syntax datetime.daytime

datetime.daytime

datetime.daytime and that was an example of using a class

and that was an example of using a class

and that was an example of using a class from a module now user.user may

from a module now user.user may

from a module now user.user may look a little bit weird so we can use

look a little bit weird so we can use

look a little bit weird so we can use our

our

our familiar import statement where instead

familiar import statement where instead

familiar import statement where instead of

of

of importing the whole module we can pick

importing the whole module we can pick

importing the whole module we can pick and choose and import specific

and choose and import specific

and choose and import specific definitions or specific elements of that

definitions or specific elements of that

definitions or specific elements of that module

module

module in our case we just have one element

in our case we just have one element

in our case we just have one element which is the class

which is the class

which is the class so we're going to say from user module

so we're going to say from user module

so we're going to say from user module import

import

import user class and now we don't need the

user class and now we don't need the

user class and now we don't need the module name anymore because we imported

module name anymore because we imported

module name anymore because we imported the

the

the class itself and now if we

class itself and now if we

class itself and now if we execute main dot p y

execute main dot p y

execute main dot p y let's do it again here we have the same

let's do it again here we have the same

let's do it again here we have the same result

result

result for two of our users

for two of our users

for two of our users and again as i said in applications you

and again as i said in applications you

and again as i said in applications you will have multiple classes

will have multiple classes

will have multiple classes that are connected to each other so for

that are connected to each other so for

that are connected to each other so for example if we have a post here

example if we have a post here

example if we have a post here post blueprint basically whenever a new

post blueprint basically whenever a new

post blueprint basically whenever a new post gets created

post gets created

post gets created with some specific values like the

with some specific values like the

with some specific values like the actual message

actual message

actual message and creation date time etc

and creation date time etc

and creation date time etc it will also have an author and that

it will also have an author and that

it will also have an author and that author will

author will

author will actually be one of those user objects

actually be one of those user objects

actually be one of those user objects right

right

right so you will have some functions here

so you will have some functions here

so you will have some functions here that actually

that actually

that actually reference the post and we can also see

reference the post and we can also see

reference the post and we can also see that in action

that in action

that in action let's actually create a post class

let's actually create a post class

let's actually create a post class let's give it just two attributes to

let's give it just two attributes to

let's give it just two attributes to keep it simple

keep it simple

keep it simple so we need a constructor here

so we need a constructor here

so we need a constructor here in it

and we're gonna pass in message

and we're gonna pass in message and author right this is gonna be the

and author right this is gonna be the

and author right this is gonna be the user who wrote it

user who wrote it

user who wrote it and you know the drill already

and let's create another function

and let's create another function which displays a post with its

which displays a post with its

which displays a post with its respective author so let's do get

respective author so let's do get

respective author so let's do get post info

post info

post info again we have self here and let's print

and the author name so this is going to

and the author name so this is going to be our simple

be our simple

be our simple post class and user

post class and user

post class and user is able to create new posts so we have

is able to create new posts so we have

is able to create new posts so we have the blueprint for a post

the blueprint for a post

the blueprint for a post and the same way we can create that post

and the same way we can create that post

and the same way we can create that post inside the main dot pi so first let's

inside the main dot pi so first let's

inside the main dot pi so first let's import

and then here we're going to create a

and then here we're going to create a new post

new post

new post in pycharm you get this nice display of

in pycharm you get this nice display of

in pycharm you get this nice display of parameters

parameters

parameters that function or class basically

that function or class basically

that function or class basically expects so we have message and author

expects so we have message and author

expects so we have message and author let's do some

message or post and as a second

message or post and as a second parameter

parameter

parameter we have the author and we can use

we have the author and we can use

we have the author and we can use the name of a user so let's do

the name of a user so let's do

the name of a user so let's do app user to dot name and this will

app user to dot name and this will

app user to dot name and this will create

create

create an object also called instance in

an object also called instance in

an object also called instance in programming

programming

programming special instance of that post class

special instance of that post class

special instance of that post class and then we can print the information

and then we can print the information

and then we can print the information of that post first assign it

of that post first assign it

of that post first assign it to a variable let's say it's a new post

to a variable let's say it's a new post

to a variable let's say it's a new post and on a new post we're gonna call get

and on a new post we're gonna call get

and on a new post we're gonna call get post info let's actually run this

post info let's actually run this

post info let's actually run this application now and see the result

application now and see the result

application now and see the result and here we have our post message that

and here we have our post message that

and here we have our post message that gets

gets

gets printed by this get post info method

printed by this get post info method

printed by this get post info method in the post class

and at the beginning i mentioned object

and at the beginning i mentioned object oriented programming

oriented programming

oriented programming which basically means that when you're

which basically means that when you're

which basically means that when you're writing your code with

writing your code with

writing your code with objects and classes like this to create

objects and classes like this to create

objects and classes like this to create blueprints and then

blueprints and then

blueprints and then use those blueprints for specific

use those blueprints for specific

use those blueprints for specific instances

instances

instances that's called object-oriented

that's called object-oriented

that's called object-oriented programming and also an

programming and also an

programming and also an interesting note here is that in python

interesting note here is that in python

interesting note here is that in python almost

almost

almost everything is actually an object for

everything is actually an object for

everything is actually an object for example the data types like string

example the data types like string

example the data types like string integer list set etc when we printed

integer list set etc when we printed

integer list set etc when we printed them out we saw

them out we saw

them out we saw class of string or class of

class of string or class of

class of string or class of list so these data types are also

list so these data types are also

list so these data types are also classes in python

classes in python

classes in python and this int or sdr for string functions

and this int or sdr for string functions

and this int or sdr for string functions we called

we called

we called where actually the constructor we called

where actually the constructor we called

where actually the constructor we called to create a string

to create a string

to create a string or integer object and the constructor of

or integer object and the constructor of

or integer object and the constructor of int for example took a string

int for example took a string

int for example took a string representation of a number

representation of a number

representation of a number and in its init function and constructed

and in its init function and constructed

and in its init function and constructed an integer out of it now for us in terms

an integer out of it now for us in terms

an integer out of it now for us in terms of

of

of using these data types and variables etc

using these data types and variables etc

using these data types and variables etc it doesn't actually matter but it's just

it doesn't actually matter but it's just

it doesn't actually matter but it's just an interesting thing to know

an interesting thing to know

an interesting thing to know about how this whole thing works in

about how this whole thing works in

about how this whole thing works in python

in this part we're going to learn how to

in this part we're going to learn how to use

use

use python to talk to external applications

python to talk to external applications

python to talk to external applications in our case we're going to use gitlab

in our case we're going to use gitlab

in our case we're going to use gitlab and then application and just

and then application and just

and then application and just note here that communication between

note here that communication between

note here that communication between two applications in our case our python

two applications in our case our python

two applications in our case our python application

application

application and a gitlab application usually happens

and a gitlab application usually happens

and a gitlab application usually happens using a common protocol like http

using a common protocol like http

using a common protocol like http so basically our python application will

so basically our python application will

so basically our python application will send an http request

send an http request

send an http request to gitlab application and from the

to gitlab application and from the

to gitlab application and from the gitlab application it will get

gitlab application it will get

gitlab application it will get an http response for that request

an http response for that request

an http response for that request so just know that http is just a

so just know that http is just a

so just know that http is just a protocol

protocol

protocol that these two applications can

that these two applications can

that these two applications can communicate with

communicate with

communicate with over the internet i have a couple of

over the internet i have a couple of

over the internet i have a couple of projects on gitlab

projects on gitlab

projects on gitlab so we're gonna write a very simple

so we're gonna write a very simple

so we're gonna write a very simple python application

python application

python application that basically goes to gitlab and asks

that basically goes to gitlab and asks

that basically goes to gitlab and asks for the list

for the list

for the list of projects for my user and

of projects for my user and

of projects for my user and then just prints it here in our run

then just prints it here in our run

then just prints it here in our run window

window

window and the concept of one application

and the concept of one application

and the concept of one application talking to another is basically done

talking to another is basically done

talking to another is basically done using

using

using something called api requests so the

something called api requests so the

something called api requests so the remote

remote

remote application in this case gitlab has an

application in this case gitlab has an

application in this case gitlab has an api

api

api so these are functions basically that

so these are functions basically that

so these are functions basically that gitlab

gitlab

gitlab makes available for other applications

makes available for other applications

makes available for other applications to call

to call

to call and we're going to call those functions

and we're going to call those functions

and we're going to call those functions from our python application

from our python application

from our python application in order to get the list of projects for

in order to get the list of projects for

in order to get the list of projects for my user and that

my user and that

my user and that communication or python basically asking

communication or python basically asking

communication or python basically asking for this information

for this information

for this information is going to be an api request or api

is going to be an api request or api

is going to be an api request or api call and what we get in response from

call and what we get in response from

call and what we get in response from this gitlab

this gitlab

this gitlab api is going to be api response

api is going to be api response

api is going to be api response so let's go ahead and do that

in python in order to make those

in python in order to make those external requests

external requests

external requests to remote applications we're going to

to remote applications we're going to

to remote applications we're going to need a module

need a module

need a module called requests this is a generic module

called requests this is a generic module

called requests this is a generic module that you can use for

that you can use for

that you can use for any external application and as i

any external application and as i

any external application and as i mentioned at the beginning the

mentioned at the beginning the

mentioned at the beginning the communication happens

communication happens

communication happens using http protocol between two

using http protocol between two

using http protocol between two applications

applications

applications and as you see here also in the module

and as you see here also in the module

and as you see here also in the module description it says

description it says

description it says an http library which allows you to send

an http library which allows you to send

an http library which allows you to send http requests and then receive http

http requests and then receive http

http requests and then receive http responses

responses

responses from another application and that's

from another application and that's

from another application and that's exactly what we're going to be doing

exactly what we're going to be doing

exactly what we're going to be doing and this request module is not part of

and this request module is not part of

and this request module is not part of python

python

python so we're going to install it using pip

so we're going to install it using pip

so we're going to install it using pip again remember that we're using pip

again remember that we're using pip

again remember that we're using pip that actually comes packaged with the

that actually comes packaged with the

that actually comes packaged with the pycharm

pycharm

pycharm so in the terminal window of my ide of

so in the terminal window of my ide of

so in the terminal window of my ide of pycharm

pycharm

pycharm i'm going to execute peep install

i'm going to execute peep install

i'm going to execute peep install requests

successfully installed request this is

successfully installed request this is the version of that module

and if i expand this external library's

and if i expand this external library's site packages

site packages

site packages i'm going to see the requests package

i'm going to see the requests package

i'm going to see the requests package in the list great

in the list great

in the list great so once we have the module available

so once we have the module available

so once we have the module available locally we can

locally we can

locally we can import that module in our file

import that module in our file

import that module in our file and this requests module now has or

and this requests module now has or

and this requests module now has or package actually

package actually

package actually has functions variables and objects

has functions variables and objects

has functions variables and objects that we can use to talk to these remote

that we can use to talk to these remote

that we can use to talk to these remote applications like gitlab

applications like gitlab

applications like gitlab as i said gitlab is just one example you

as i said gitlab is just one example you

as i said gitlab is just one example you can talk to any

can talk to any

can talk to any remote application that has an api and

remote application that has an api and

remote application that has an api and we can not only do

we can not only do

we can not only do requests for getting the existing

requests for getting the existing

requests for getting the existing information but we can also make

information but we can also make

information but we can also make requests

requests

requests to change something in that remote

to change something in that remote

to change something in that remote application so for example

application so for example

application so for example i can write a python application that

i can write a python application that

i can write a python application that will actually create

will actually create

will actually create a new project on my gitlab account

a new project on my gitlab account

a new project on my gitlab account but to keep the demo simple we're just

but to keep the demo simple we're just

but to keep the demo simple we're just going to be

going to be

going to be fetching information from gitlab so

fetching information from gitlab so

fetching information from gitlab so how do we make requests to an api of an

how do we make requests to an api of an

how do we make requests to an api of an application

application

application with this requests module we get a

with this requests module we get a

with this requests module we get a function called

function called

function called get and get takes one main parameter

get and get takes one main parameter

get and get takes one main parameter which is url so basically we need to

which is url so basically we need to

which is url so basically we need to tell python where to find that remote

tell python where to find that remote

tell python where to find that remote application

application

application or again in our case where to find

or again in our case where to find

or again in our case where to find gitlab

gitlab

gitlab to talk to it so we need the url of

to talk to it so we need the url of

to talk to it so we need the url of gitlab

gitlab

gitlab and where do you find this url

and where do you find this url

and where do you find this url information of a remote application

information of a remote application

information of a remote application you can basically google that every

you can basically google that every

you can basically google that every application has their own documentation

application has their own documentation

application has their own documentation where you can see the urls

where you can see the urls

where you can see the urls so for example for gitlab i actually

so for example for gitlab i actually

so for example for gitlab i actually googled it

googled it

googled it so if i do gitlab api documentation

so if i do gitlab api documentation

so if i do gitlab api documentation like this

let's make it bigger so you have

let's make it bigger so you have basically description

basically description

basically description for the api and what type of information

for the api and what type of information

for the api and what type of information you can get from gitlab

you can get from gitlab

you can get from gitlab and also what kind of things you can

and also what kind of things you can

and also what kind of things you can create in gitlab

create in gitlab

create in gitlab and you see an example api here that

and you see an example api here that

and you see an example api here that basically

basically

basically just lists all the projects however we

just lists all the projects however we

just lists all the projects however we want to list

want to list

want to list projects of one specific user in this

projects of one specific user in this

projects of one specific user in this case i want to list my own projects

case i want to list my own projects

case i want to list my own projects and in this documentation i found this

and in this documentation i found this

and in this documentation i found this list user project

list user project

list user project section where i have an example

section where i have an example

section where i have an example of how to use projects for a specific

of how to use projects for a specific

of how to use projects for a specific user

user

user so we have slash users and the user id

so we have slash users and the user id

so we have slash users and the user id so that's going to be my gitlab user id

so that's going to be my gitlab user id

so that's going to be my gitlab user id and projects so basically the url will

and projects so basically the url will

and projects so basically the url will now look like this

now look like this

now look like this first we're gonna have this base url so

first we're gonna have this base url so

first we're gonna have this base url so that's basically

that's basically

that's basically https gitlab.com api v4

https gitlab.com api v4

https gitlab.com api v4 and all the things that we want to do is

and all the things that we want to do is

and all the things that we want to do is going to be

going to be

going to be at this base api and

at this base api and

at this base api and after that we can basically depending on

after that we can basically depending on

after that we can basically depending on what exactly we want to do

what exactly we want to do

what exactly we want to do we can choose one specific action

we can choose one specific action

we can choose one specific action and again going back this is

and again going back this is

and again going back this is the action we want to execute

the action we want to execute

the action we want to execute on this base url so from gitlab we want

on this base url so from gitlab we want

on this base url so from gitlab we want projects that belong to user and right

projects that belong to user and right

projects that belong to user and right here i'm going to add

here i'm going to add

here i'm going to add my own gitlab user id

my own gitlab user id

my own gitlab user id so if you have a github account you

so if you have a github account you

so if you have a github account you should add your own user id here

should add your own user id here

should add your own user id here and that's going to be an api url for

and that's going to be an api url for

and that's going to be an api url for user projects and this will actually

user projects and this will actually

user projects and this will actually give us

give us

give us some kind of response so requests.get

some kind of response so requests.get

some kind of response so requests.get will make that request

will make that request

will make that request to gitlab and it will return some kind

to gitlab and it will return some kind

to gitlab and it will return some kind of response and we can save that

of response and we can save that

of response and we can save that response into a variable

response into a variable

response into a variable so let's call this variable response

so let's call this variable response

so let's call this variable response because that's what it is

because that's what it is

because that's what it is and on the next line let's actually

and on the next line let's actually

and on the next line let's actually print and see what's in that response

let's run our application and

let's run our application and right here you see we have an object

right here you see we have an object

right here you see we have an object response

response

response with a code here 200 is a code for a

with a code here 200 is a code for a

with a code here 200 is a code for a successful

successful

successful request but we're not seeing the actual

request but we're not seeing the actual

request but we're not seeing the actual contents right we want to see the

contents right we want to see the

contents right we want to see the projects with their

projects with their

projects with their details and in order to get that we're

details and in order to get that we're

details and in order to get that we're gonna

gonna

gonna do dot and text and let's actually

do dot and text and let's actually

do dot and text and let's actually execute this now

execute this now

execute this now and now you see these square brackets

and now you see these square brackets

and now you see these square brackets which means it is a list because we have

which means it is a list because we have

which means it is a list because we have a list of projects

a list of projects

a list of projects and this whole bunch of information

and this whole bunch of information

and this whole bunch of information about projects there

about projects there

about projects there and you also see curly braces so this is

and you also see curly braces so this is

and you also see curly braces so this is a list of

a list of

a list of dictionaries and each dictionary holds

dictionaries and each dictionary holds

dictionaries and each dictionary holds information

information

information of one specific project now

of one specific project now

of one specific project now if i actually print the type of that

if i actually print the type of that

if i actually print the type of that response text

like this see that it is a

like this see that it is a string so even though we see the format

string so even though we see the format

string so even though we see the format is actually

is actually

is actually a list of dictionaries we're getting a

a list of dictionaries we're getting a

a list of dictionaries we're getting a string because we're accessing

string because we're accessing

string because we're accessing text attribute now there is actually

text attribute now there is actually

text attribute now there is actually another attribute which will give us

another attribute which will give us

another attribute which will give us the same thing but as an actual list of

the same thing but as an actual list of

the same thing but as an actual list of dictionaries instead of string and this

dictionaries instead of string and this

dictionaries instead of string and this will be actually a better way to get

will be actually a better way to get

will be actually a better way to get that information because then we can

that information because then we can

that information because then we can work on it so we can

work on it so we can

work on it so we can look through it and get the individual

look through it and get the individual

look through it and get the individual elements

elements

elements and access the values so what i'm gonna

and access the values so what i'm gonna

and access the values so what i'm gonna do now instead of

do now instead of

do now instead of dot text i'm gonna

dot text i'm gonna

dot text i'm gonna use json json is a standard format that

use json json is a standard format that

use json json is a standard format that all programming languages

all programming languages

all programming languages understand and usually when two

understand and usually when two

understand and usually when two applications

applications

applications communicate with each other which are

communicate with each other which are

communicate with each other which are written in different languages

written in different languages

written in different languages and with different technologies with

and with different technologies with

and with different technologies with json they have a common format

json they have a common format

json they have a common format for communication and this requests

for communication and this requests

for communication and this requests module basically gives us this

module basically gives us this

module basically gives us this json function to read the json format

json function to read the json format

json function to read the json format that

that

that gitlab sent us so json function will

gitlab sent us so json function will

gitlab sent us so json function will read the json response

read the json response

read the json response from gitlab and turn it into one of the

from gitlab and turn it into one of the

from gitlab and turn it into one of the python data types

python data types

python data types so i'm going to execute this now and now

so i'm going to execute this now and now

so i'm going to execute this now and now you see that response.json actually

you see that response.json actually

you see that response.json actually gave us list data type instead of string

gave us list data type instead of string

gave us list data type instead of string so again for demonstration

since this is a list i'm going to

since this is a list i'm going to access the first element of that list

access the first element of that list

access the first element of that list and print that out and right here you

and print that out and right here you

and print that out and right here you see

see

see that is actually the first element

that is actually the first element

that is actually the first element just the first one from the list and

just the first one from the list and

just the first one from the list and that element

that element

that element is a dictionary as you see so all these

is a dictionary as you see so all these

is a dictionary as you see so all these just to give you an idea

just to give you an idea

just to give you an idea of what we're getting back from that

of what we're getting back from that

of what we're getting back from that gitlab

gitlab

gitlab api and what we can do with that

api and what we can do with that

api and what we can do with that response or how we can actually work

response or how we can actually work

response or how we can actually work with that response

with that response

with that response so i'm gonna clean all this up and we

so i'm gonna clean all this up and we

so i'm gonna clean all this up and we saw that

saw that

saw that response.json gives us exactly what we

response.json gives us exactly what we

response.json gives us exactly what we want

want

want and that is a list of my projects so

and that is a list of my projects so

and that is a list of my projects so let's call this

variable my projects and now what i want

variable my projects and now what i want to do with this

to do with this

to do with this is i want to print out

is i want to print out

is i want to print out in our window for each project

in our window for each project

in our window for each project project name and project url so

project name and project url so

project name and project url so basically the repository url for that

basically the repository url for that

basically the repository url for that project

project

project so i don't want to have any other values

so i don't want to have any other values

so i don't want to have any other values like id

like id

like id or description or whatever

or description or whatever

or description or whatever other stuff i have in this dictionary i

other stuff i have in this dictionary i

other stuff i have in this dictionary i just want name

just want name

just want name and project url for every single

and project url for every single

and project url for every single project and i want that information

project and i want that information

project and i want that information printed out in this

printed out in this

printed out in this window so how do we do that

window so how do we do that

window so how do we do that we have a list so we're gonna loop

we have a list so we're gonna loop

we have a list so we're gonna loop through that list

through that list

through that list to access each element inside that list

to access each element inside that list

to access each element inside that list so you remember we have for loop to loop

so you remember we have for loop to loop

so you remember we have for loop to loop through

through

through or iterate through a list and give us

or iterate through a list and give us

or iterate through a list and give us access to each element

access to each element

access to each element one at a time so here i'm going to write

one at a time so here i'm going to write

one at a time so here i'm going to write for loop and if you remember the syntax

for loop and if you remember the syntax

for loop and if you remember the syntax of for loop we have

of for loop we have

of for loop we have four and then a variable which will

four and then a variable which will

four and then a variable which will represent the single element in that

represent the single element in that

represent the single element in that list

list

list and in this case it's going to be a

and in this case it's going to be a

and in this case it's going to be a project a single project

project a single project

project a single project and then we have in

and then we have in

and then we have in list so for project in my projects

list so for project in my projects

list so for project in my projects do something so for every project

do something so for every project

do something so for every project element

element

element in this my projects list we want to

in this my projects list we want to

in this my projects list we want to print out the name and the url

print out the name and the url

print out the name and the url so right here i will do print

so right here i will do print

so right here i will do print and let's do our formatted string here

and let's do our formatted string here

and let's do our formatted string here and let's start writing our message

and let's start writing our message

and let's start writing our message let's do

let's do

let's do project name

project name

project name and the project name will be this one

and the project name will be this one

and the project name will be this one right here

right here

right here now how do we actually access

now how do we actually access

now how do we actually access the name of the project in each project

the name of the project in each project

the name of the project in each project element as you see here these project

element as you see here these project

element as you see here these project elements are actually

elements are actually

elements are actually dictionaries and how do we access a

dictionaries and how do we access a

dictionaries and how do we access a value in a dictionary

value in a dictionary

value in a dictionary using the name of the dictionary in this

using the name of the dictionary in this

using the name of the dictionary in this case

case

case our variable project so this whole thing

our variable project so this whole thing

our variable project so this whole thing is going to be

is going to be

is going to be saved into a variable called project and

saved into a variable called project and

saved into a variable called project and then on that

then on that

then on that variable on the dictionary we're going

variable on the dictionary we're going

variable on the dictionary we're going to pass in

to pass in

to pass in the name of the key which is name

the name of the key which is name

the name of the key which is name now i've been using double quotes

now i've been using double quotes

now i've been using double quotes throughout our project

throughout our project

throughout our project and for a syntax for dictionaries as

and for a syntax for dictionaries as

and for a syntax for dictionaries as well

well

well like this

right however here we have a small

right however here we have a small problem which is

problem which is

problem which is we have double quotes inside the double

we have double quotes inside the double

we have double quotes inside the double quotes but as you remember

quotes but as you remember

quotes but as you remember for string representation we can

for string representation we can

for string representation we can actually use

actually use

actually use single quotes as well as double quotes

single quotes as well as double quotes

single quotes as well as double quotes and this is one of the

and this is one of the

and this is one of the really important use cases for why we

really important use cases for why we

really important use cases for why we can actually use

can actually use

can actually use both single and double quotes for a

both single and double quotes for a

both single and double quotes for a string

string

string and that is if we have a string inside

and that is if we have a string inside

and that is if we have a string inside another string

another string

another string like right here we can actually use that

like right here we can actually use that

like right here we can actually use that interchangeably so that we don't have

interchangeably so that we don't have

interchangeably so that we don't have this problem here

this problem here

this problem here so now as you see back to normal

so now as you see back to normal

so now as you see back to normal everything works because

everything works because

everything works because now python knows okay this is another

now python knows okay this is another

now python knows okay this is another string

string

string which we're using inside this string

which we're using inside this string

which we're using inside this string so we can use these interchangeably as

so we can use these interchangeably as

so we can use these interchangeably as we want so this could be single quotes

we want so this could be single quotes

we want so this could be single quotes and this could be double quotes

and this could be double quotes

and this could be double quotes wouldn't really matter but that's a

wouldn't really matter but that's a

wouldn't really matter but that's a really good use case why we need

really good use case why we need

really good use case why we need both types of quotes so we have the

both types of quotes so we have the

both types of quotes so we have the project name

project name

project name now we need a project url

and let's see where the project url is

and let's see where the project url is in our dictionary

in our dictionary

in our dictionary this is one element one dictionary right

this is one element one dictionary right

this is one element one dictionary right so

so

so i'm gonna scroll it to the left

i'm gonna scroll it to the left

i'm gonna scroll it to the left and we have web url this is what we

and we have web url this is what we

and we have web url this is what we could use

could use

could use or we could also use http url to repo

or we could also use http url to repo

or we could also use http url to repo let's go with the web url so again this

let's go with the web url so again this

let's go with the web url so again this is a

is a

is a key inside the dictionary so we can

key inside the dictionary so we can

key inside the dictionary so we can access

access

access the value so this is actually the value

the value so this is actually the value

the value so this is actually the value we need and we can access that using

we need and we can access that using

we need and we can access that using the dictionary name projects

and the key name which is web url and

and the key name which is web url and this is actually project

this is actually project

this is actually project not projects and this code will now

not projects and this code will now

not projects and this code will now print

print

print name and url for each project so let's

name and url for each project so let's

name and url for each project so let's actually execute our program

actually execute our program

actually execute our program and as you see we have project name and

and as you see we have project name and

and as you see we have project name and project url

project url

project url for each project we can make the output

for each project we can make the output

for each project we can make the output a little bit cleaner

a little bit cleaner

a little bit cleaner let's do a new line here

let's do a new line here

let's do a new line here and a new line here so we can separate

and a new line here so we can separate

and a new line here so we can separate the projects from each other and

the projects from each other and

the projects from each other and run again and there you go this looks a

run again and there you go this looks a

run again and there you go this looks a little bit cleaner

little bit cleaner

little bit cleaner for each project we have a name and a

for each project we have a name and a

for each project we have a name and a url

url

url so if i click inside i'll go directly to

so if i click inside i'll go directly to

so if i click inside i'll go directly to this

this

this project so that's basically a very

project so that's basically a very

project so that's basically a very simple example of how to use

simple example of how to use

simple example of how to use requests module to talk to external

requests module to talk to external

requests module to talk to external applications

applications

applications or external urls and then do something

or external urls and then do something

or external urls and then do something with the response that we get

with the response that we get

with the response that we get from that external application by first

from that external application by first

from that external application by first converting that into an actual data type

converting that into an actual data type

converting that into an actual data type that we're getting using json function

that we're getting using json function

that we're getting using json function so in our case it was a list

so in our case it was a list

so in our case it was a list and that's why json function actually

and that's why json function actually

and that's why json function actually converted it into

converted it into

converted it into a list if the response was a dictionary

a list if the response was a dictionary

a list if the response was a dictionary instead of at least

instead of at least

instead of at least then json would convert it into a

then json would convert it into a

then json would convert it into a dictionary

dictionary

dictionary and then we can do something with that

and then we can do something with that

and then we can do something with that response value

congratulations you made it till the end

congratulations you made it till the end i hope you learned a lot

i hope you learned a lot

i hope you learned a lot and got some valuable knowledge from

and got some valuable knowledge from

and got some valuable knowledge from this course if you like the course

this course if you like the course

this course if you like the course please leave a thumbs up on this video

please leave a thumbs up on this video

please leave a thumbs up on this video on my channel i actually cover

on my channel i actually cover

on my channel i actually cover lots of different devops topics like

lots of different devops topics like

lots of different devops topics like docker ci cd

docker ci cd

docker ci cd terraform and more so be sure to check

terraform and more so be sure to check

terraform and more so be sure to check out

out

out my tutorials if you're learning python

my tutorials if you're learning python

my tutorials if you're learning python to become a devops engineer

to become a devops engineer

to become a devops engineer i actually have a complete devops

i actually have a complete devops

i actually have a complete devops bootcamp

bootcamp

bootcamp with all the technologies you need to

with all the technologies you need to

with all the technologies you need to learn as a devops engineer

learn as a devops engineer

learn as a devops engineer which also includes a module for

which also includes a module for

which also includes a module for automation with python

automation with python

automation with python with several cool demo projects to

with several cool demo projects to

with several cool demo projects to automate some

automate some

automate some common devops tasks like application and

common devops tasks like application and

common devops tasks like application and server monitoring

server monitoring

server monitoring cloud automation tasks with aws

cloud automation tasks with aws

cloud automation tasks with aws jenkins etc so if you're interested

jenkins etc so if you're interested

jenkins etc so if you're interested check out more info in the description

check out more info in the description

check out more info in the description also happy to connect with you on social

also happy to connect with you on social

also happy to connect with you on social media

media

media so i would love to see you there with

so i would love to see you there with

so i would love to see you there with that said

that said

that said thank you for watching and see you in

thank you for watching and see you in

thank you for watching and see you in the next video

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.