PYTHON FUNDAMENTAL
CHAPTER -IV (PART - 1)
CLASS – XI
INTRODUCTION
In this
chapter, we will learn about all basic elements that a python program can
contain. You’ll be learning about Python’s basics like Character set, tokens,
expressions, statements, simple input and output etc.
Python
Character Set: A set of valid characters recognized by python. Python uses the
traditional ASCII character set. The latest version recognizes the Unicode
character set. The ASCII character set is a subset of the Unicode character
set.
Letters: A-Z, a-z
Digits: 0 to 9
Special Symbols:
Special symbol
available over keyboard like +, -, ( ), *, & ^ %, !, @, # , etc.
White Space: Blank space, tab, carriage return,
new line, form feed.
Other Characters:
Python can process all
ASCII and Unicode characters as part of data or literals.
Example:
a1 =
‘Informatics Practices’
b1 =
‘Computer Science
print
(‘a1’, and, ‘b1’)
The output
will be
Informatics Practices and
Computer Science
raw_input(): Function in Python allow a user to
give input to a program from a keyboard but in the form of string
Exampe:
name
=int(input(“Enter your Name”))
age =
int(input(“Enter your Age”))
per =
float(input(“Enter your Percentage”))
Token
The
smallest individual unit in a program is known as a Token or a lexical unit.
1. Keywords
2.
Identifiers
3. Literals
4.
Operators
5.
Punctuators
and |
Del |
is |
yield |
not |
as |
For |
pass |
expect |
try |
assert |
In |
with |
if |
False |
break |
Or |
else |
nonlocal |
True |
class |
While |
global |
return |
None |
continue |
Elif |
lambda |
finally |
|
def |
From |
raise |
import |
|
Identifiers:
A Python identifier is a name used to identify a variable, function, class
module, list, dictionaries or other objects.
Some important points for identifier:
An
identifier starts with a letter A to Z or a to z or and underscore(_) followed
by zero or more letters, underscore and digits (0 to 9).
Python does
not allow special characters.
Identifier
must not be a keywords of Python.
Python is a
case sensitive programming language. Thus, Rollno and rollno are two different
identifiers in Python.
Example of valid and invalid identifiers
Valid:
Myname, file123, Y2ad, date_2, _no
Invalid:
2rno, break, my.name, data-cs
Literals:
Literals in Python can be defined as number, text, or other data that represent
values to be stored in variables. Python allows several kinds of literals: (i)
String (ii) Numeric (iii) Boolean (iv) Special literal (v) Literal collections
Example of String Literals
name =
‘Shekhar’ , fname = “shekhar”
Example of
Integer Literal (Numeric Literal)
age = 15
Example of
Special Literals
name = None
Escape
Sequence |
Description |
\\ |
Backslash (\) |
\’ |
Single quote (‘) |
\” |
Double quote(“) |
\a |
ASCII Bell (BEL) |
\b |
ASCII Backspace (BS) |
\f |
ASCII Formeed (FF) |
\n |
ASCII Linefeed (LF) |
\r |
ASCII Carriage Return (CR) |
\t |
ASCII Horizontal Tab (TAB) |
\v |
ASCII Vertical Tab (VT) |
\ooo |
Character with octal value |
\xhh |
Character with hex value hh |
No comments:
Post a Comment
Please do not any spam in the comment box.