Data Types Variables And Operators In Python | Python Fundamentals | Great Learning

Great Learning
11 Oct 202017:47

Summary

TLDRThis tutorial introduces the fundamentals of Python programming, focusing on data types, variables, and operators. It explains how variables act as temporary storage for data, which can be manipulated using different types of operators. The video covers arithmetic, relational, and logical operators, providing examples of each. Additionally, it highlights the importance of understanding data types such as integers, floating-point numbers, booleans, and strings. The tutorial is aimed at beginners and promotes a free learning platform called Great Learning Academy, offering courses in various fields.

Takeaways

  • ๐Ÿ˜€ The tutorial emphasizes the importance of learning Python fundamentals before moving on to complex topics.
  • ๐Ÿ”‘ Understanding data types, variables, and operators is crucial for mastering Python.
  • ๐Ÿ“š Variables in Python are used to store data temporarily and can be changed multiple times.
  • ๐Ÿ“ String values, denoted by quotes, are a type of data that can be stored in variables.
  • ๐Ÿ”ข Data types in Python include integers, floating-point numbers, booleans, and strings.
  • ๐Ÿงฎ Arithmetic operators such as +, -, *, and / are used to perform basic mathematical operations on variables.
  • ๐Ÿ” Relational operators like <, >, ==, and != help compare values and return boolean results.
  • ๐Ÿค– Logical operators AND (&&) and OR (||) are used to combine boolean values and determine complex conditions.
  • ๐Ÿ’ก The tutorial introduces the concept of comments in Python, which are ignored by the interpreter and used for notes.
  • ๐ŸŒ Great Learning Academy offers free courses on various topics, including Python, to enhance learning opportunities.

Q & A

  • What is the first step in learning Python according to the script?

    -The first step in learning Python is to understand the fundamentals, which includes learning about data types, variables, and operators.

  • What is the purpose of a variable in Python?

    -A variable in Python serves as a temporary storage space where data can be stored and changed as needed. It holds a value that can be manipulated throughout the program.

  • How can you change the value of a variable in Python?

    -You can change the value of a variable in Python by assigning a new value to it using the assignment operator (=) followed by the new value.

  • What are the four main data types mentioned in the script?

    -The four main data types mentioned in the script are integers, floating-point numbers, booleans, and strings.

  • What is the difference between a single and double equal sign in Python?

    -In Python, a single equal sign (=) is used for assignment, while a double equal sign (==) is used for comparison to check if two values are equal.

  • What is a comment in Python and how is it written?

    -A comment in Python is a piece of code that is not executed by the Python interpreter. It is written using the hash symbol (#) followed by the comment text.

  • What are arithmetic operators and how are they used in Python?

    -Arithmetic operators in Python are used to perform mathematical operations like addition, subtraction, multiplication, and division. They include the plus (+), minus (-), multiplication (*), and division (/) symbols.

  • What are relational operators and what do they help to determine?

    -Relational operators are used to compare two values and determine their relationship. They include less than (<), greater than (>), equal to (==), and not equal to (!=) symbols.

  • What are logical operators in Python and give an example of each?

    -Logical operators in Python are used to combine conditional statements and include 'and' and 'or'. 'and' returns True if both conditions are True, while 'or' returns True if at least one of the conditions is True.

  • What is a complex data type in Python and how is it represented?

    -A complex data type in Python is used to represent complex numbers which have a real part and an imaginary part. It is represented with the real part followed by 'j' for the imaginary part, for example, '3 + 5j'.

  • What is the Great Learning Academy and what does it offer?

    -The Great Learning Academy is a free learning platform mentioned in the script that offers access to free courses such as AI and digital marketing.

Outlines

00:00

๐Ÿ Introduction to Python Variables

This segment introduces the basics of Python programming, focusing on variables. Variables are explained as temporary storage spaces that can hold data, which can be changed over time. The tutorial demonstrates how to store and change the values of variables using examples such as storing employee names. It also mentions the launch of a free learning platform called Great Learning Academy, which offers courses in various fields including AI and digital marketing.

05:01

๐Ÿ”ข Exploring Python Data Types

The second paragraph delves into the different data types in Python. It explains that every variable in Python has an associated data type, which can be integers, floating-point numbers, booleans, or strings. The presenter demonstrates how to create variables for each data type and uses the 'type' function to verify the data type of the variables. The paragraph also introduces complex numbers, which have a real and an imaginary part, represented in Python with 'j'.

10:02

โž—โž•โž– Basic Arithmetic Operations in Python

This part of the script covers arithmetic operators in Python, which are used to perform mathematical operations on variables. The presenter creates two variables and demonstrates how to use the addition, subtraction, multiplication, and division operators. The results of these operations are shown, highlighting the basic arithmetic capabilities of Python.

15:04

๐Ÿ” Relational and Logical Operators in Python

The final paragraph discusses relational and logical operators in Python. Relational operators are used to compare values and include less than, greater than, equal to, and not equal to symbols. Logical operators, such as 'and' and 'or', are used to combine boolean values. The presenter provides examples of how these operators work with boolean variables, showing the outcomes of different combinations of true and false values.

Mindmap

Keywords

๐Ÿ’กPython

Python is a high-level, interpreted programming language known for its readability and ease of use. In the video, Python is the central theme as the tutorial focuses on teaching the fundamentals of programming in Python, including data types, variables, and operators. It is used as the medium to demonstrate programming concepts.

๐Ÿ’กVariables

Variables in programming are used to store data values. The video explains that variables act as temporary storage spaces that can hold different data types, and their values can be changed. This is illustrated by creating variables to store employee names like 'John', 'Sam', and 'Matt'.

๐Ÿ’กData Types

Data types refer to the classification of data items, such as numbers, strings, and booleans, which determine what kind of values a variable can store. The video covers various data types in Python, including integers, floating-point numbers, booleans, and strings, providing examples for each to demonstrate how they are used and identified in the language.

๐Ÿ’กOperators

Operators are symbols that perform operations on variables and values. The tutorial discusses different types of operators in Python, including arithmetic, relational, and logical operators. Arithmetic operators are used for mathematical operations, relational operators compare values, and logical operators deal with boolean logic.

๐Ÿ’กArithmetic Operators

Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication, and division. In the script, examples are given where the operator '+' is used to add two numbers, and the '/' operator is used for division, demonstrating basic arithmetic operations in Python.

๐Ÿ’กRelational Operators

Relational operators are used to compare two values and return a boolean result. The video explains and demonstrates the use of '<' (less than), '>' (greater than), '==' (equal to), and '!=' (not equal to) operators to compare numerical values, showing how these operators help in decision-making within programs.

๐Ÿ’กLogical Operators

Logical operators are used to combine boolean values and determine the flow of a program based on true or false conditions. The video discusses 'and' and 'or' operators, explaining that 'and' returns true only if both conditions are true, while 'or' returns true if at least one condition is true.

๐Ÿ’กBoolean Values

Boolean values are a data type that can be either True or False. They are used in decision-making processes within a program. The video demonstrates boolean values with examples such as 'True' and 'False', and how they interact with logical operators to control program flow.

๐Ÿ’กString

A string in Python is a sequence of characters enclosed in quotes, which can be single, double, or triple. The video explains that strings are used to handle text data, and it provides examples of creating string variables and checking their data type.

๐Ÿ’กGreat Learning Academy

Great Learning Academy is mentioned as a free learning platform in the video. It is used as an example of an external resource that offers free courses, suggesting that learning Python and other subjects can be accessed through various educational platforms.

๐Ÿ’กJupyter Notebook

Jupyter Notebook is an interactive computing environment that allows users to create and share documents containing live code, equations, visualizations, and narrative text. The video uses Jupyter Notebook to demonstrate Python code examples, showing how variables and data types are used in a practical programming environment.

Highlights

Fundamentals of Python include learning about data types, variables, and operators.

Variables in Python are used to store data temporarily and can be changed.

Data types in Python include integers, floating-point numbers, booleans, and strings.

Integers are whole numbers without a decimal point.

Floating-point numbers include decimal points and can be positive or negative.

Boolean values can be either True or False, represented as 1 or 0.

Strings are sequences of characters enclosed in quotes.

Complex numbers consist of a real part and an imaginary part, represented with 'j'.

Arithmetic operators in Python include addition, subtraction, multiplication, and division.

Relational operators help to find the relationship between two values, such as less than or greater than.

The equality operator (==) checks if two values are equal, while the assignment operator (=) assigns a value to a variable.

Logical operators include 'and' and 'or', which combine boolean values.

The 'and' operator returns True only if both operands are True.

The 'or' operator returns True if at least one of the operands is True.

Great Learning Academy offers free courses in various fields, including data science and digital marketing.

The tutorial concludes with a summary of the concepts covered on data types, variables, and operators in Python.

Transcripts

play00:00

If you are a master python you would

play00:02

obviously have to learn the fundamentals off Python

play00:04

Before you move into complex topics you'd have

play00:07

to learn about data types variables and operators

play00:09

and python This brief tutorial will cover exactly

play00:12

that Yeah yeah who now before we guy's

play00:25

head off to the session I would like

play00:27

to inform that we have launched a completely

play00:29

free platform called as Great Learning Academy We

play00:32

have access to free causes such as a

play00:34

iCloud and digital marketing You can check out

play00:37

the details in the description below Let's start

play00:40

off by understanding what exactly are variables in

play00:43

Python Now when you work with any programming

play00:46

language your first task needs to be toe

play00:49

work with data isn't it So whatever programming

play00:52

language and working with you are essentially working

play00:55

with data But the question or here is

play00:57

how do you actually store the data that

play01:00

you work with So let's say you're walking

play01:03

in your company and you want to store

play01:05

the names off all of the employees so

play01:07

we start off with taking three employees names

play01:09

So let's say we have John Sam on

play01:12

dMarc with us and we'll have to store

play01:14

these names somewhere So where can we store

play01:17

them This is where a variable comes in

play01:20

so you can consider a variable Toby ord

play01:23

Temporary stories piece Now what we'll do is

play01:26

we'll take this string value So this what

play01:30

you see inside double quotes is known as

play01:32

a string and we'll take this string value

play01:35

and we will store this in this variable

play01:38

called a student Either we can call the

play01:40

student or employee or whatever we want toe

play01:42

and this variable will have a particular address

play01:47

associated with it And since this valuable is

play01:51

a temporary storage space the values which are

play01:54

stored inside it can be changed again and

play01:58

again So initially we are storing this value

play02:02

Jon inside this variable employees or students Then

play02:07

after some time we can go ahead and

play02:09

replace this value John with this value Sam

play02:13

Similarly after some time we are changing this

play02:16

value off Sam with this value off Matt

play02:19

And this is how variables work in Python

play02:22

So now let's go to Jupiter notebook and

play02:24

I'll give you a proper example off this

play02:30

Hear what I'll do is I create a

play02:32

variable called us We are one I'll give

play02:35

him this equal to symbol and I'll go

play02:37

ahead and store the value Jon inside this

play02:40

Let me click on Run Now Let me

play02:42

print out the sprint off Wire one on

play02:45

Let's see what will be the result So

play02:47

we have successfully stored the value Jon inside

play02:50

wire one and we were able to print

play02:52

this out And since Marvin is a variable

play02:55

it is a temporary storage piece So that

play02:57

is why we can change the value which

play02:58

is stored inside this So now instead off

play03:01

John I want to store the value Sam

play03:04

inside this I can't run again I'll you

play03:07

sprint on then I'll be printing out the

play03:10

value off our one And as you guys

play03:13

see initially we had John inside this We

play03:15

were able to change this to some Now

play03:17

again after some time I'll go ahead and

play03:20

change this value to mad Now let me

play03:24

print out War one over here Print off

play03:28

our one on And as you can see

play03:30

initially we had joined Then we change it

play03:32

to Sam and finally we have changed the

play03:35

two mad So that was a basic in

play03:39

proto variables And now another thing to be

play03:42

kept in mind Us Every variable has a

play03:45

data type associated with it So when you're

play03:48

working with data that data can be present

play03:51

in any format So when you're working with

play03:54

numbers such as than 500 minus 1000 minus

play03:59

3 23 these are called us in teachers

play04:02

And when you work with decimal point numbers

play04:05

so decimal point numbers such as 3.14 15.97

play04:10

minus 1.92 all off these would be floating

play04:14

point numbers Then we have something called as

play04:17

bullion values So Boolean values are basically you

play04:21

have only zero and one or you can

play04:24

also tag them as true and false So

play04:28

you have only two values over here and

play04:30

those two values are true and false Or

play04:33

you can also tag them a zero and

play04:35

the one Then we have springs so strings

play04:38

are something which you put in single coats

play04:41

double coats or triple coats So these are

play04:44

the four main data types over here in

play04:46

Python So let's go ahead and look at

play04:48

an example off each of these Now I'm

play04:52

going to start off by creating an in

play04:55

teacher variable so I lame this in teacher

play04:58

variable as numb one And I'll store the

play05:01

value off then inside this and just to

play05:04

see what is the data type off this

play05:07

I will use the type method and inside

play05:10

the type method I'll be passing in number

play05:13

one And as you guys see this tells

play05:15

us that the data type off this particular

play05:18

variable s in teacher Then I'll go ahead

play05:22

and pass in awe Floating point number or

play05:26

a decimal number So I'll call this US

play05:29

Let's sit decimate and in decimate Maybe I'll

play05:34

store in the value off 3.14 Now let

play05:38

me go ahead and check the type off

play05:40

estimates inside this I'll parts an estimate on

play05:44

when I click on run Yeah I see

play05:46

that this is off floating type Then we

play05:49

have the next data type which is off

play05:52

bullion So here I will have maybe another

play05:56

variable called as log one on the inside

play05:59

Log one I will storing the value through

play06:03

Let me hit Run again on then let

play06:06

me check the type off log one So

play06:08

inside type other parts in the variable log

play06:12

one And as you guys see this tells

play06:14

us that this is off bull bull piece

play06:16

Kimeses Oh bullion or logical type And then

play06:19

we've got the character or strength So this

play06:23

time I'll have my variable as car one

play06:28

on and inside this I will store the

play06:30

name Let's say I'll store the name Argenteuil

play06:34

way You then let me check the type

play06:36

off car one And when I had drunk

play06:40

you see that this else is that this

play06:42

is a string type were able We also

play06:45

have another variable over here or another data

play06:48

typo here which is off complex type so

play06:51

complex as be skier data type where you

play06:54

have a really part and an imaginary part

play06:57

So let's say if I write something called

play06:59

us three plus five j So here three

play07:03

would be your riel part on defy J

play07:06

would be your imaginary part You have learned

play07:09

about complex numbers in your primary or in

play07:12

your secondary school So normally in madness J

play07:15

is represented as ice You have something called

play07:18

the three Let's FYI there three would be

play07:20

a really part Fire would be our imaginary

play07:22

part So in python this is represented with

play07:25

J instead off by So now I'll go

play07:29

ahead on store this in a variable Caldas

play07:32

Comp one Now let me go ahead then

play07:35

check the type off this so type off

play07:38

comp one And I see that this is

play07:41

off complex type So we have successfully understood

play07:44

what are variables and we have also looked

play07:47

at the different data types of variable can

play07:50

have Now we'll go ahead with her next

play07:53

concept in Python which will be operators And

play07:57

as the names such as operators help us

play08:00

to perform simple operations on this data on

play08:04

we've got arithmetic operators relational operators and logical

play08:08

operators So we'll start with the first set

play08:10

off operators which are the arithmetic operators Let

play08:14

me go ahead toe the soup eternal back

play08:16

over here and what I'll do worse I

play08:18

will clear out everything which is present in

play08:21

the console So there's scissors which you see

play08:23

If you click on the scissors symbol you

play08:25

will be able to cut out all of

play08:26

the's cells Now let me add a comment

play08:29

So what is the comment Commenters Something which

play08:32

is not executed by the Python interpreter and

play08:36

you can add a comment with this hash

play08:39

symbol So after this hash symbol I am

play08:43

going ahead and writing arithmetic operators I'll can't

play08:48

run And as you see this is not

play08:51

executed over here So whenever you add hash

play08:54

symbol over here Python interpreter automatically recognizes whatever

play08:59

follows hash symbol as a comment Now if

play09:02

I remove this hash symbol and then if

play09:05

I could can't run you would see that

play09:07

we get this arrow which tells us that

play09:09

this is invalid syntax Because if we don't

play09:12

add the hash symbol over here then Python

play09:16

interpreter would consider this these two actually as

play09:20

two separate variables And since we have not

play09:23

declared any variable called us arithmetic or as

play09:27

operator this is giving us this error so

play09:30

I'll just go ahead and at this hash

play09:33

over here now after this since we have

play09:36

to perform arithmetic operators and arithmetic operators basically

play09:40

constitute off Plus we have plus than we

play09:45

have minus than we have multiplication And then

play09:49

we have division Now I'll create two variables

play09:53

over here I'll have first variable number one

play09:56

and I'll store the value off and inside

play09:59

this Then I'll have the second variable number

play10:02

two and I'll go ahead and store the

play10:04

value off 20 inside this Now after creating

play10:08

thes two variables Let me perform the basic

play10:11

arithmetic cooperations so I'll start off by adding

play10:15

numb one and numb to So I'll type

play10:19

numb one less numb to And when I

play10:22

perform numb one pletz numb to I get

play10:25

a result off 30 So basically if you

play10:29

want to add two numbers you have to

play10:31

use the plus symbol between those two operates

play10:33

And since tennis stored in number 1 20

play10:36

is stored in number two we get a

play10:37

result off 30 Then similarly I'll go ahead

play10:42

and perform the subtraction operation So here I'll

play10:45

have number one minus number two And when

play10:49

I type number one minus number So I

play10:52

get a result off minus then because then

play10:55

minus 20 s minus 10 Going ahead I'll

play10:59

also perform multiplication and perform multiplication I'd have

play11:03

to type numb one into numb to and

play11:08

when I have numb one into numb toe

play11:10

over here which is basically 10 into 20

play11:13

I get a result off 200 then we

play11:16

are only left with division sort of performed

play11:19

division I love number one Then I used

play11:22

a forward slash symbol which denotes division Then

play11:27

I'll have the second opera in the war

play11:29

here which is numb to and I can't

play11:31

run and as you guys see when we

play11:33

divide 10 which 20 We get a result

play11:36

off 0.5 So these were some basic arithmetic

play11:41

operations Now we'll go ahead on Dwork with

play11:45

relational operators so I'll just add another comment

play11:49

over here on day I'll add the comment

play11:53

as relational operators and whatever relational operators please

play11:57

help us to find the relationship between two

play12:00

operates So you can understand if one operator

play12:03

the value off one or print is less

play12:05

than the other operating or maybe the value

play12:07

off one operating is greater than the other

play12:09

operate So we will have less than symbol

play12:13

greater than symbol equal to symbol and not

play12:17

equal to symbol Now again we will use

play12:20

the same variables Number one and number two

play12:24

Let me just print out number one and

play12:26

number two over here for your sick And

play12:28

as you guys see we have 10 stored

play12:30

in number one and 20 stored in number

play12:33

two Now I want to check if the

play12:36

value in number one is less than the

play12:39

value in numb to so I'll type number

play12:42

one I lose the less than symbol and

play12:44

I'll type numb toe a hero if you

play12:46

can't run And as you can see I

play12:49

get the result as true Which means that

play12:52

numb one is less than 20 which we

play12:54

get because 10 is obviously less than 20

play12:58

Now I want to check if the value

play13:01

in number one is greater than the value

play13:04

and number two And when I hit run

play13:06

I get off false value because then is

play13:09

not greater than 20 Now Going ahead I

play13:13

want to check if the value in numb

play13:15

one is equal to the value in numb

play13:17

to So that's what you see is the

play13:20

double equal toe operator You have to understand

play13:23

the difference between the double equal toe operator

play13:25

and single equal to operator So this is

play13:28

the single equal toe operator and with the

play13:30

help of single equal toe operator we are

play13:32

assigning a value to a variable But when

play13:37

we are using this double equal toe operator

play13:39

this helps us to understand if these two

play13:43

values if though operate on the left hand

play13:45

side and the operate on the right hand

play13:47

side are equal to each other or not

play13:51

And when I click on Brand I get

play13:53

a false value because then is obviously not

play13:56

equal to 20 Then going ahead I have

play13:59

not equal to operators So I'll have number

play14:02

one It's not equal to operators represented like

play14:05

this so I'll have exclamation mark Then I'll

play14:08

have the equal to symbol Then I'll have

play14:10

numb to or what you and I get

play14:13

a true result because then is obviously not

play14:16

equal to 20 So these were some off

play14:19

the relational operators Going head will work with

play14:22

logical operators So I'll add comment over here

play14:26

to which would be logical operators And we

play14:29

have to logical operators which are on board

play14:33

part Let's start with so on is a

play14:37

logical operator which would give us a true

play14:39

result only when the boat off the operations

play14:44

are true but or is a logical operator

play14:47

which would give us a true result when

play14:49

either off the operation is true So let's

play14:52

understand this in detail so this time I

play14:55

will be creating to bullion variables Over here

play14:58

I'll have log one and in log one

play15:01

I'll have the value truth steward Then I'll

play15:03

have log to and in log to I'll

play15:06

have the value fall stored so I have

play15:09

logged one and lock toe over here Now

play15:13

I'll perform the Ondo operator on both of

play15:17

these So let me go ahead and type

play15:19

log one Onda log toe And when I

play15:23

hit a run I get a false value

play15:25

because log one is through locked doors False

play15:29

true and false will give us a false

play15:32

result Now let me see what will happen

play15:36

when I have log toe and log one

play15:39

again I get a false result because false

play15:42

Andre true is also falls Now let me

play15:45

check log toe and log toe log to

play15:49

and log You will also give me false

play15:51

because false and false is also false And

play15:55

finally I'll check log one and log one

play16:00

log one and log One will give me

play16:02

a true results because on the operator gives

play16:04

a true result only went both off the

play16:07

operations that true Now we'll head onto the

play16:09

or operator So this time I'll have log

play16:13

one or log toe No true or false

play16:19

will give me a true result because or

play16:22

will give me a true result when either

play16:24

off the operations this troop then I'll have

play16:27

log to or log one And this again

play16:32

gives me a crew result because false or

play16:34

true is again through Then I'll have log

play16:38

one or log you and this again Well

play16:43

let me actually change this to log one

play16:45

or log one And this will give me

play16:47

a true result because true or true is

play16:49

also true And finally we'll have log to

play16:55

or log And this is the only case

play16:59

where we'll have a false results with this

play17:01

false or false So only in the case

play17:05

where both off your operations are false doctors

play17:07

when you will get a false result when

play17:09

you're working with the or operator So this

play17:12

was all about different types off operators in

play17:16

fightin This brings us to the end of

play17:18

this tutorial on data types variables and operators

play17:21

in python Before you guys sign off I'd

play17:23

like to inform that we have launched a

play17:25

completely free learning platform called as Great Learning

play17:28

Academy But you have access to free causes

play17:31

such as a iCloud and they're still marketing

play17:33

But thank you very much for attending this

play17:34

session and have a great learning

Rate This
โ˜…
โ˜…
โ˜…
โ˜…
โ˜…

5.0 / 5 (0 votes)

Related Tags
Python TutorialData TypesVariablesOperatorsProgrammingCode LearningArithmeticRelationalLogicalEducational Content