Professional Documents
Culture Documents
COMPUTER SCIENCE-XII-CH1p1
COMPUTER SCIENCE-XII-CH1p1
COMPUTER SCIENCE-XII-CH1p1
with
PYTHON
STATEMENT
EXPRESSIONS
Root statement
Indent content
Here root statement show the main statement of block, under which a block defined. And indent content is part of block
An block can have multiple statement8, expression, comments etc. block always start by : colon sign on root statement
Floating
Integer complex String Tuples Lists Dictionary
point
Boolean
Here you find that according to value variable showing different data type behaviour
Computer Science with PYTHON class XII Chaper-1 14
4.Keywords
• Keywords are the reserved words used by python interpreter to recognize
the structure of a program. These words interpreted by interpreter and
performed task according to their definition
As on above example, variable l is a kind of list, first As shown on above example, variable a is a kind of
we initialized the list with values 1,2 and 3 afterword tuple, and trying to change value but we got error,
we try to change value 2 with 10, and it got changed mean it not allow to change
List, Dictionary Int, float, complex, bool, string, tuple
Remainder
-= Subtract and assign Subtract two number and assign to left side A-=B or A-=10
variable
*= Multiply and assign Used to find product of given operands and assign A*=B or A*=10
to left side variable
/= Divide and assign To find the quotient with fraction part and assign A/=B, A/=5
to left side variable
//= Floor Division and To find the quotient with integer part and assign to A//=B, A//=2
assign left side variable
**= Exponent and To raise a number to the power of another number A**=B, A**=2
assign and assign to left side variable
%= Divide and assign It used to find remainder on division operation and A%=B, A%=5
remainder assign to left side variable
= Assignment Just used to assign value to left side variable A=10, mean value 10 assign to A or A=B, value of B assign to
variable a
Computer Science with PYTHON class XII Chaper-1 20
6.Operator and operands- Relational Operator
Symbol Operator Description Example
Relational operator perform compare operands and produces output in terms of TRUE or A=10,B=5
FALSE result
== Equality If both operand equal, it produce True otherwise A==B FLASE
false
!= Inequality If both operand are not equal, it produce True A!=B TRUE
otherwise false
< Less Than Produce TRUE, If left operand is smaller than right A<B FALSE
operand, in case both equal it produce false
<= Less than or Produce True if left operand is smaller or equal A<=B FALSE
Equal to
> Greater Than Produce TRUE, If left operand is Greater than right A>B TRUE
operand, in case both equal it produce false
>= Greater than Produce True if left operand is greater or equal A>=B TRUE
or Equal to Computer Science with PYTHON class XII Chaper-1 21
6.Operator and operands- Logical Operator
Symbol Operator Description Example
operator perform operation on basis of logic, AND OR NOT gate, in programming NON Zero (positive or
negative value)represent True and ZERO represents False
AND If both operand true, it produce True otherwise A=1,B=0 A AND B FLASE
false
A=1,B=1 A AND B TRUE
Functions: Int(), float(), str(), chr(),unichr() are used as type casting functions
Computer Science with PYTHON class XII Chaper-1 25
7.Input and output(python’s built-in functions)
Output: function used to display output result on screen, in python
print() is used for the same
Print( value , Sep=‘ ‘ , end=“\n” )
This is the message which we want In case of multiple values, how one will How a line end, by default new
to display separate with other, by default blank space line expression works