Operators

 
""" The + operator concatenates two strings
    The * operator performs repetitions on strings
"""

a = 'Hello'
b = 'World'

print(a + ' ' + b) 
print(a * 3) 

"""
    Hello World
    HelloHelloHello
"""

Exponential

 
n = 6**2 + 6

print(n)  # 42

Bitwise

 
n = 6^2  # XOR

print(n)  # 4

Division

 
n = 105 / 60

print(n)  # 1.75

Floor Division

 
minutes = 105
hours = minutes // 60

remainder = minutes - hours*60
print(remainder)  # 45






Questions and answers:
Clink on Option to Answer




1. Concatenate two strings in Python.

  • a) a + ' ' + b
  • b) a . ' ' . b

2. The ^ in the 6^2 represents:

  • a) exponential operator
  • b) bitwise XOR operator

3. Divide two numbers and round down (floor division):

  • a) 150 % 60
  • b) 150 // 60


References: