Quantcast
Channel: CodeSection,代码区,Python开发技术文章_教程 - CodeSec
Viewing all articles
Browse latest Browse all 9596

Learning Python Variables

$
0
0

We all know that variables are a key part of programming and scripting languages, and sure enough, they are a big part of python. Here is how simple they are to implement:

#Today we are going to create and use some variables!
#This is really cool!
#Hey just to remind you, these are comments that are here to make our code "self-documenting"!
#Python itself is ignoring the s#$t out of these!
my_books = 14
my_years_on_planet = 47
books_per_year_on_planet = my_books / my_years_on_planet
print ("Below is my books per year on the planet!")
print (books_per_year_on_planet)

Notice here I am using Python 3 so I need parenthesis around the objects and text that I want to print!

Here is the result of my program!

Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
======================= RESTART: C:\Users\terry\ex3.ps =======================
Below is my books per year on the planet!
0.2978723404255319
>>>

Viewing all articles
Browse latest Browse all 9596

Trending Articles