Let’s check out some exercises that will help understand Python Operators better.
Exercise 18-c: Addition using
Add 100 to the variable using +=.
Exercise 18-d: Modulus
Using modulus operator assign the remainder of 1000/400 to the variable.
Exercise 18-e: Power Operator
Using power operator **, assign the square of 11111 to the variable.
Exercise 18-f: Comparison Operator
Write a conditional statement (if else) which checks the first element in a list (index zero) and assign answer_1 to "Yes" if the first element is equal to "strawberry" else it should assign answer_1 to "No".
In conditional statements comparison operator == is used to check if 2 values are equal.
lst can be used to access the first element of the list.
if else structure can be used to create a conditional statement.
Please refer to this lesson if you need to refresh your knowledge of conditional statements (if, elif, else): Conditional Statements
if lst=="strawberry": answer_1="Yes" else: