PyNotes
260 subscribers
125 photos
7 videos
1 file
60 links
**Code is communication**
admin: @Xojarbu
https://t.me/solutions_py for problem solutions
Download Telegram
#compare
Package with module!
A module is a single importable Python file whereas a package is made up of two or more modules. A package can be imported the same way a module is. Whenever you save a Python script of your own, you have created a module.
#compare
*args and **kwargs
*args - allows your function to get infinite arguments (without keywords)
**kwargs - allows your function to get infinite keyword arguments

*args returns tuple
**kwargs returns dictionary

** — for passing keys and values
#compare
Function & Method

A function inside a class changes its name to “method” and method has to have at least one argument (i.e. self)
#compare
all() and any()
all()
method demonstrates if List1 has List2 elements

# List1
List1 = ['python' , 'javascript', 'csharp', 'go', 'c', 'c++']

# List2
List2 = ['csharp1' , 'go', 'python']

check = all(item in List1 for item in List2)

any() checks if the list contains any elements of another one:
# List1
List1 = ['python' , 'javascript', 'csharp', 'go', 'c', 'c++']

# List2
List2 = ['swift' , 'php', 'python']

check = any(item in List1 for item in List2)
#compare
Instance & Attribute

Instance
is a Python variable belonging to only one object, accessable in the scope of the object;

Class attribute is a Python variable belonging to a class rather than a particular object.