Python print variable | Python data types in Python 3

Python print variable

How to Print Python variable?

In this Lecture, we are going to learn how to Python print variable and its Python Data Types in Python 3.

You can declare a variable without its Data Types in Python. It will automatically judge it’s the data type of any variable with respect to its given value.

Firstly, we discuss what are variables and why we can use it in its program.

Are you want to know, How to Python print variable? Ohh really, let’s start…

 Variable: it is used to store or hold any value in the program. 

Python print variable

Simple write variable’s name without any data types. Also, initialize its value with an equal sign like.

name= "ABDUL JABBAR"

Don’t need to declare string Data Type in Python. And, you don’t need to include the semicolon (;) as well. As we write the second variable.

age= 23

You don’t need to declare it’s integer data type as well.

marks=988.0

You don’t need to declare the Float Data Type as well.

How to make multiple Variables in the single line and also initialize its value

We can make the different variable in a single line that is separated by a comma (,).

Sname, Sage, Smarks = "ABDUL JABBAR", 23, 988.0

#We can access this varibale simply as:

print (Sname)
Output: ABDUL JABBAR

print(Sage)
Output: 23

print (Smarks)
Output: 988.0

You can access separately every single variable where you want to access by its name.

You can also assign a single value for more than one variable.

Like

Ali= Ahsan= Bilal = "White shirt"
print (Ali)
Output: White shirt

print (Ahsan)
Output: White shirt

print (Bilal)
Output: White shirt

Same as it is we can access the single value through multiple variables in the program.

Python data types in Python 3

Python Data Types in Python 3

  1. Numbers
  2. Strings
  3. List
  4. Tuple
  5. Dictionary

As we can write about the student’s age variable (Sage=23). I said that there is don’t need to declare it’s the Data type.

Because in Python variable type can be judged by its value which is given. We are going to prove that how to judge Python Data Types in Python 3 automatically.

We can write the name of a variable with type keyword to find it’s data types. Like Sage variable as bellow

Sage = 27 # student age
type(Sage)
Output: <class 'int'>

As we can declare a string variable and find it’s type Like

Sname = "ABDUL JABBAR" # Student name
type(Sname)
Output: <class 'string'>

Smarks = "988.0"
Type(Smarks)
Output: <class 'float'>

Python automatically stores Value according to its Data Types.

Related Video

Video’s Credit: sentdex

I hope you can understand how to Python print Variable and its Python Data types in Python 3.

Add a Comment

Your email address will not be published. Required fields are marked *