“Basic Operators” is a tutorial that covers the fundamental operators in Python. The tutorial begins by defining what operators are and why they are useful in programming. It explains how operators are used to perform different types of operations on values in Python, including arithmetic, comparison, logical, assignment, and membership operations.


#BODMAS finally comes in use..
number = 1 + 2 * 3 / 4.0
print(number)

#Modulo
remainder = 11 % 3
print(remainder)

#To the Power of
squared = 7 ** 2
cubed = 2 ** 3
print(squared)
print(cubed)

#Concatenation
helloworld = "hello" + " " + "world"
print(helloworld)

The tutorial covers a wide range of arithmetic operators, including addition, subtraction, multiplication, division, and modulus, as well as more complex operators like exponentiation and floor division. It also covers comparison operators, such as equal to, not equal to, greater than, less than, and others, as well as logical operators, including AND, OR, and NOT.

In addition to these basic operators, the tutorial also covers assignment operators, which are used to assign values to variables, and membership operators, which are used to check if a value is present in a sequence.

Throughout the tutorial, there are numerous practical examples and exercises to help reinforce the concepts covered. These examples cover a range of real-world scenarios, such as performing mathematical calculations, comparing values, and working with lists and dictionaries.


#Hello x10
lotsofhellos = "hello" * 10
print(lotsofhellos)

#List Merging
even_numbers = [2,4,6,8]
odd_numbers = [1,3,5,7]
all_numbers = odd_numbers + even_numbers
print(all_numbers)

#Repeating Lists
print([1,2,3] * 3)

The tutorial concludes by introducing some advanced topics related to working with operators, including operator precedence, which is the order in which operators are evaluated in Python, and operator overloading, which allows you to define custom operators for your own classes.

Lists Exercise Solution


# Code Completed
x = object()
y = object()

# TODO: change this code
x_list = [x] * 10
y_list = [y] * 10
big_list = x_list + y_list

print("x_list contains %d objects" % len(x_list))
print("y_list contains %d objects" % len(y_list))
print("big_list contains %d objects" % len(big_list))

# testing code
if x_list.count(x) == 10 and y_list.count(y) == 10:
    print("Almost there...")
if big_list.count(x) == 10 and big_list.count(y) == 10:
    print("Great!")

Overall, “Basic Operators” is an excellent resource for anyone looking to learn the fundamental operators in Python. Its clear and concise explanations, practical examples, and interactive exercises make it an ideal resource for beginners and intermediate programmers alike. Whether you are looking to perform simple calculations or complex operations in Python, this tutorial is an excellent starting point.