Adobe Scan 08 Sept 2024
Adobe Scan 08 Sept 2024
ecial English
alphabet
letters
-) to
90
A-Z,
a-z
&
#
=,
tabs,
iage
urn,
line
Symbols Description Examples
Using backslash (\) You can use a backslashat the end of a line total=10 + \
to indicate that the statement continues on 20 + \
the next line. 30
ecial Variable
() Space
is
is not
is
a
cters
allowed name not
allowed
cannot
in
in are
variable a in
not start
wed variable a
with
so name. Reason
it a
in digit.namne.
iable a
be
name.
as
a
Operator Name Description Example Output
Addition >>2+3 5
It adds two operands.
Subtraction It subtracts the right operand from the left. >>16-3 13
Greater than
It returns True if the left operand is >>>3>5 False
greater than the right.
< Less than It returns True if the left operand is less >>>3K5 True
than the right.
It returns True if both the operands are >>>456 False
==
Equal to
equal.
It returns True if the operands are not >>>45!-6 True
Not equal to
equal.
Greater than It returns True if the left operand is >>>34=105 False
or equal to greater than or equal to the right.
<=
Less than or It returns True if the left operand is less >>34<=105 True
equal to than or equal to the right.
Operator
not Or and
True
not
>>>not
False >>> False>>>True
>>>True False
and True
or >>>True and
False
Example
or
False
X +=2 X=X t2
X=2 X=X-2
*= x *=2 X=x*2
x=2 X=x/2
%= x%=2 X=X %2
x /=2 x=x/ 2
x **= 2 X=x **2
lication, Parentheses
Floor Unary
vision,
Exponentiation
sion,
n,
plus, Precedence
Unary
lus
minus
()
*,1,1|, % +X,-X
Operators
KiB0s
uery 1
n
e
o
a
Precedence Operators
Parentheses
Exponentiation
Unary plus, Unary minus +X, -X
Multiplication, Division,
|,%
Floor division, Modulus
Addition, Subtraction t, -
Relational
not
Logical not
and
Logical and
or
Logical or
)Z=X+Y print(Z)
="Hell0" X=5 Z=X+Y
Y="good. "print("The
X="I
am" print y 10X
=
print("I
5=
("The
am
sumvalue
learning
of Example
X of
and x
is:", Python"
y
is:",x
x) )
+
y)
An
and Explanation: The The
good.am
I I
am
other error sumvalue
learning
occurs of
of
is x
rìng. Here, and x
because is: Python
y Output
'+ is: 10
combines
one 15
value
two
is
integer strings.
Example Output
num=input ("Enter a number: ") Enter a number: 2
num=int (num) Square of number is: 4
print("Square of number is:", num** 2)
weight=input ("Enter your weight:") Enter your weight:50.5
weight=float (weight) Your weight in pounds is:
pound=weight * 2.20462 111.33330999999998