- BASICS
- Statements
-
Operators
- Functions
- Incremental
- Errors
- FUNCTIONS
- Function Definition
- Recursion
- Objects
- STRINGS
- Immutable
- Raw Strings
- Regex
- Validation
- Config
- Security
- Encrypt
- CLASS
- Definition
- Attributes
- Functional
- Methods
- COLLECTIONS
- Lists
- List Comprehension
- Dictionaries
- Dictionary Efficiency
- Tuples
- References
- Iterable
- STORAGE
- Files
- Databases
- Pipes
- With Open
- Shelve
- Zip
- Csv
- Json
PYTHON PAGES - LEVEL 1
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
"""
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