Learn How to Correctly Assign Values with Python 3


show more Assigning values provides you with in-depth training on Developer. Taught by Bill Weinman as part of the Python 3 Essential Training show less
please wait ...

Assigning values

Assignments in Python are handled with the assignment operator, which is the Equal sign. Let's go ahead and make a working copy of syntax.py. I'll call it syntax-working.py. And we'll open that working copy, and we'll go ahead and create an assignment. So I'll have a variable called a, and I will assign it the value 1. Now what this does in Python is it actually defines the variable a, and it creates an integer type variable, and it puts the value 1 in it.

And so in the print statement, I can print a. And if I go ahead and save this and run it, we'll see that we get the value 1 printed. If instead I were to put a string there, say "one" spelled out, run that then we get a one here. We can look at the type of the variable that was created by using the type function. And so this will print the type and the value.

Save that and run it. See that that's a Class String, it's the type. In fact everything in Python is an object, and objects have classes, and...

Assigning values
Video duration: 3m 37s 6h 36m Beginner

Viewers:

Assigning values provides you with in-depth training on Developer. Taught by Bill Weinman as part of the Python 3 Essential Training

Subjects:
Developer Web
Software:
Python
Author:
please wait ...