Pages

Monday, March 23, 2015

Pick up a variable and displays the value of a variable in Python 3.

Hello, this article is talking about is the variable value and the display value in Python 3 why there must be a variable. A variable is a property that has changed.Represented by a symbol such as the variable X, Y etc.

Variables are easy to activate the data. If to compare. I asked for a simple comparison it is like a variable with spaces for filling in documents.

The naming rules for variables in Python 3

  1. Do not set the variable name corresponds to Python's keyword 3 keyword is as follows: False class finally is return None continue for lambda try True def from nonlocal while and del global not with as elif if or yield assert else import pass break except in raise But you can use uppercase. Do not use lowercase.
  2. Do not use special symbols ,such as/*-+ #!-% $, etc.
  3. Do not use numbers.
  4. Do not leave empty.

Format To get the variable value in Python 3.

>> variable = input().
For example, in a text format, such as..
>>> name = input("What is your name? ")
results:
What is your name?

Input:
What is your name? tontan

For example, in the number format.
>> a = int(input("input1: "))

Show up or pulling values from variables in Python 3.

> > Variant
For example

>> name

It will display the results variable value.
'tontan'
Or print name
It shows the variable value as well.

Examples of programming in Python 3 using variables as well.


Positive number
>>> a = int(input("input1: "))
input1: 1
>>> b = int(input("input1: "))
input1: 3
>>> print ("=" , a + b)
= 4

Thank you.

No comments:

Post a Comment