Python Essentials Classroom Series – 07/Jul/2021

Primitives Variables and Expressions

  • To perform operations on the Variables we need operators
Operator Description
x + y Addition
x – y Subtraction
x * y Multiplication
x / y Division
x // y Integer Division or Truncating Division
x % y Modulo (Remainder)
-x Unary minus
+x Unary plus
x ** y x to the power of y

Preview

  • Common Mathematical functions
Function Description
abs(x) Absolute value
divmod(x,y) Returns (x//y, x%y)
round(x, [n]) Round to the nearest multiple of nth power
  • Comparision operators
Operator Description
x == y Equals to
x != y Not equals to
x < y Less than
x > y greater than
x >= y greater than or equals to
x <= y Less than or equals to
  • Logical Operators
Operator Description
x or y if either x or y is true it returns true, false otherwise
x and y if both x and y are true returns tru, false otherwise
not x if x is true returns false and if x is false returns true
  • Samples:
    • Refer Here for the samples created
    • Write expression in a python file to find the value of y Preview
    • Write a python expression for the below value Preview
    y = x ** 2 * z ** 2 /4 
    
    • Write a python expression for below value Preview Preview

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin