Python Tutorial for Beginners 3 - Basic Math, Mathematical Operators and Python Expressions

preview_player
Показать описание
In this Video I am going to show How to Use Basic Math, Mathematical Operators and Python Expressions In python.
So what is an expression ? An expression is A data value or set of operations to compute a value.
Arithmetic operators we will use:
+ - * / addition, subtraction/negation, multiplication, division
% modulus, a.k.a. remainder
** exponentiation
precedence: Order in which operations are computed.

Mathematical Operators
Here are some commonly used mathematical operators

Syntax Math Operation Name
a+b {\displaystyle a+b\,} a+b\, addition
a-b {\displaystyle a-b\,} a-b\, subtraction
a*b {\displaystyle a\times b\,} a\times b\, multiplication
a/b {\displaystyle a\div b\,} a\div b\, division (see note below)
a//b {\displaystyle \lfloor a\div b\,\rfloor } \lfloor a\div b\,\rfloor floor division (e.g. 5//2=2) - Available in Python 2.2 and later
a%b {\displaystyle a~{\bmod {~}}b\,} a~{\bmod ~}b\, modulo
-a {\displaystyle -a\,} -a\, negation
abs(a) {\displaystyle |a|\,} |a|\, absolute value
a**b {\displaystyle a^{b}\,} a^{b}\, exponent

Order of Operations (Python Operator Precedence)
Highest precedence at top, lowest at bottom.Operators in the same box evaluate left to right..

Name Syntax PEMDAS Mnemonic
Parentheses ( ... ) Please
Exponents ** Excuse
Multiplication
and Division * , / , // , % My Dear
Addition
and Subtraction + , - Aunt Sally

#PythonTutorialforBeginners #ProgrammingKnowledge #LearnPython #PythonCourse
★★★Top Online Courses From ProgrammingKnowledge ★★★

★★★ Online Courses to learn ★★★

★★★ Follow ★★★

DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!
Рекомендации по теме
Комментарии
Автор

Dear Sir, your tutorial extremely help me in my assignments and projects

rameezahmed
Автор

Nice
Sir this is python 3
OK
We want more python course

ashbin
Автор

Wow..Thanks for redoing this series..New thing is coming soon

hridoyahmed
Автор

I think you should correct your knowledge because priority is not defined on left to right basis. Division gets evaluated first after that multiplication. To prove my point I'll say do hands on with ur equation that is 5+9-6*10/20 and 5+9-10/20*6 both will give the same answer 11.0

surajkumarprajapati
Автор

It's really very helpful...thank u so much bro..!!!

AmanPandey-fuvy
Автор

Hi there, I'm a bit confused on this one (5+9)-6*(10/20). I do not see any areas where I can use the multiplication sign (*). It looks like multiplication is being bypassed and the priority is still the division sign inside a close parenthesis. Also, it looks like PEMDAS does not work on this one. If you look at the samples below, they all provide the same results. I'm looking for the purpose of the close parenthesis as PEMDAS seems not to work on this one, and how the multiplication sign is being used. Your feedback and insights would be a great help. Thank you.

5+9-10/20*6
11.0
5+9-6*10/20
11.0
(5+9)-6*(10/20)
11.0

stevenrodriguez
Автор

Sir give more details in tue video and example programs and assignments

salmankevin
Автор

hi there thanks for ur usefull tutorials.
ever before u was posted a video setup NOTEPAD++ plugin to run code
thanks

atg
Автор

Hi,
You explained that if we don't want decimal value, we can do 50 // 3. But how to do that in an expression of multiple operands. For example: 5 + 9 - 6 * 10 / 20 was giving the result as 11.0
How to get this expression result in just 11 (not 11.0)?

nikitamathur
Автор

Hi Programming Knowledge. My IDLE IDE is not opening, what should I do.

nayangohain
Автор

thanks for PEMDAS..It is like a BODMAS in mathematics

milankbudha
Автор

Hello dear,
so, i like your tuto very much, it's really useful for beginner,
but i don't understand why the videos are in reverse way, so it can't be read automatically,
i have to search the next tuto and cilck on it. this is not useful
please, if you can fix it, do it.
thanks

HassanBraim
Автор

Sir when I do .
60*20/30=400
Your answer is 40.0
Kya there is no difference between them
Why
When I do (5+9)-6*10/20
It's right.
Why sir tell me

Sankum
Автор

My mother wants to be a teacher 👩‍🏫 in white hat 🎩 junior



👇👍

anannyamantri