PYTHON:
- Developed by Guido Van Rossum in Feb 1991; python was named after famous BBC comedy show namely Monty Python Flying Circus.
- based on two programming language : ABC language(replacement of BASIC) and Modula
- Interpreted language, Cross Platform language(run on every type of OS), Free and Open source(no license required) & Object Oriented Language
- Case Sensitive Language (treats uppercase letter ABC and lowercase letter abc differently)
- Working on Python have two modes i.e. Interactive mode and Script mode
- Interactive Mode: write one command at a time and receives output immediately.
- >>> is the python prompt
- Script Mode: We have to write whole program first then save the program (with .py extension) & then receive output.
- F5 is the shortcut key to run python program.
PYTHON FUNDAMENTALS:
TOKENs: The smallest individual unit in a program is known as Token or a Lexical unit.
such as: Keywords, Identifiers, Literals, Operators, Punctuators
Keywords: predefined words with special meaning to the Interpreter.
Total 35 keywords (previous 33 + await & sync)
3 keywords starts with capital letter i.e. True, False & None
True |
as |
and |
assert |
break |
while |
False |
if |
else |
elif |
class |
raise |
None |
del |
except |
finally |
Continue |
yield |
import |
global |
from |
for |
def |
await |
in |
is |
not |
or |
pass |
sync |
lambda |
nonlocal |
return |
try |
with |
|
IDENTIFIERS: are the names given to the different parts of the program (variable, object, class, function, list, dictionary etc.)
RULES for naming identifiers:
- name must be a non keyword word with no space in between
- name should be only of letters, numbers and only one special character underscore(_)
- can't begin with a number
for example: myfile, date_12, _abc
LITERALS/VALUES: literals are the data items that have fixed or constant values.
- several kinds of literals: String, Numeric, Boolean, Special Literal(None), Literal Collections
String Literals: sequence of characters surrounded by quotations (' ', " ", '" '").
- Single line String : sequence of characters surrounded by single quotations (' ') or double quotations (" ").
- Multiline Strings: text1="' hello
what are you doing"'
Multiline string with single quotation and double quotation is also possible with a slash (/) at the end of line.
No comments:
Post a Comment