Python is a High
Python is a High
- A variable in python can start with a letter or underscore and can contain letters , numbers,
and uderscores
- Python is dynamic type
- In Python A block is defined by consistent indentation.
- Debugging in Python :
o Using Print Statment
o Use pdp (pdp.set_trace() : pause execution and open interactive debugging prompt)
o Use logging
o Unit testing (unittest, pytest,nose)
o Profiling and Perfortmance Debugging (cProfile) : pyhton -m cProfile qsdq.py
o Using trace for code coverage : python -m trace –trace qsdq.py
o Using IDE Debugger
o Summary of Best Practices:
For quick checks: Use print() or logging.
For detailed, step-by-step debugging: Use pdb or an IDE debugger.
For production code: Use logging instead of print statements.
For testing functionality: Use unit tests with pytest or unittest.
For performance issues: Use cProfile to identify bottlenecks.
- min(x,y,z) return the minimum value
- The function len can be used to find out the length of a string, among other things. The
function returns the number of characters in a string.
- odd numbers are integers that are not divisible by 2
- The continue command is use inside loop to skip the rest of the current iteration and move
directly to the next iteration of the loop
- Slicing is the process of selecting a substring from a string :
o String my_string = “EXEMPLARY"
o my_string[2:6] == “EMPL"
- The in operator can tell us if a string contains a particular substring.
- Python string method find tell us if a substring exists in a string and returns either the first
index where it is found, or -1 if the substring is not found within the string.
- Using global Keyword allows modification of global variables inside a function.