Python Classroom image

Anil  Bist / Professional / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16|Last
Lessons:-INTRODUCTION

1.7. PRINT FUNCTION, PART I 16
fred = ’Frederick’
first = fred
first
Now fred, without the quotes, makes sense.
There are more subtleties to assignment and the idea of a variable being a “name for” a value, but we
will worry about them later, in Section 2.4.6. They do not come up if our variables are just numbers and
strings.
Autocompletion: A handy short cut. Python remembers all the variables you have defined at any moment.
This is handy when editing. Without pressing Enter, type into the Shell just
f
Then hold down the Alt key and press the ’/’ key. This key combination is abbreviated Alt-/. You
should see f autocompleted to be first. This is particularly useful if you have long identifiers! You can
press Alt-/ several times if more than one identifier starts with the initial sequence of characters you typed.
If you press Alt-/ again you should see fred. Backspace and edit so you have fi, and then and press Alt-/
again. You should not see fred this time, since it does not start with fi.
1.6.1. Literals and Identifiers. Expressions like 27 or ’hello’ are called literals, coming from the
fact that they literally mean exactly what they say. They are distinguished from variables, who value is not
directly determined by their name.
The sequence of characters used to form a variable name (and names for other Python entities later) is
called an identifier. It identifies a Python variable or other entity.
There are some restrictions on the character sequence that make up an identifier:
• The characters must all be letters, digits, or underscores ’_’, and must start with a letter. In
particular, punctuation and blanks are not allowed.
• There are some words that are reserved for special use in Python. You may not use these words
as your own identifiers. They are easy to recognize in Idle, because they are automatically colored
orange. For the curious, you may read the full list:
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
There are also identifiers that are automatically defined in Python, and that you could redefine, but you
probably should not unless you really know what you are doing! When you start the editor, we will see how
Idle uses color to help you know what identifies are predefined.
Python is case sensitive: The identifiers last, LAST, and LaSt are all different. Be sure to be consistent.
Using the Alt-/ auto-completion shortcut in Idle helps ensure you are consistent.
What is legal is distinct from what is conventional or good practice or recommended. Meaningful
names for variables are important for the humans who are looking at programs, understanding them,
and revising them. That sometimes means you would like to use a name that is more than one word
long, like price at opening, but blanks are illegal! One poor option is just leaving out the blanks, like
priceatopening. Then it may be hard to figure out where words split. Two practical options are
• underscore separated: putting underscores (which are legal) in place of the blanks, like price_at_opening.
• using camelcase: omitting spaces and using all lowercase, except capitalizing all words after the
first, like priceAtOpening
Use the choice that fits your taste (or the taste or convention of the people you are working with).
1.7. Print Function, Part I
In interactive use of the Python interpreter, you can type an expression and immediately see the result
of its evaluation. This is fine to test out syntax and maybe do simple calculator calculations. In a program

 
 
 
image
Anil  Bist

Skills    Python

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,India
Description:-

I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a
Explore

 

  Students (0)