0% found this document useful (0 votes)
11 views11 pages

Adobe Scan 08 Sept 2024

Uploaded by

nikhat6332
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views11 pages

Adobe Scan 08 Sept 2024

Uploaded by

nikhat6332
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

bolsDigits

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

Using parentheses () You can also use parentheses to define a product=(70


24 *
multi-line statement.
45)
Using square brackets [ ]|You can use square brackets to create my_list=[
multi-line statements, particularly when apple
"banana
working with lists.
"orange
[email protected]
Ltd
Employeecode
Variable
Invalid
Name

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

Multiplication It multiplies two operands. >>2*10 20


Division Itdivides the left operand by the right one. >>13/2 6.5

It returns the remainder of the division of


% Modulus >>13%2 1
the left operand by the right.
Exponentiation It is used to raise the first operand to the >>3**2 9
power of the second operand.
It divides the value, and then truncates the
Floor Divisionquotient valueafter decimal point. It returns>>> 13//2 6
onlythe whole number.
Operator Name
Description Example Output

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

isthe It are true, |It any It


is retums returns
sion false.
and of
unary a
the
returns true
two true
operator when
is expressions when
false is
false
any
and that
only Description
both
one
returns
urns when expressions
of
thereturns
false, it
both
two
false true
the
expressions
when are
when expressions
true.
false.
f
1s

True
not
>>>not
False >>> False>>>True
>>>True False
and True
or >>>True and
False
Example
or
False

False True False True Output


False True
Operator Example Equivalent to
X=2 X=2

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

print ("Your weight in pounds is:", pound)


name=input("Enter your name: ") Enter your name: Shivani
msg="Welcome, + name + "!" Welcome, Shivani!
print (msg)

You might also like