pythonsecrets Profile Banner
Python Tips Profile
Python Tips

@pythonsecrets

Followers
14
Following
0
Media
19
Statuses
23

🐍Unlock the power of Python with daily tips and tricks! 💡Stay ahead in coding with concise and insightful Python hacks.

Joined October 2023
Don't wanna be here? Send us removal request.
@pythonsecrets
Python Tips
2 years
11. dir(), dir(object) Without arguments, return the list of names in the current local scope. With an argument, attempt to return a list of valid attributes for that object.
0
0
0
@pythonsecrets
Python Tips
2 years
10. dict(**kwarg) To create a dictionary with kwargs or two list with same length. ?? What is the use of Zip here. Any guess which will be key - name or Python.
1
0
0
@pythonsecrets
Python Tips
2 years
9. delattr(object, name) Used to delete an attribute of an object, provided its name as a string #Python #pythonprogramming Tip: delattr(obj, 'y') is similar to del obj.y Output??
1
0
0
@pythonsecrets
Python Tips
2 years
8. complex(real=0, imag=0) Return a complex number with the value real + imag*1j or convert a string or number to a complex number. #python #pythonprogramming Tip: complex('1 + 2j') raises ValueError, spaces not allowed. Output??
1
0
0
@pythonsecrets
Python Tips
2 years
7. callable(object): Return True if the object argument appears callable, False if not. A callable is any object that can be called like a function. Objects can implement the __call__ method to make instance callable. Output??
1
0
0
@pythonsecrets
Python Tips
2 years
6. bytearray(source, encoding, errors): Return a new array of bytes. The bytearray class is a mutable sequence of integers in the range 0 <= x < 256. What is the output?? Tip: chr(266) is 'Ċ'
1
0
0
@pythonsecrets
Python Tips
2 years
5. bool(x=False): Return a Boolean value, i.e. one of True or False. x is converted using the standard "truth testing procedure". If x is false or omitted, this returns False; otherwise, it returns True. Tip: 0, None, False, empty sequence and collection etc... are False.
1
0
0
@pythonsecrets
Python Tips
2 years
4. bin(x): Convert an integer number to a binary string prefixed with “0b”. What will be the output?? Tip: '0b101' represents 5 and is a valid Python expression.
1
0
0
@pythonsecrets
Python Tips
2 years
3. any(iterable): Return True if any element of the iterable is true. If the iterable is empty, return False Added custom any function as reference.
1
0
0
@pythonsecrets
Python Tips
2 years
2. all(iterable): Return True if all elements of the iterable are true (or if the iterable is empty) Try to implement the function for this logic. What is the output for the below code??
1
0
0
@pythonsecrets
Python Tips
2 years
1. abs(): Return the absolute value of a number. Implement __abs__() to have this on user defined object. Try passing complex object to abs() 🤔 Now what will be the output??
1
0
0
@pythonsecrets
Python Tips
2 years
🧵Python: Built-in Functions. There are around 70 built in functions always available.
1
0
0
@pythonsecrets
Python Tips
2 years
Starting a Python challenge ♾and will try to cover most of the @Python Standard Library concepts. #Python #PYthonTips #Pythonsecrets
0
0
0
@pythonsecrets
Python Tips
2 years
Wondering how to get the file path? Useful in debug logs for bigger projects.
0
0
0
@pythonsecrets
Python Tips
2 years
So, what's happening here? What will be the output?
1
0
0
@pythonsecrets
Python Tips
2 years
What is the Output? 1. Car 2. BMW 3. Error 4. None
0
0
0
@pythonsecrets
Python Tips
2 years
Day $ Coding. Solvin https://t.co/XlLWon8iYs After so many efforts all the test cases were not accepted. Finally noticed a blunder I was doing. Any guess what could be wrong here?
0
0
0
@pythonsecrets
Python Tips
2 years
#Python Using 'filter' to easily discard the elements from a sequence. Implement a function to return Boolean based on the criteria. *Use filter to remove the elements not satisfying the criteria. Follow @pythonsecrets
0
0
0
@pythonsecrets
Python Tips
2 years
Use of "for-else" in #Python. If 'break' is executed else will be skipped. If not else will be continued (no odd numbers). @pythonsecrets
0
0
0
@pythonsecrets
Python Tips
2 years
#Python What will be the output?
0
0
1