minte9
LearnRemember / PYTHON





pag. 26
pag. 86

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



  Last update: 17 days ago


Questions and answers:




Concatenate two strings in Python.

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

The ^ in the 6^2 represents:

  • a) exponential operator
  • b) bitwise XOR operator

Divide two numbers and round down (floor division):

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


References and applications:






Related pages graph: