0 ratings0% found this document useful (0 votes) 28 views10 pagesPython Notes Basic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
masai
12 Anouncerents
SD tecares
gue
9 Praia Tess
suppor ket
ptcanesecral cams 929%
seroma aes ee ee
‘Mathematical & Comparison Operator 9:
Bnet st satire
‘Student Notes for Mathematical Operators & Comparison Operator
‘operators are used to perform operations on variables and values.
What are the basic mathematical operations?
‘The common operators in Javascript are:
‘Addition
subtraction
Mutipication
Division
Problem: Given a=15,b=25.Caleulate sum, dit
168, product, and vision.
Real-world example
Visit amazon.com, and add some products tothe cart.
[Adding products leads to an increase in the cart pri
‘Manipulating the quantity or Adding the items affects the total
used behind the piet
‘This is how Mathematical operators are
Modulo Operator(%) [Remainder]masai
12 Anouncerents
SD tecares
gue
9 Praia Tess
suppor ket
saconsrastcholcomtachresrazantab-roos
‘when we divide a number into another, there are 4 terms that we need to understand
quotiont
divisor
dividend
remainder
‘about the above terms
Looking at the above picture, you will get cle
‘The remainder represents by %.
For x: var result =78 % 4 [ Read as 75 Modulus 4]
Explaining Modulus
Lot take the analogy:
‘There are many candidates who came to the company office to give interviews.
Since there are more than 100 candidates, 4 Interview panel setups where one interviewer is used totakethe
Interviews,
40100, interview Panel1is assigned to D1,
‘Aunique dis assigned to each candidate, starting from 1.2.3.
Interview Panel is assigned to D2, and so on.
Now, the qué
jonis Which Interview Pane! willbe assigned to Candidate 25?
The Solution Lis in Modulus: Just ealeulate 25 % 4 [since there are 4 interview Panel]
Result=25% 4=1
Candidate 25 is assigned to Interview Pant
‘The power of zlles in distributing
Google Server Analogy
‘Also, Using the same analogy of 4 Google servers and more than 1000 requests coming ina sequence.
Which server will procoss the 62rd requost?
Exponentiation Operator(**)
Explain the exponentiation operator with examples, Also discuss the difference between *
and **masai
12 Anouncerents
SD tecares
gue
9 Praia Tess
suppor ket
ptcaneseacrol amass 929%
tis used to compute the power of any number
Difference between * and **
screenshot (205).png
Find Square root using Exponentiation Operator
How to Solve long expression?
Discuss the steps to solve long expressions using brackets
you want to solve long expressions containing multiple operatior
Putting brackets also gives readability to code,
For x:
expr= ((atb)*(e+d))/0
Solve the Expression
Forex:a=3;b=2;
sum = (02) + (62) + (c2); #4(32)+(22)+(42) prnt(sum) #18 the sum
String Concatenation
Discuss examples of how to concatenate multiple strings
Coneatenation means a serie
interconnected things.
Use + tojoin two or more stringExample!
masai
12 Announcements
SD tecares
gu ‘The problem statementis to store the following information into @ unique vari
9 Praca Tess rea
2a Disussons city
‘The tasks to print the complete address.
CConeatenation with Numbers
Ifyou could write a book, what would it be about?
What are Comparison Operators?
‘Comparison operators ares
for comparing two values.
‘There are 6 comparison operators:
> (Greater Than)
(Greater Than Equal To)
« (Less Than)
«<= (Loss Than Equal To)
suppor ket
ptcanesecral cams 929%qual)
masai 1 (not Equal)
FH vasnooars ‘The result of a comparison operatoris always a boolean value.
12 Anouncerents Greater Than Operator ( >)
SD tecares
Puntitied
) Asserments 3 values strictly greater than the second value. For ex-
rice tes Finis mas mt
ss Discussions ‘The first value is loss than oF equal to the second value. For ox
suppor ket
pcane seer cams 929%masai
BE vasnooars ‘There is some problem with the above solution, what ifthe Sunil markis 35
Inthat case, the above coco will give the result false but in reality, it shoul
12 Announcements rue
SD tecares .
‘thus, we will use2 (greater than or equel te) to solve this problem
gue
9 Praca Tess
Note
> 3ieFalee
2>-3ie Tue
Greater Than Equal To Operator ( >=)
‘The first value is greater than or equallto the second value. F
suppor ket
saconsrattcholcomtachresrazantab-roos sinoCode 3: Try these questions on Repilt
masai
12 Announcements
& cures rine
Note:
aoe ais Tue
gue 2>=-3ie Tue
2% race es Less Than Operator (<)
sta seusions ‘Tho first valuo is strictly loss than the second value. For x
‘The first value is greater than or equal tothe second value. For ex
Code 4: Check whether Sunil falled or not, where the passing markcis 35
Inthe above code, wo can not uses (lesser than or equal to), it will give the wrong result,
Less Than Equal to Operator ( <=)
‘The first value is strictly less than or equal to the second value. For ex:
Not
suppor ket
pcaneseacral amass aTb-raot m0masai. a4
‘2 Announcements ‘The firs value is greater than the second value. For ox:
SD tecares .
- Untitled design (i) mp4
Problems
gue
Code 5: Those customers willbe eligible for the amazon discount whose spending is equal to or above 4000. Check
9 Praca Tess whether a customer Sams eligible fr a discount or not
ao Wrong Code
‘The probiem with the above code, we have used only greater than butn the question itwas given that.
“eligible for the arnazon discount whose spending Is equal to or above 4000".
correct code
Code 6: Check whether Heeralals eligible for driving a vehicte in india,
‘The legal agen india for driving a vehicles 18+,
(supporter rv
psoconsrastcholcomtachresrazanab-roos sinomasai
12 Anouncerents
SD tecares
gue
9 Praia Tess
suppor ket
Equal (=
Itehecke whether the two operands are identical or not
Forex:
Code 7:0n Repilt
Code 8: Find the output
51 4ie True,
saconsrattcholcomtachresrazantab-roosmasai.
BB vasnaoars
SD tecares
Blended earning
© Assignments
gue
Praia Tests
ots Discussions
suppor ket
Nees Geren
‘A IeFalse
Code 9: Find the output
‘Code 10: Find the output
Happy Coding!
saconsrastcholcomtachresrazantab-roos